This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Help!!! 16x2 lcd interfacing with msp430g2211

Other Parts Discussed in Thread: MSP430G2211

I'm trying interfacing a standard 16x2lcd whit a msp430g2211, but I can't , I'm tired and I don't know what to do,I tried everything but  I can't see a single character. please help!

thanks a lot!

my code:

/*Here's how the MCU pins are interfaced to the target.

MSP430 LCD interface
Function | MSP Pin
----------------------------
RW | GND
RS | P1.0
EN | P1.1
DB7 | P1.7
DB6 | P1.6
DB5 | P1.5
DB4 | P1.4
DB3 | GND
DB2 | GND
DB1 | GND
DB0 | GND
/////////////////////////////// */

#include <msp430g2211.h>

#define EN BIT1
#define RS BIT0
#define PIN_MASK ((RS | EN | BIT7 | BIT6 | BIT5 | BIT4))

void waitlcd(volatile unsigned int x)
{
volatile unsigned int i;
for (x ;x>1;x--)
for (i=0;i<=110;i++);
}

void lcdcmd(unsigned char Data)
{
P1OUT &= ~RS; //because sending command
P1OUT &=~EN;

P1OUT |= (Data & 0xF0);
P1OUT |=EN;
waitlcd(2);
P1OUT &=~EN;

P1OUT |= ((Data & 0x0F) << 4);
P1OUT |=EN;
waitlcd(2);
P1OUT &=~EN;
}

void lcdData(unsigned char l)
{
P1OUT |=RS; //because sending data
P1OUT &=~EN;

P1OUT |=(l & 0xF0);
P1OUT |=EN;
waitlcd(2);
P1OUT &=~EN;

P1OUT |= ((l & 0x0F) << 4);
P1OUT |=EN;
waitlcd(2);
P1OUT &=~EN;
}

void lcdinit(void)
{
P1DIR |= PIN_MASK;
P1OUT &= ~(PIN_MASK);

waitlcd(250);

P1OUT &= ~RS; //because sending command
P1OUT &=~EN;

P1OUT =0x20;//set data length 4 bit
P1OUT |=EN;
waitlcd(2);
P1OUT &=~EN;

waitlcd(250);
lcdcmd(0x28); //set data length 4 bit 2 line
waitlcd(250);
lcdcmd(0x0E); // set display on cursor on blink on
waitlcd(250);
lcdcmd(0x01); // clear lcd
waitlcd(250);
lcdcmd(0x06); // cursor shift direction
waitlcd(250);
lcdcmd(0x80); //set ram address
waitlcd(250);
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;// Stop watchdog timer

BCSCTL1 = CALBC1_1MHZ; //BCSCTL1 Calibration Data for 1MHz
DCOCTL = CALDCO_1MHZ; //DCOCTL Calibration Data for 1MHz

lcdinit();
lcdData('A');

for(;;){
waitlcd(1);
}

}// end main

  • the code seem correct.

    most of the time when the code is correct, the problem is on hardware.

    Last time when i started on lcd 16x2, i have same problem.

    Later on, i found out is the contrast problem which set on pin 3.

    I didnt set the tune the trimmer correctly.

**Attention** This is a public forum