wierd problem with the CFAH2004A

As I think more about it, it just could be that your code has bugs. You dont really give any details of your functions. You should post the part of the code you use to set the cursor address.
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

gdx9902

New member
well, it's pretty straight forward, its just like a put char but the rs line is cleared

here it is:
Code:
void LCD_changedisplayaddr(unsigned char address)
  {
  RSclear(); // set A0 = 0
  RWclear();// set A1 = 0
  DelayUs(1); // wait for rs and rw to stabilize
  portd_set(address);// set port d to address
  DelayMs(1); // wait for data on port d to stabilize
  LCD_Strobe(); // strobe E signal for 1 Millisecond
  DelayMs(2); // wait more than 39 Us for it to latch, decode and excecute
  portd_clear(); // clear the port when done
  }
and as for my LCD_Strobe it's like this:
Code:
void LCD_Strobe(void)
  {
  Eset();  // set A2 to high
  DelayMs(1); // wait 1 millisecond
  Eclear(); // set A2 to low
  }
 
I'll look at your code more closely tomorrow.

One question: do you remove power from the LCD module before trying to re-initialize it (with 0x38)? If not, do that.

The data sheet says that the number of lines and font can not be changed after the init is first performed, so you'd have to power down and back up before doing a 2nd init sequence with a different line/font bitcode. The logic power draw is low enough that you could probably power the Vdd pin from a port pin, so you could dynamically switch the controller off/on, since there is no other way to effect a reset.
 

gdx9902

New member
Thank you very much for helping me this far, Most people on the boards lose patience and just leave me hanging.

but to answer your question, yes, i always power off then power on again before initialization. the only way i initialize is in the beginning of my program, and after I see it doesnt work, i cut the power, wait a few seconds and then power it up again.

I've tried a new LCD_init function, and modeled it exactly like what is mentioned in the HD44780 datasheet, and i still get the same result. 0x30, good to go, but 0x38,0x34, and 0x3C, are rejected and do not initialize the LCD.

wierd huh?

anyways here's the new LCD_init function for comparison:
Code:
void LCD_init(void)
{// wait for power on

  char data = 0;
  DelayMs(40);

  RSclear();
  RWclear();
  DelayUs(1);
  Eset();
  data=0x30;
  portd_set(data);  // 1st function set
//  LCD_Strobe();
  DelayUs(2);
  Eclear();
  DelayMs(5);
  portd_clear();

  Eset();
  data=0x30;
  portd_set(data);  // 2nd function set
  DelayUs(2);
  Eclear();
//  LCD_Strobe();
  DelayUs(250);
  portd_clear();

  Eset();
  data=0x30;
  portd_set(data);  // 3rd function set
  DelayUs(2);
  Eclear();
//  LCD_Strobe();
  DelayUs(50);
  portd_clear();

  Eset();
  data=0x30;
  portd_set(data);  // 4th and final function set
  DelayUs(2);
  Eclear();
//  LCD_Strobe();
  DelayUs(50);
  portd_clear();
  
  Eset();
  data = 0x08;
  portd_set(data);  // turn off LCD
  DelayUs(2);
  Eclear();
//  LCD_Strobe();
  DelayUs(50);
  portd_clear();

  Eset();
  data = 0x01;
  portd_set(data); // LCD clearscreen
  DelayUs(2);
  Eclear();
//  LCD_Strobe();
  DelayMs(2);
  portd_clear();

  Eset();
  data=0x06;   // entry mode set
  portd_set(data);
  DelayUs(2);
  Eclear();
//  LCD_Strobe();
  DelayUs(50);
  portd_clear();

  Eset();
  data=0x0F;  // Turn on LCD w/ cursor and blinking
  portd_set(data);
  DelayUs(2);
  Eclear();
// LCD_Strobe();
  DelayUs(50);
  portd_clear();

  LCD_cursorreset();  // sends command 0x02
}
once again, thank you
 

gdx9902

New member
Actually I just had a thought, after all these tests, and it only works for 0x30, i'm begining to wonder if the internal circuit of the LCD may have been fried. as in the lower 4 bits of the function set ( after the latch) is burnt out, and any value I set with in the DDRAM latch, the signal is going else where and LCD function is being disrupted.

Just a thought
 

gdx9902

New member
Ok, please ignore the last post,
i just got the emulation board from Crystal Fontz, and plugged it in, and all four lines work no problem.


*sigh back to square one
 

gdx9902

New member
It's 1:30 AM, and I FEEL GREAT!!!
wooohoooo!!!

i finally found my problem.

it turns out that i needed to initialize the first three times of the LCD with 0x30.

it doesnt like it if the last four bits are high in any order.

so with my new init code, i had it at 0x30, and for the last changed it to 0x38. The data sheet mentions that you should initialize with 0011**** <--- i thought the stars mean dont care, but it really does care.

oh man i feel like a weights been lifted. Thank you Cosmic very much for your help in all this. Thank you.

Cheers,

gdx9902
 
Good work.

I've never had a HD44780 type controller be so fussy. My code has always used four 0x38s, and its always worked OK. Even the Win Test code agrees with that.

I'm curious how you got an emulation board from CFA at 11PM. Do you live in Spokane or Adelaide ;) ?
 

gdx9902

New member
actually, I got my friend to drop it off,

He's working on another project, and borrowed my emulator board. so i got it back pretty late last night.

but back to the hd44780, yeah, I had no idea it was going to be so fussy, and to top it off, this is my first sortie into the lcd world. whew I'm just glad i got it to work
 
Top