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.

display on lcd using msp430g2553 with launch pad

Other Parts Discussed in Thread: MSP430G2553

i want to interface LCD with MSP430G2553 using LAUNCHPAD..i have a code which builds and debugs but not displaying any output on LCD.

Below is the code and plz help me out.if any other code is there then it would also welcome.

waiting for rply..

thank u

C CODE:

#include <msp430.h>
#include <stdio.h>
#include "LCD_20x4.h"

void Delay_ms(unsigned int i)
{
unsigned int j,k;

for(j=0; j<i; j++)
for(k=0; k<60000; k++);
}

int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
LCDputs("how are you");
while (1)

for (;;)
{
volatile unsigned int i;

P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR

i = 50000; // Delay
do (i--);
while (i != 0);
}
}

// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}

SOURCE FILE OF LCD_20x4.h

#ifndef __LCD_C__
#define __LCD_C__

#define LCD_ENABLE_PIN_L P1OUT &= ~(0x01<<5);
#define LCD_RS_PIN_L P1OUT &= ~(0x01<<7);
#define LCD_RW_PIN_L P1OUT &= ~(0x01<<6);
#define LCD_DATA4_L P1OUT &= ~(0x01<<4);
#define LCD_DATA5_L P1OUT &= ~(0x01<<3);
#define LCD_DATA6_L P1OUT &= ~(0x01<<2);
#define LCD_DATA7_L P1OUT &= ~(0x01<<1);

#define LCD_ENABLE_PIN_H P1OUT |= 0x01<<5;
#define LCD_RS_PIN_H P1OUT |= 0x01<<7;
#define LCD_RW_PIN_H P1OUT |= 0x01<<6;
#define LCD_DATA4_H P1OUT |= 0x01<<4;
#define LCD_DATA5_H P1OUT |= 0x01<<3;
#define LCD_DATA6_H P1OUT |= 0x01<<2;
#define LCD_DATA7_H P1OUT |= 0x01<<1;

#define LCD_STROBE {LCD_ENABLE_PIN_H; LCD_ENABLE_PIN_L;}
#define LCMD 1
#define LDATA 0
#define LCMDDELAY 1000//2
#define LDATADELAY 500//0
#define LCD_CURSOR_ON 1
#define LCD_CURSOR_OFF 0
#define LCD_LEFT 1
#define LCD_RIGHT 0


extern void Delay_ms(unsigned int i);

void LCDSendByte(unsigned char value, unsigned char type);
void LCDInit(void);
void LCDputc(unsigned char dat);
void LCDClear(void);
void LCDGoHome(void);
void LCDShift(unsigned char side, unsigned char space, unsigned char speed);
void LCDCursor(unsigned char state);
void LCDGotoXY(unsigned char x, unsigned char y);
void LCDputs(char* dat);

void LCDSendByte(unsigned char value, unsigned char type)
{
unsigned char temp_i;

if(type)
{LCD_RS_PIN_L;}
else
{LCD_RS_PIN_H;}

LCD_RW_PIN_L;

for(temp_i=0; temp_i<2; temp_i++)
{
if(value & (0x01 << 7))
{LCD_DATA7_H;}
else
{LCD_DATA7_L;}

if(value & (0x01 << 6))
{LCD_DATA6_H;}
else
{LCD_DATA6_L;}

if(value & (0x01 << 5))
{LCD_DATA5_H;}
else
{LCD_DATA5_L;}

if(value & (0x01 << 4))
{LCD_DATA4_H;}
else
{LCD_DATA4_L;}

LCD_STROBE;
value = value << 4;
}
}


void LCDInit(void)
{
const unsigned char init[] = {0x02, 0x28, 0x0C, 0x06};
unsigned char temp_i;

for(temp_i=0; temp_i<4; temp_i++)
{
LCDSendByte(init[temp_i],LCMD);
Delay_ms(LCMDDELAY);
}
}


void LCDputc(unsigned char dat)
{
LCDSendByte(dat,LDATA);
Delay_ms(LDATADELAY);
}


void LCDClear(void)
{
LCDSendByte(0x01,LCMD);
Delay_ms(LCMDDELAY);
}


void LCDGoHome(void)
{
LCDSendByte(0x02,LCMD);
Delay_ms(LCMDDELAY);
}


void LCDShift(unsigned char side, unsigned char space, unsigned char speed)
{
unsigned char temp_i;

if(side)
side = 0x18;
else
side = 0x1C;

for(temp_i=0; temp_i<space; temp_i++)
{
LCDSendByte(side,LCMD);
Delay_ms(LCMDDELAY*(255 - speed));
}
}


void LCDCursor(unsigned char state)
{
if(state)
state = 0x0F;
else
state = 0x0C;
LCDSendByte(state,LCMD);
Delay_ms(LCMDDELAY);
}


void LCDGotoXY(unsigned char x, unsigned char y)
{
unsigned char address;

switch(y)
{
case 1:
address = 0x80;
break;
case 2:
address = 0xC0;
break;
case 3:
address = 0x94;
break;
case 4:
address = 0xD4;
break;
default:
break;
}

address += (x - 1);

LCDSendByte(address,LCMD);
Delay_ms(LCMDDELAY);
}

void LCDputs(char* dat)
{
while(*dat)
LCDputc(*dat++);
}

#endif

  • chothani amit said:
    i want to interface LCD with MSP430G2553 using LAUNCHPAD..i have a code which builds and debugs but not displaying any output on LCD.

    Below is the code and plz help me out.if any other code is there then it would also welcome.

    Code isn't everything. Since the LaunchPad does not have built-in LCD, you can't be sure that the code you use will match the LCD you use. There is no generic 'the LCD' an more than one way to connect it.

    Likely, the code is okay, but either your LCD or the way you connected it to the MSP doesn't match the setup for which the code was written.

    If so, nobody can help you without knowing your exact schematics and the exact specifications of the LCD you use.

    And even if connection and LCD type are okay, there might be a supply issue. The LaunchPad cannot provide unlimited supply. Maybe the LCD needs an external supply.

    Just a few thoughts.

**Attention** This is a public forum