TI msp430 with LCD screen

Discussion in 'Embedded Systems and Microcontrollers' started by crobertsbmw, Oct 2, 2011.

  1. crobertsbmw

    Thread Starter New Member

    Sep 7, 2011
    28
    0
    I have a TI MSP430x2274 that I am trying to interface with an LCD (http://shop.moderndevice.com/products/3-3v-16-x-2-blue-lcd-character-display). I have it all wired up, but I can't get anything to show up. I wonder just a little bit if they sent me a 5volt version and not the 3.3 volt version and I don't have high enough voltage for the contrast or something. Or maybe something is wrong with my code. The code is an adaptation of the sample code from newHaven Display. I compared the two data sheets and they seem to be exactly the same. Any other ideas why I might not be able to get anything written to this LCD?

    Here is my code:
    Code ( (Unknown Language)):
    1.  
    2.  
    3. //---------------------------------------------------------
    4. /*
    5. 8_bit_character.c
    6. Program for writing to character LCD
    7. */
    8. //---------------------------------------------------------
    9. //#include <lcdTest.h>
    10.  
    11. #include "msp430x22x4.h"
    12. #include "eZ430X.h"
    13. //---------------------------------------------------------
    14. //
    15. //#define E     P3_4;
    16. //#define D_I     P3_0;
    17. //#define R_W     P3_7;
    18. //******************************************************************************
    19.  
    20. char const text1[] = {"Test Program    "};
    21. char const text2[] = {"Character LCD   "};
    22.  
    23. void Delayms(int n){
    24.     int i;
    25.     int j;
    26.     for (i=0;i<n;i++)
    27.         for (j=0;j<1500;j++)
    28.         {;}
    29. }
    30.  
    31. void command(char i){
    32.     P1OUT = i;
    33.     P3OUT &= ~0x01;        //P3_0 =0;
    34.     P3OUT &= ~0x80;        //P3_7 =0;
    35.     P3OUT |= 0x40;        //e P3_6  = 1;
    36.     Delayms(1);
    37.     P3OUT &= ~0x40;        //P3_6  = 0;
    38. }
    39. void write(char i){
    40.     P1OUT = i;
    41.     P3OUT |= 0x01;        //P3_0 =1;
    42.     P3OUT &= ~0x80;        //P3_7 =0;
    43.     P3OUT |= 0x40;        //P3_6  = 1;
    44.     Delayms(1);
    45.     P3OUT &= ~0x40;        //P3_6  = 0;
    46. }
    47. void init(){
    48.    // P3OUT &= ~0x10;        //E = P3_4  = 0;
    49.     P3OUT &= ~0x40;     //E = P3.6 = 0;
    50.     Delayms(5);
    51.     command(0x30);
    52.     Delayms(100);
    53.     command(0x30);
    54.     Delayms(10);
    55.     command(0x30);
    56.     Delayms(10);
    57.     command(0x38);
    58.     command(0x10);
    59.     command(0x0c);
    60.     command(0x06);
    61. }
    62. void home(){
    63.     command(0x01);
    64.     Delayms(5);
    65. }
    66. void nextline(){
    67.     command(0xc0);
    68. }
    69. void disp_pic(){
    70.     int i;
    71.     home();
    72.     for (i=0;i<16;i++){
    73.         write(text1[i]);
    74.     }
    75.      nextline();
    76.      for (i=0;i<16;i++){
    77.         write(text2[i]);
    78.     }
    79. }
    80.  
    81.  
    82. void main(void) {
    83.     WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
    84.     P1DIR = 0xFF; //set p1.0-p1.7 as output
    85.     P3DIR |= 0xC1; //set p1.0 p1.6 and p1.7 as output
    86.     P1OUT = 0x00;
    87.     P3OUT = 0x00;
    88.     while(1){
    89.         init();
    90.         disp_pic();
    91.         Delayms(1000);
    92.     }
    93. }
    94.  
    95. [/i][/i]
     
    Last edited by a moderator: Dec 19, 2011
  2. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    The datasheet says it's 5 volts. Did you contact their customer support?

    While I can interface to my HD44780 compatible LCD displays with 3.3v signals from my Launchpad, I still have to power the displays from 5 volts.

    Some people suggest you may be able to power these 5v displays from 3.3v but you may have to come up with a negative voltage for the contrast adjustment.

    Cheerful regards, Mike
     
  3. crobertsbmw

    Thread Starter New Member

    Sep 7, 2011
    28
    0
    I bought the 3.3 volt version, and it just shares the same datasheet as the 5volt version. But I am still a little baffled. I wonder if they sent me the wrong one...
     
  4. jazz_saigon

    New Member

    Dec 19, 2011
    2
    0
    it depends how you hooked up the lcd, if using 6 pin or 12 pin mode, you have to check the busy flag of the display before writing any new data. as the msp430 runs on 16mhz this is much to fast for the display.
    A better solution is using a 2 wire interface and shift register 74hc164 as writing this way to the display is slow enough so that you not need to test the display's busy flag, and it saves you plenty of mcu pins.
    The difference between a 5v lcd and a 3v lcd is only a resistor ! when you measure on pin 2(5v vdd) of the display it goes to a 4k7 resistor... simply solder a tiny wire over it and voila , your 5v display works now on 3v3 (of course don't put 5v as power supply now !)
    don't forget google is your friend
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    Is the backlight working? Did you connect the contrast circuit?
     
Loading...