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.

lcd 16*2 msp430f5529

Other Parts Discussed in Thread: MSP430F5529

has anybody interfaced 16*2 lcd using msp430f5529?

  • This is an extremely common application that is generally accomplished on the MSP-EXP430G2 LaunchPad:

    www.circuitvalley.com/.../16x2-char-lcd-with-ti-msp430-launch-pad.html
    forum.allaboutcircuits.com/.../
    www.instructables.com/.../
    blog.vinu.co.in/.../4-bit-interfacing-of-16x2-lcd-display.html
    www.golden-ic.com/.../solution.php
    bennthomsen.wordpress.com/.../
    www.npeducations.com/.../interfacing-16x2-character-lcd-display.html
    karuppuswamy.com/.../

    You can use these references to better-understand how communication with a character LCD is accomplished. Since both MSP430 devices use USCI peripherals for SPI/I2C communication it shouldn't be too hard to port one of the above examples for the MSP430F5529.

    Regards,
    Ryan
  • Hi Ryan,

    i tried interfacing lcd on msp430f5529, but when i execute my code it skips my delay routine...it never goes into the delay routine.

    here is my code,

    #include <msp430.h> 
    #include <in430.h>
    //#include <math.h>
    /*
    * main.c
    */

    void init_lcd();
    void cmd_wr(unsigned char ch);
    void data_wr(unsigned char dat);
    void delay(unsigned int i);
    void enable();

    void main(void)
    {

    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
    P1DIR = 0x1c;
    P2DIR = 0xF0;

    init_lcd();
    cmd_wr(0x85);
    data_wr('A');
    while(1);

    }

    void init_lcd()
    {
    delay(5);
    delay(5);
    delay(5);
    cmd_wr(0x22);
    delay(5);
    cmd_wr(0x22);
    delay(5);
    cmd_wr(0x22);
    delay(5);
    cmd_wr(0x33);
    delay(5);
    cmd_wr(0x20);
    delay(5);
    cmd_wr(0x28);
    delay(5);
    cmd_wr(0x0e);
    delay(5);
    /* cmd_wr(0x06);
    delay(5);*/
    cmd_wr(0x01);
    delay(5);
    }


    void cmd_wr(unsigned char ch)
    {
    P1OUT=0x00;
    P2OUT=(ch & 0xf0 | P2OUT & 0x0f);
    enable();
    P2OUT=(ch<<4 & 0xf0 | P2OUT & 0x0f);
    enable();
    }

    void delay(unsigned int i)
    {
    unsigned int cnt,j;

    for(cnt=0;cnt<=i;cnt++)
    {
    for(j=0;j<=10;j++);
    }


    }

    void data_wr(unsigned char dat)
    {
    P1OUT=0x40;
    P2OUT=(dat & 0xf0 | P2OUT & 0x0f);
    enable();
    P2OUT=(dat<<4 & 0xf0 | P2OUT & 0x0f);
    enable();
    }


    void enable()
    {
    P1OUT=0x10;
    _nop();
    _nop();
    _nop();
    _nop();
    // _nop();
    P1OUT=0x00;
    }

    Plz guide me if im making any mistake.

    Regards,

    Neha

  • NEHA SONAWDEKAR said:
    it never goes into the delay routine

    It may have been optimized away. You can a) turn optimization off in your IDE or b) declare your counting variable as volatile.

  • how much delay should i take....is my code right?
  • The minimum delay times are given in the datasheet of the HD44780 controller.
  • Hi Dennis Eichmann,

    I tried alot but there is no luck. only cursor blinks could not see data on lcd.

    I'm using JHD162A lcd.

    here is my code

    #include <msp430.h>
    #include <in430.h>
    //#include <math.h>
    /*
    * main.c
    */

    void init_lcd();
    void cmd_wr(unsigned char ch);
    void data_wr(unsigned char dat);
    void delay();
    void enable();

    void main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
    //P1DIR = 0x1c;
    //P2DIR = 0xF0;

    P1DIR |= BIT2+ BIT3+ BIT4;

    P2DIR |= BIT4+ BIT5+ BIT6+ BIT7;

    init_lcd();
    cmd_wr(0x85);
    delay();
    while(1)
    {

    // delay();
    //delay();
    //delay();
    data_wr('A');
    // delay();
    //delay();
    //delay();
    //delay();
    }
    //while(1);

    }

    void init_lcd()
    {
    delay();
    delay();
    delay();
    delay();
    delay();
    delay();
    delay();
    delay();
    delay();
    delay();
    delay();
    delay();
    delay();
    delay();
    delay();
    cmd_wr(0x22);
    delay();
    delay();
    delay();
    delay();
    delay();
    cmd_wr(0x22);
    delay();
    delay();
    delay();
    delay();
    cmd_wr(0x22);
    delay();
    delay();
    delay();
    delay();
    cmd_wr(0x33);
    delay();
    delay();
    delay();
    delay();
    cmd_wr(0x20);
    delay();
    delay();
    delay();
    delay();
    cmd_wr(0x28);
    delay();
    delay();
    delay();
    delay();
    cmd_wr(0x0e);
    delay();
    delay();
    delay();
    delay();
    /*cmd_wr(0x06);
    delay();
    delay();
    delay();
    delay();*/
    cmd_wr(0x01);
    delay();
    delay();
    delay();
    delay();

    }


    void cmd_wr(unsigned char ch)
    {
    P1OUT=0x00;
    P2OUT=(ch & 0xf0 | P2OUT & 0x0f);
    enable();
    P2OUT=(ch<<4 & 0xf0 | P2OUT & 0x0f);
    enable();
    }

    /*void delay(unsigned int i)
    {
    unsigned int cnt,j;

    for(cnt=0;cnt<=i;cnt++)
    {
    for(j=0;j<=10;j++);
    }


    }*/

    void delay()
    {
    for(;;)
    {
    volatile unsigned int Ms;
    Ms = 1000;
    do Ms--;
    while(Ms != 0);

    }

    }

    void data_wr(unsigned char dat)
    {
    P1OUT=0x04;
    P2OUT=(dat & 0xf0 | P2OUT & 0x0f);
    enable();
    P2OUT=(dat<<4 & 0xf0 | P2OUT & 0x0f);
    enable();
    }


    void enable()
    {
    P1OUT=0x10;
    _nop();
    _nop();
    _nop();
    _nop();
    // _nop();
    P1OUT=0x00;
    }

    plz guide me.

    Regards,

    Neha

  • Neha,

    The P1OUT = 0x04 inside data_wr is being overwritten by P1OUT = 0x10 from enable(), you should be using a bit set (|=) to avoid this. You need to be using an oscilloscope or logic analyzer to confirm that your data lines are being controlled as expected and follow the specifications from the JHD162A datasheet.

    Regards,
    Ryan
  • Hi Ryan,

    got the output....there was  a connection problem.

    R/W pin and enable was not connected properly.

    i also used bit set(|=) as suggested by you,to avoid overwriting.

     

    Thanks.

     

    Regards,

    Neha

**Attention** This is a public forum