??? 08/05/04 01:51 Read: times |
#75439 - RE: ° LCD (44780) works in only ASM not C! ° Responding to: ???'s previous message |
When things stop making sense, you've got to stop and work through the problem carefully.Too often we try all kinds of black magic to coax something into working only to find out the problem is elsewhere. A simulator helps here.
It's incredible how one device can cause such a waste of human effort! Them darn lcds! I too had heaps of problems when I first started using them and people still have problems. My problems stemmed from not reading the datasheet - just because you don't understand a requirement won't let you off the hook! Firstly the timing when talking to these devices is critical - these lcds are slow by today's standards. Setup, hold times and minumum pulse widths must be obeyed. Setup times are the time the data must be stable before doing something: outputing the data before asserting E, hold times are the time the data must be held after something has happened, pulse width is the minumum on or off time. The signal E has a minumum width of around 1uS (I'm guessing here as I don't have the data handy), therefore your code must ensure that timing is adhered to - for a 12clock 8051 at 11.0592MHz, just setting and clearing the bit will meet that requirement, if you have a 6 clock or faster micro, that won't. Therefore you have to put in NOP() or just repeat the instruction: E=1; E=1; //keep E high for two cycles E=0; There's plenty of examples for lcd code that 'works' but if your particular situation is different to the one the author had, well it may not work. If you can tell us what cpu and frequency you are using, then we can better give suggestions. I'm using a Philips LPC2129 micro at the moment running at 60MHz - you really have to be aware of the timing in this instance! |