• We recently switched our forum platform. If you experience any issues please email support@crystalfontz.com

CFAH2004ATMIJP with msp430

blobbob

New member
hey guys,

I want to initialize the CFAH2004ATMIJP with a msp430.
Between both are two 74hct245(one for D7...D0, other for RS, R/-W, EN) as levelshifter from 3V3 to 5V.
I try to initialize by this routine:

LCD_EN_LOW;
LCD_RS_LOW;
LCD_RD_WRITE;

LCD_EN_ACTIV;
LCD_RS_ACTIV;
LCD_RD_ACTIV;
LCD_DATA_ACTIV;
delay(100);
LCD_DATA = 0x30;
delay(5);
LCD_DATA = 0x30;
delay(1);
LCD_DATA = 0x30;
delay(1);
LCD_DATA = 0x38;
delay(1);
LCD_DATA = 0x08;
delay(1);
LCD_DATA = 0x06;
delay(1);
LCD_DATA = 0x0c;
delay(1);
LCD_DATA = 0x01;

the delays are in ms.
but I always have the the 2 bars(first and third row) like an uninitialized display.
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

CF Tech

Administrator
Generally the problem is wiring. What is the voltage on Pin 3 (Vo) ?

I have this known-good 4-bit function, it seems to follow yours pretty close. It is based on the old "grandaddy" LCD controller:

http://www.crystalfontz.com/controllers/index.html?c=Hitachi+HD44780+Compatible

Code:
void LCD_Initialize(void)
  {
  SET_PORT1_FOR_LCD_WRITE;

  //This sequence is from the initialization on page 46 of the HD44780U
  //data sheet.
  delay_mS(40);
  Blind_Write_LCD_Upper_Control_Nibble(0x30);
  //Yes, the data sheet says write it twice.
  delay_mS(5);
  Blind_Write_LCD_Upper_Control_Nibble(0x30);
  //Yes, the data sheet says write it three times.
  delay_mS(1);
  Blind_Write_LCD_Upper_Control_Nibble(0x30);
  //Yes, the data sheet says write it four times, but at least this one counts.
  //020h is Function set:
  //4 bit,
  //2 line
  //F = (5x8)
  delay_mS(1);
  //This is last 8-bit write, which is an instruction to put the LCD into 4-bit mode.
  Blind_Write_LCD_Upper_Control_Nibble(0x20);
  //Here is the 4-bit instruction to set the font and number of lines.
  Write_LCD_Control(0x28);

  //"Display off"
  Write_LCD_Control(0x08);
  //"Display clear"
  Write_LCD_Control(0x01);
  //This delay is needed  for some Sitronix ST7066 controllers. No reasonable
  //explanation, I found it empirically.
  //delay_mS(2);
  //006h is Entry mode set, increment, no shift
  Write_LCD_Control(0x06);
  //Display on, cursor on, blinking
  Write_LCD_Control(Cursor_Style=0x0F);
  //Clear the display again. This seems to fix a power-up problem
  //where some displays sometimes show "{{{{{" in a couple of places.
  Write_LCD_Control(0x01);
  }
 

blobbob

New member
thank you for the code, I'll try it later today.
At Pin3 ( VO ) I have a variable voltage up to 5V.

update:
do you also have the functions in the code?
and how I have to initialize a 4 line display? with the 2 lines bit set?
 
Last edited:

blobbob

New member
ok now I have removed the lvlshifter, they are waste for this display :)
and I've found a complete code on mathar.com .
 
Top