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

CFAH1602Y-YYH-ET Manual Redundancy?

ayergo

New member
In the manual in section 14, page 18 of the manual for the device it lists the beginning of initialization for the device as follows
Function Set 1 (this initializes it to 4-bit mode)
Function Set 2 (same function number, but now set line numbers and font)
Function Set 3 (same as above)

The first two Function Set calls make sense, as the latter N and F bits are ignored when first entering into 4-bit mode. The third call to Function Set though seems to have no purpose that i could see.

I've tried doing it with the call duplicated and not, it seems to function fine in both respects.

My question is "What is the purpose of the 3d call to Function Set and is this redundant call necessary?"

Thanks much
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 
The original HD44780 lcd controller recommended that the Function Set be done 3 times from a cold start, to assure that the controller recovered from any previous condition. I assume the HD44780 compatible controllers keep the same init sequence so that they are backward compatible with old software.

If you want to skip the 3rd Function Set, that's up to you. It could save you a few hundred microseconds :rolleyes:.
 

ayergo

New member
The original HD44780 lcd controller recommended that the Function Set be done 3 times from a cold start, to assure that the controller recovered from any previous condition. I assume the HD44780 compatible controllers keep the same init sequence so that they are backward compatible with old software.

If you want to skip the 3rd Function Set, that's up to you. It could save you a few hundred microseconds :rolleyes:.
Its not really the time that concerns me, but proper operation of the device. I still don't understand why it would require it would need to be done 3 times. I definitely understand the need for backwards compatibility, however it still leaves questions, like "Does it mean that other instructions need to be done 3 times as well?"
 

ayergo

New member
Hi Cosmicvoid,

Thanks so much for your replies. I've been digging more, and while i have more questions than answers, i think i'm on the right track.

I decided to take a look at the base Hitachi part, have a look at the datasheet page 42 here:

http://www.sparkfun.com/datasheets/LCD/HD44780.pdf

Now compare the first step to the Crystalfontz version page 18 here:

http://www.crystalfontz.com/products/1602y/datasheets/132/CFAH1602YYYHET.pdf

It would appear i mis-spoke in my first post, i didn't actually check what the bits were doing. It would appear that in the Crystalfontz version they set the controller to 8-bit mode then try to set it back to 4-bit mode.

The Hitachi flavor of startup just does 2 4-bit setup codes (as opposed to the 3 of crystalfontz). I haven't been able to get either properly working yet, though haven't ruled out some wiring issues. I started with the crystalfontz flavor, but noticed that when i did a single character write it would take the first nibble and append 0xFF to the end for the display. It looked like it was operating in 8-bit mode as far as i could tell.

I'm still digging, and will be out until monday but would greatly appreciate if you and/or someone from crystalfontz could have a peek at this discrepancy.
 
The Hitachi flavor of startup just does 2 4-bit setup codes (as opposed to the 3 of crystalfontz).
If you look at page 46 of the Hitachi data sheet, you can see that their sequence does the function set nibble 5 times, 4 as a single nibble, then again as a 2-nibble pair. I can not explain why they do this, except maybe its because the busy flag is not testable for the first few writes, so the delays between the nibbles is to make sure the controller is not busy. I'm just guessing.

I looked at some code that I did a while back, using a USB I/O module, using 4 bit mode, and it has the 5 repetitions of the function set nibble
Code:
	USBm_StrobeWrite(0, 0x30, 0, 0x12);		// generic init nibble
	Sleep(5);
	USBm_StrobeWrite(0, 0x30, 0, 0x12);
	Sleep(1);
	USBm_StrobeWrite(0, 0x30, 0, 0x12);
	USBm_StrobeWrite(0, 0x20, 0, 0x12);		// set 4 bit I/F
	Write2Nibbles(CMD, 0x28);		// set 4 bit, 2 lines
	Write2Nibbles(CMD, 0x08);		// display off
	Write2Nibbles(CMD, 0x01);		// clear screen
	Sleep(1);
	Write2Nibbles(CMD, 0x06);		// cursor increment
	Write2Nibbles(CMD, 0x0C);		// display on, no cursor
and that works, so I would recommend you just do it, and don't ask why.
You haven't given enough info to diagnose your character write discrepancy. If you want more help, you should post some of your code.
 

CF Tech

Administrator
Here is the init routine we use on some of our LCDs:

Code:
//============================================================================
void LCD_Initialize(void)
  {
  ubyte
    i;
  ubyte
    j;

  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);
  //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 the display shows "{{{{{" in a couple of places.
  Write_LCD_Control(0x01);
  }
//============================================================================
The "blind" write functions do not check for busy. All others do check for busy, and are 4-bit mode (two writes, one for each nibble).
 

ayergo

New member
Took me an extra write of the function set. Not sure why but finally got it all sorted out. Wrote a kernel module for it. I'm not the prince of code or anything but i posted it up on the third party software forum. Hopefully helpful to someone.

Thanks for your help here!
 
Top