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.

16X2 LCD character display LED with MSP430G2553

Other Parts Discussed in Thread: MSP430G2553

Hello sir/mam,

I am doing 16X2 LCD character display programming in 4 bit mode using MSP430G2553 microcontroller .My code is  given below  and Hardware connections are also attached.After powering up the board,the LCD  glows but why the characters are not showing?

#include  "msp430g2553.h"

#include  "stdio.h"

#include  "string.h"

#include "stdlib.h"

#define delay_value 500

 

void LCD_Init(void)

{

 send_cmd(0x38);   // configure LCD as 2 lined 5x7 matrix

 delayms(delay_value);

 send_cmd(0x0E);   //display on, cursor blink

 delayms(delay_value);

 send_cmd(0x06);  // auto <span id="IL_AD10" class="IL_AD">increment</span> of cursor

 delayms(delay_value);

 send_cmd(0x01);  // <span id="IL_AD3" class="IL_AD">clear display</span>

 delayms(delay_value);

 

}

 

void send_cmd(unsigned char command)

{

 

 P1OUT &= 0X00;

 P2OUT &= 0X00;

 P2OUT = command;

 P1OUT &= 0X00;

    P1OUT &= ~0x40;                        // RS = 0 for command, P1.6 0x40

    //RW is grounded

    P1OUT &= ~0x80;                        //EN = 0, P1.7, 0x80

    delayms(delay_value);

    P1OUT |= 0x80;                        // EN = 1, P1.7, 0x80

    delayms(delay_value);

    P1OUT &= ~0x80;                        //EN = 0, P1.7, 0x80

    delayms(delay_value);

 

}

 

void send_char(unsigned char character)

{

 P1OUT &= 0X00;

 P2OUT &= 0X00;

 P2OUT = character;

  // P1OUT &= 0x00;

     P1OUT |= 0x40;                        // RS = 0 for command, P1.6

   //  RW is grounded

     P1OUT &= ~0x80;                        //EN = 0, P1.7

     delayms(delay_value);

     P1OUT |= 0x80;                        // EN = 1, P1.7

     delayms(delay_value);

     P1OUT &= ~0x80;                        //EN = 0, P1.7

     delayms(delay_value);

}

 

 

void send_string(char *String)

{

unsigned char i=0;

 

 while(String[i]!='\0')

 {

 

  P1OUT &= 0X00;

  P2OUT &= 0X00;

  P2OUT = String[i];

  P1OUT |= 0x40;                        // RS = 0 for command, P1.6

     //  RW is grounded

  P1OUT &= ~0x80;                        //EN = 0, P1.7

  delayms(delay_value);

  P1OUT |= 0x80;                        // EN = 1, P1.7

  delayms(delay_value);

  P1OUT &= ~0x80;                        //EN = 0, P1.7

  delayms(delay_value);

  if(i>=16)   // If the number of characters in the string > 16, then the below command automatically

  send_cmd(0x18);  // Shift the display right side

  delayms(40000);   // 100 millisec <span id="IL_AD5" class="IL_AD">delay</span>

  i++;

 }

 

}

void delayms(unsigned int value)

{

 unsigned int i;

 for(i=0;i< __delay_cycles;i++);

}

 

 

 

 

void main(void)

{

  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

  BCSCTL1 = CALBC1_1MHZ;                    // Set DCO

  DCOCTL = CALDCO_1MHZ;

  BCSCTL2 &= ~(DIVS_3); //This line of code ensures that the SMCLK divider is 0,

   // so we have SMCLK=DCO=1MHz (in fact if we are to have a /8 divider, it should be BCSCTL2 |= DIVS_3;).

 

 

  P1DIR = 0xFF; // make P1 as output

  P2DIR = 0xFF; // make P2 as output

 

 

  P2SEL = 0;  // These two are "Function Select Registers PxSEL and PxSEL2",

  P2SEL2 = 0; // If both are zero's means simple I/O function is selected.

 

 

 

  P1DIR |= 0x01;                            // Set P1.0 to output direction

  P1REN |= 0x01;

 

 

   delayms(1500); // wait for more than 15ms after supply rises to 4.5V

   send_cmd(0x30);

   delayms(400);  // wait more than 4.1ms

   send_cmd(0x30);

   delayms(100);  // wait more than 100us, but delayms(1) will provide 1ms

   send_cmd(0x30);

   delayms(100);

   send_cmd(0x02); // return to home

   delayms(100);

 

 

  LCD_Init(); // LCD initialization

 

 

   while(1)

   {

 

   send_cmd(0x01);  // clear display

       delayms(delay_value);

       send_cmd(0x81);  // clear display

       delayms(delay_value);

       send_string("NPEDUCATIONS");

       delayms(delay_value);

   send_cmd(0xC0);  // clear display

       delayms(delay_value);

       send_string("http://www.npeducations.com");

       delayms(delay_value);

   }

 

}

 

}

  • Hi Abhshek,

    This is difficult for me to debug because I don't know what commands the LCD needs in order to display properly or the amount of delay it needs in between data. I did notice a few things though:

    In main(), why are you sending commands before initializing the LCD? My guess is that this is most likely an issue with sending the wrong commands or not setting up the display in the correct order.

    Best regards,
    Caleb Overbay
  • Hi Abhishek,

    Do you still need assistance with this issue or would you like to share your solution?

    Best regards,
    Caleb Overbay
  • hello abhishek,

                                     have you tried to vary the voltage on contrast adjust pin of LCD? it is normally b/w 0.4 to 0.9V.(PIN no 3)

**Attention** This is a public forum