NPEDUCATIONS, Electronic circuits development, electronics tutorials, microcontroller tutorials and projects, advanced microcontroller (ARM) based tutorials and projects, Embedded c development, Embedded c for ARM cortex M, Intel IoT based projects, IoT projects, CC3200 launch pad projects, MSP430 Launchpad tutorials and projects, Tiva C launch pad tutorials and projects, 8051 tutorials and projects, sensor interfacing with microcontroller tutorials, data communications and networking tutorials, peripheral interfacing with microcontroller, led message scrolling display, arduino based tutorials and projects, intel galileo based tutorials and project, ADC interfacing tutorials, LED Blinking, LCD interfacing, Embedded System tutorials and projects, B.tech projects, M.tech projects, online Embedded C training

Interfacing 16x2 character LCD display with MSP430 Launch pad


Interfacing 16x2 character LCD display with MSP430 Launch pad is quite simple. You just need a separate 5V power supply to drive the LCD. One of the main advantages of MSP430 Launch pad is its in-built debugging feature and its pin configuration. In this tutorial, I am not going to start from the scrap of LCD. But I encourage you to read my previous tutorials about introduction to LCD and its interfacing to microcontroller, where you can find the LCD commands, LCD functions, LCD interface mechanism etc.  In this post, I just show the connections between the LCD and MSP430 Launch pad, A test program to  display a string of characters on it, and finally a small video is presented in which output of the program is shown.

1. Construction:
Generally 16x2 character LCD displays requires eight data lines, three control lines (RS, EN, R/W) and 5v power supply and common ground. Here the microcontroller belongs to MSP430 family which runs worth 3.3v USB power supply. But the 16x2 LCD requires 5v power supply which should be provided separately. Generally, when we interface the same LCD with 8051 microcontroller there is no need of separate power supply. Why because both LCD and 8051 microcontroller works with the same 5v supply.

A small important note for you “don’t use USB power supply taken from MSP430 launch pad for LCD display” which may damage your pc USB port, so be careful about that.

All the data lines of the LCD are connected to Port 2 pins of the MSP430G2553 microcontroller and the control lines connected to Port1 pins (RS - P1.6 and EN - P1.7). Another more import thing is that connect the ground pin MSP430 Launch Pad with LCD ground pin in order form the closed loop circuit. If you won’t connect the two grounds, then you notice some garbage characters appear on the LCD display while executing the program. One more important point in this tutorial that I connected the R/W pin of the LCD to ground, because I am not performing read operation on LCD, just write operation only. For write operation the LCD R/W pin should be connected to the ground.

2. Circuit Diagram to interface 16x2 LCD with MSP430 microcontroller:

Circuit Diagram to interface 16x2 LCD with MSP430 microcontroller

Note:
      1.   Don’t use USB power supply for LCD display which is taken from the MSP430 launch pad board.      Otherwise your pc USB port may damage by drawing more current from it. 
        2.   Join MSP430 launch pad ground point with LCD ground pin in order to form a closed circuit. Otherwise garbage characters will display.



/******************************************************************************************************************************/ // http://www.npeducations.com // MSP430_LCD.c // Author - lovakiranvarma, M.tech /******************************************************************************************************************************/ #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 increment of cursor delayms(delay_value); send_cmd(0x01); // clear display 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 delay 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); } }
You tube video:

2 comments :

  1. Thanks for stressing on notes :

    "Join MSP430 launch pad ground point with LCD ground pin in order to form a closed circuit. Otherwise garbage characters will display."

    This saved me!

    ReplyDelete
  2. Is this code perfectly working on MSP430?

    ReplyDelete

Thanks for visiting NPEDUCATIONS. We will contact you soon

2 comments :

Sandeep Tayal said...

Thanks for stressing on notes :

"Join MSP430 launch pad ground point with LCD ground pin in order to form a closed circuit. Otherwise garbage characters will display."

This saved me!

Dipankar Panda said...

Is this code perfectly working on MSP430?

Post a Comment

Thanks for visiting NPEDUCATIONS. We will contact you soon

If you really like this tutorial, Don't forget to give the comment or please subscribe to the RSS feed by submitting your E-mail or like our Facebook page.
Related Posts Plugin for WordPress, Blogger...

 
Powered by Blogger