Reading the LCD busy flag doesn't work

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've written a custom HD44780 driver for my alarm clock, which works fine using timing delays. However, I'm now trying to get it to work with the 'busy flag' as well. If I uncomment the IsBusy() call in the source code (see attachments) it keeps looping since it reads only 1's coming from the LCD.

Anyone have an idea what the problem could be?

Thanks in advance.

Attachment(s): 

Building my dreams!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In readbyte you need to read the data when E is high. Read the datasheet carefully in regards to setup time with RS and RW.
The sequence should be something like this:

Ddr to input
Select RS
RW to read
E high
Delay
Read port
E low

You also want a timeout on busy - the displays can sometimes lockup and you get caught waiting infinitely. I much prefer to use a delay.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried your suggestions but to no avail. I'm seriously contemplating removing the IsBusy() altogether. I've added the modified code in the attachments.

Attachment(s): 

Building my dreams!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not really fluent in C but it looks like you may be reading the PORT register instead of the PIN register.

Don

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

floresta1212 wrote:
I'm not really fluent in C but it looks like you may be reading the PORT register instead of the PIN register.

Don

That's correct but that should work just the same.

Building my dreams!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bigpilot wrote:
floresta1212 wrote:
I'm not really fluent in C but it looks like you may be reading the PORT register instead of the PIN register.

Don

That's correct but that should work just the same.

No because PORTx register will return the buffered output what you have written, the PINx register will return the actual state of input pins.

The other parts that write to the display use still completely wrong sequence. Like said before, RS and RW must be stable long enough before E is brought high, and they must be stable long enough after E is brought low. The data bus must also be stable long enough before falling E edge, and stable long enough after falling E edge.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Its always the same problems.........

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As written, you will never see the busy flag as set. The only time you are checking the busy flag is after calling SendByte(), but that has a delay in it that is long enough for the busy flag to go low before you ever call IsBusy().

Regards,
Steve A.

The Board helps those that help themselves.