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.

CCS/MSP430G2553: LCD interfacing

Part Number: MSP430G2553

Tool/software: Code Composer Studio

Hi,

For below code,am not getting output. Please suggest me what's the error in code.

#include <msp430.h> #include<lcd_header.h> /** * main.c */ void main(void) { WDTCTL = WDTPW + WDTHOLD; // stop watchdog timer lcd_init(); send_command(0x80); send_string("Sri Ram"); send_command(0xC0); send_string("KIT"); while(1){} } #include <msp430g2553.h> #define DR P2OUT = P2OUT | BIT0 // define RS high #define CWR P2OUT = P2OUT & (~BIT0) // define RS low #define READ P2OUT = P2OUT | BIT1 // define Read signal R/W = 1 for reading #define WRITE P2OUT = P2OUT & (~BIT1) // define Write signal R/W = 0 for writing #define ENABLE_HIGH P2OUT = P2OUT | BIT2 // define Enable high signal #define ENABLE_LOW P2OUT = P2OUT & (~BIT2) // define Enable Low signal unsigned int i; unsigned int j; void delay(unsigned int k) { for(j=0;j<=k;j++) { for(i=0;i<=1000;i++); } } void data_write(void) { ENABLE_HIGH; delay(2); ENABLE_LOW; } void data_read(void) { ENABLE_LOW; delay(2); ENABLE_HIGH; } void check_busy(void) { P1DIR &= ~(BIT7); // make P1.7 as input while((P1IN&BIT7)==1) { data_read(); } P1DIR |= BIT7; // make P1.7 as output } void send_command(unsigned char cmd) { check_busy(); WRITE; CWR; P1OUT = (P1OUT & 0x00)|(cmd); data_write(); // give enable trigger } void send_data(unsigned char data) { check_busy(); WRITE; DR; P1OUT = (P1OUT & 0x00)|(data); data_write(); // give enable trigger } void send_string(char *s) { while(*s) { send_data(*s); s++; } } void lcd_init(void) { P2DIR |= 0xFF; P1DIR |= 0xFF; P2OUT &= 0x00; P1OUT &= 0x00; send_command(0x38); // 8 bit mode send_command(0x01); // clear the screen send_command(0x0E); // display on cursor on send_command(0x06);// increment cursor send_command(0x80);// cursor position }

  • Hi Darshan,

    What are you trying to accomplish with your code?

    Have you tried debugging? Please check out the code composer debug guide for reference.

    - Chris

  • You don't mention the particular display you are using so I am making an assumption here. Your lcd_init function isn't  correct. The flow charts for software initialization say stuff like:

    Wait more than 4.5ms after 5V applied.

    Function set command (cannot check busy flag)

    wait 4.1ms

    function set command again (cannot check busy flag)

    wait more than 100us

    function set command (busy flag can be checked AFTER this command)

    Final function set command. This is where your code starts! The manual I am looking at states that if you use the internal power on reset, the busy flag will go active 10ms after power is applied and remain active until the initialization commands are sent. So either way, your init code can't work.  Mostly because you use the busy flag when you can't

**Attention** This is a public forum