Got a test program on Arduino displaying the text lines I want on the LCD, this with the Wire library which uses the builtin I2C pins on the AVR. Wrote the equivalent program in the 8051 code and program the EEPROM. No joy, display doesn't even initialise.
Ok, need to backtrack a bit. Tried using my bit-banging routines on the Arduino. No joy either.
Some searching found the SoftwareWire library which works on any two pins instead of just A0 and A1, the normal I2C pins. I modified my test program to use this, but got garbage printed out. At the right intervals though. At least the initialisation seems to be working.
Oh well, have retrace my steps and break this down to smaller steps until I find the missing piece. I hate it when hardware decides to be picky like this.
Ok, I found the problem. The 1602 is fussy about letting it complete certain actions, like clear and home, by waiting the period specified in the datasheet. When sufficient delay was added, I could get the correct text later. But there is a potential issue with insertng delays, which I will discuss in a later log.
Now, moving back to using my bit-banging routines, this still failed, until I noticed by reading the code for SoftwareWire that where the specification specifies the slave address, say ADDR, what actually is sent over the wire is ADDR*2 for writes and ADDR*2+1 for reads. That explains why some slave addresses were odd, and of course why they only go up to 127. I was under the mistaken impression that the write and read addresses were ADDR and ADDR+1 respectively. So I won't forget this detail of the protocol.
Fixed the code and programmed the EEPROM for the 8051. That works too.
Now to get the increment and decrement buttons working in conjunction with the display.