On Monday, October 12, 2020 at 6:36:35 AM UTC-4, Jim Jackson wrote:
> I've held off from following up, because I'm no expert, but I was hoping
> to learn some stuff. I have written LCD drivers - but just for myself.
> When controlling an LCD directly connected to the SBC, I've used
> checking the operation ocmpleted flag. But when using an I2C connected
> LCD I just used, conservative, timing. Not an option for you.
Not sure why you say this is not an option for me. That's exactly what I plan to do, use "conservative" timing.
> On 2020-10-10, Rick C <
gnuarm.del...@gmail.com> wrote:
> >
> > I working with an LCD display using this chip which is apparently
> > function compatible with the ubiquitous HD44780 LCD controller. The
> > initialization sequence is a set of commands because no one trusts the
> > internal power up reset.
>
> Maybe, but the device does need setting in 4/8bit mode.
If you are talking about relying on the power up reset, that sets the Function set register...
Initializing by Internal Reset Circuit
1. Display clear
2. Function set:
DL = 1; 8-bit interface data
N = 0; 1-line display
F = 0; 5 × 8 dot character font
3. Display on/off control:
D = 0; Display off
C = 0; Cursor off
B = 0; Blinking off
4. Entry mode set:
I/D = 1; Increment by 1
S = 0; No shift
The reason for performing a specific reset command sequence is because the device can not be relied on to reset itself unless the power up meets all the specs in the data sheet.
I'm doing the reset sequence to protect against glitches since the unit is not intended to be powered off. It has an internal battery backup.
> > Rather than an MCU this will be driven from
> > an FPGA with a repeating sequence, so I'd like to eliminate anything
> > that is not important in the commands. In particular the "magical
> > reset sequence" includes the Clear Display command which takes 1.52 ms
> > to complete while the other instructions mostly complete in 37 us
> > (give or take as I mention below).
>
> I'm guessing just setting the char address, and increment, and writing
> all the data in one go will be fine.
That's what I'm thinking, but not certain. Hard to tell from testing since that can't take into account the many variables.
> I seem to remember from last time I wrote 44780 code (a few years ago)
> that the more modern clone I had was faster than the standard 44780 - I
> certainly don't remember have timing problems when I developing the
> code.
The clocks may be faster, or they may be slower. The data sheets tend to echo the Hitachi data sheets, but testing with individual displays can't verify timing of your code. The design has to be based on the spec. I definitely see differences on the bus timing specifications, so those numbers need to be very conservative to be sure of meeting timing over a variety of suppliers.
> > I'm wondering if this command is strictly needed. It clears the
> > display data RAM, resets the data RAM pointer and resets some cursor
> > functions. I won't be using the cursor and I can manually reset the
> > data RAM pointer easily enough. The data is completely written on a
> > periodic basis, so clearing the memory is not useful. Does anyone
> > know if this command does anything else that might be important? Or
> > can I replace this command with one to simply set the display data RAM
> > address pointer without impacting the operation of the display?
> >
> > Does anyone know how many times the Function Set command needs to be
> > sent to be sure of starting the chip off right? The data sheet I have
> > shows twice for an 8 bit bus. I've seen people say three times for an
> > 8 bit bus and 4 times for a 4 bit bus.
>
> I only ever send it twice - but I use 8 bit mode. you might need
> 3 times in 4 bit mode.
The reset command sequence is about not knowing what mode the device is in. The best explanation of this I've seen is in the Wikipedia page for the controller although it explains the rational in a somewhat overly confusing manner. I proposed a more straightforward explanation in the talk page and will post it if there is no discussion in a week or so.
https://en.wikipedia.org/wiki/Talk:Hitachi_HD44780_LCD_controller
Bottom line is that if the controller is left in a state expecting the second nybble of a split transfer it takes three transfers to put it in a known state and you need to give it another command if you don't want 8 bit transfers, 1 line, 5x8 characters. If you want 4-bit mode, you need to send one more 4 bit transfer to put it into 4 bit mode and then a proper pair of 4-bit transfers to set the various bits in the Function set register, so a total of 6 enable pulses, all spaced at 37 us (plus whatever derating you are using) other than the last pair which only need to meet the standard bus timing specs.
I've been hitting the data sheets hard on this one because the data sheets are not very clear. The issue I'm concerned about is that there are details the Reset command does that are not fully documented, but it's not like this is an overly complex device, so probably not. Then there is the issue of the reset command blanking the display and it taking a (relatively) long time to get characters in all 32 positions plus the defined CGRAM characters (another 64 transfers). Using the minimum instruction delay (all commands other than the reset and home commands) to define the wait time for the slow commands only adds another 25 cycles to the ~100 I will be sending anyway. But I'm worried about the display dimming for the later characters that have been cleared and then take a while before being refreshed. I want to refresh the whole display on a rapid basis to allow blinking and quick response. We have a thermometer graph that is updated in real time, so at least 10x per second and >30 Hz would be better. At 100 Hz the refresh time of ~8 ms would certainly be noticed and even at 30 ms refresh interval I think it might be noticed.
So I'm thinking of leaving out the Reset command because of that. Then the characters are overwritten without being blanked and no dimming. Should work.
--
Rick C.
-+ Get 1,000 miles of free Supercharging
-+ Tesla referral code -
https://ts.la/richard11209