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 2x16 on MSP430F2132

Other Parts Discussed in Thread: MSP430F2132

Hello!

I'm new in world of Microprocessor and I got some basic quations about programming them.

I try to write LCD driver (LCD 2x16) for MSP430F2132. I just want to do startup initilization and clear LCD. When LCD connected to Power Suply, dark block shown on it. When I load code in uC, there is small blink on LCD and nothing happend. LCD working on 4,5V, uC on 3,6V. LCD works fine on other uC like ARM...

Here is Code:

 

// Start Code//******************************************************************************
// LCD interface
//  
// RS     P3.4
// R/W  GND
// E        P3.6
// DB4  P3.0
// DB5  P3.1
// DB6  P3.2
// DB7  P3.3
//
//******************************************************************************



#include "msp430x21x2.h"


// Global Functions
void init_lcm(void);       // LCD Init
void clr_lcm(void);        // LCD  clear
void delay(int);              // Delay
void strobe(void);         // Enable


 void main()
  {
      int o;
      WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer  
   
   
           // LCD port
              P3DIR |= 0xFF;
              P3OUT &= 0x00;  
   
             for(o = 0; o < 0xEF; o++)delay(100);                   // Start Delay
   
             init_lcm();                                                                //  LCDInit
             clr_lcm();                                                                 // Clear the disp   

   
  }



// Functions
   

void init_lcm(void)
{
   
   
  // 4-bits comunication
  P3OUT = 0x00;            // Send instruction
  P3OUT |= 0x02;           //  4-bit
  strobe();
  delay(150);
   
   
  // 2 row working (0x28)
   
  //HN
  P3OUT = 0x00;        // Send instruction
  P3OUT |= 0x02;  
  strobe();
 
  //LN
  P3OUT = 0x00;        // Send instruction
  P3OUT |= 0x08;  
  strobe();
  delay(150);
 
  // Cursor (0x0F)
   
  //HN
  P3OUT = 0x00;        // Send instruction
  P3OUT |= 0x00;
  strobe();
 
  //LN
  P3OUT = 0x00;       // Send instruction
  P3OUT |= 0x0F;
  strobe();
  delay(150);
   
   
  // Clear LCD (0x01)
   
  //HN
  P3OUT = 0x00;        // Send instruction
  P3OUT |= 0x00;
  strobe();
   
  //LN
  P3OUT = 0x00;       // Send instruction
  P3OUT |= 0x01;
  strobe();
   
  delay(3000);        // Big Delay
  delay(3000);
   
  // Increment/entire shift (0x07)
   
  //HN
  P3OUT = 0x00;        // Send instruction 
  P3OUT |= 0x00;
  strobe();
   
  //LN
  P3OUT = 0x00;        // Send instruction
  P3OUT |= 0x07;
  strobe();
   
  delay(150);
   
}


void strobe(void)
{  // E-pulse
  P3OUT = P3OUT | 0x40;          // E -ON
  delay(200);
  P3OUT = P3OUT & 0xBF;       // E - OFF
  delay(200);
}


void clr_lcm(void)
{
 
  //HN
  P3OUT = 0x00;        // Send instruction
  P3OUT |= 0x00;
  strobe();
 
 
  //LN
  P3OUT = 0x00;        // Send instruction
  P3OUT |= 0x01;
  strobe();
   
}



void delay(int d)
{
  int i;
  for(i = 0; i <5*d; i++);

}

 

//End Code//*********************************************************************************************************

Thnx for anny help!

 

  • What are the voltage levels of the interface between the MSP430 and your LCD?  The MSP430 can only support a 3.3V interface.  If you LCD interface is operating at 4.5V, you will need to level translate the signals from 3.3V to 4.5V by an external device.

  • Brandon,

    He appears to be operating as output only to the LCD he shows r/w as ground in his comment.. In this case no level translators are needed because the output high of the msp will still be fine for the "5v" device.. I have done this on several projects and have had no  issues..

    I think his problem most likely is that the compiler he is using is optimizing out the delay loop. Most of the msp 430 compilers do a good job by default about removing "unnecessary" code.. The way he has delay defined, the compiler is free to throw it away..

     

     

     

  • Hi Mihakorosec,

    Did you get any success? Even I am trying to implement same application with same controller you used.Please let me know if you have some solution.

     

    Regards,

    Harshal

  • Yes, I found a solution. It was HW problem. LCD GND and uP GND didn't connected together:)

  • While you found a solution - the 4 bit initialization code posted here will "not" normally work for HD44780 (or similar) text lcd controllers.

    To force these controllers into 4 bit mode one must send the sequence: 3, 3, 3, 2, 2, 8, 0, 6, 0, e, 0, 1.   Without sending the first three "3's" (on Lcd pins DB4-DB7) this class of lcd controllers usually will not enter (nor remain) in stable/reliable 4 bit mode.  Lcd data sheets show relatively long (mS) delays during the first several 4 bit data transfers.

    As another states - we've run multiple text lcds with the 3V levels of modern micros - however 5V is normally required for Lcd power to insure adequate contrast.  (slight negative voltage introduced to the Vo pin may enable Lcd power voltage to be tied to the same 3V supply as used by the micro)

  • cb1 said:
    however 5V is normally required for Lcd power to insure adequate contrast.  (slight negative voltage introduced to the Vo pin may enable Lcd power voltage to be tied to the same 3V supply as used by the micro

    Alternatively, you can run the LCD from 5V (if available). In case of the MSP sending to the LCD, the MSP output level should be still high enough to be accepted (usually >2.4V for TTL 'high' is sufficient). If the LC is sending to MSP, 5V of course is too much, You'll have to limit the inrushing current into the MSP por tpins to <2mA. Which means a series resistance of >1kOhm will do ((5V-3V)/1k = 2mA).

**Attention** This is a public forum