what we are gonna do is interfacing MSP430 with an LCD module. In this case a typical 16×2 parallel LCD module with the Texas Instruments’ MSP430G2211 on Launchpad development board. i will not cover much on the LCD side because i have already explained the working of HD44780 LCD in my previous post.
if you are new to LCD and have no idea how to make them work. checkout my previous post
The MSP430 (like most MCUs today) runs on 3.3-3.5V. If you get an LCD module that only work with 5V then be prepared to either have separate voltage sources for your MCU and LCD or have the ability to step up/down your voltage source. Here’s a
link that has some ideas on how to do this.
i seen some lcd which works with both of the power (3.5V and 5V) supply but contrast is as low as you need to have special focus on the lcd to see the characters on the lcd . so be aware of low lcd contrast when 3.5 v power is there
MSP430 Pin configuration to LCD
Here’s how the MCU pins are interfaced to the LCD. all pin Number with MSP430G2211
MCU PIN Number |
LCD PIN Number |
FUNCTION |
PORT1.0 Pin 1 |
11 |
D4 |
PORT1.1 Pin 2 |
12 |
D5 |
PORT1.2 Pin 3 |
13 |
D6 |
PORT1.3 Pin 4 |
14 |
D7 |
PORT1.6 Pin 8 |
6 |
EN |
PORT1.7 Pin 9 |
4 |
RS |
The other LCD pins connections are as follows:
Pin 16 | GND
Pin 15 | Power for LED
Pin 5 | (R/W) is grounded because we are always writeing to lcd (UPDATED)
Pin 3 | Outout from potentiometer for LCD contrast
Pin 1 | GND
Pin 2 | Vcc
Software Source Code
The software code is easy to under sand and reusable in another application because
i have created a header file which have all the routines to control the lcd
all you have to do is copy the hearder file lcd16.h and lcd16.c into your project directory
#include “lcd16.h”
Routines in the program
void lcdinit(void); // This routine take no input and return nothing. it initialize the lcd
void integerToLcd(int integer ); ); //This routine take an integer as input and print that number to LCD
void lcdData(unsigned char l); // This rountine take a ASCII value and print the corresponding char to the LCD
void prints(char *s); // This rountine take a String value as input and print the corresponding char to the LCD
void gotoXy(unsigned char x,unsigned char y); //This routine will take the cursor to a specific position on the lcd.
CLICK HERE TO DOWNLOAD The SOURCE CODE