Last week I posted some AVR gotchas, but now it’s time for an LCD gotcha!
<rue_shop2> Landon, for over 6 years, everyone who gets a hd447880 screen has written their own library
Yep, that’s what I did. I wrote some LCD helpers in assembly for this project. The big problem I encountered was my strings were getting truncated when I read them from the EEPROM and displayed them on the LCD. After verifying my EEPROM code was correct, I turned to my LCD code. I had just switched to waiting on the Busy Flag of the LCD instead of a max delay.
Assuming all of my ports are set up correctly (PortD6 is the Enable line of the LCD)
Ok, you might not see the problem yet. Let me give you some more information. I was also working in 4 bit mode. Look again.
The gotcha is that with 4 bit, reads need to be done twice, otherwise you’ll be reading part of the current address next time you strobe the Enable line. Duh! This wasn’t apparent in the article I was using though, because 4 bit mode was almost an afterthought in the microcontroller implementation and there was no way you would be punching buttons fast enough by hand to need to wait on the Busy Flag.
Corrected code: