Introduction: CSCI255 LCD Final

Learn to display temperature to an LCD from a MSP430 micro-controller.

Step 1: Get the LCD

  1. Purchase the LCD below, or one similar.

http://www.newhavendisplay.com/nhdc0216cznswbbw3v3...

Step 2: Data Sheet

  1. Use page 4 to connect to your micro-controller and learn the pins.
  2. Use sample code provided on page 10. We will later edit this to fit our needs
  3. Use page 9 to learn how to display characters and symbols.

Attachments

Step 3: Connecting Display to Micro-controller

  1. Connect Pin 1.1 to CS (Purple)
  2. Pin 1.2 to RS (Grey)
  3. Pin 1.3 to BL (Black)
  4. Pin 1.5 to CLK (Green)
  5. Pin 1.7 to MOSI (Blue)
  6. Apply correct voltage (3.3) to VSS (Red)
  7. Connect ground to VDD (Brown)

Step 4: Declare Variables

While these are the variables we chose, there are many different approaches that can be used.

int adc[10] = {0};

int avg_adc = 0;

volatile int bit;

volatile int i,n, zeroth,first,second;

float temp;

float degF;

float longfirst;

Step 5: Initialize Functions

void adc_Setup();

This function points the ADC to the internal temperature sensor

void adc_Sam10();

Tells the micro-controller to continuously sample ADC

void Initialize();

Initializes the LCD to the desired settings

void Writecom();

Initializes function for future use, also sets the cursor on LCD

void Writedata();

Initializes function for future use

void Temperature();

Prints the word "Temperature" on the top row, also used to print character value to LCD

Step 6: Write Setup Functions

  1. Enable the ADC interrupt service routine
  2. Setup the ADC interrupt and point to internal temperature sensor
  3. Set the ADC sampling
  4. Initialize the LCD

Step 7: Write the LCD Communication Function

  1. Set CS and RS pins low
  2. Send the Most Significant Bit (MSB) to LCD through pin 1.7
  3. Shift one bit left
  4. Send a low, high, and low clock signal
  5. Repeat steps 1-4 (MSB will shift each time)
  6. After 8 bits are sent, set CS high, and return to where function was called
  7. This function is used to set cursor and other settings for LCD

Step 8: Write Data to LCD

  1. Set CS low and RS high

  2. The rest will be the same as function described in Step 7

  3. This function is used to write characters to the LCD display

Step 9: Write a Function to Display Temperature

  1. Create a character array of integers(0-9) used to convert integers to ASCII
  2. Use Writecom function to set cursor to top left
  3. Use Writedata to print "Temperature" one character at a time
  4. Move cursor to second row using Writecom
  5. Calculate value of the three individual characters
  6. Use Writedata to display the characters one at a time
  7. Use Writedata to display °F

Step 10: Write Main Function

  1. Stop Watch Dog Timer
  2. Initialize MSP430 I/O pins
  3. Call the initializing functions
  4. Create forever loop
  5. Turn LCD back light on
  6. Call ADC sampling function
  7. Calculate temperature using ADC
  8. Call temperature display function
  9. Insert an optional delay to slow sample and display rate