Hello,
I have hooked alphanumerical LCDs on some uCs in the past and I have always had to adjust the software to the actually installed module. I have a small collection of "compatible" displays with 1 to 4 lines and 8 to 40 char/line so the software could become messy.
In applications or situations where the LCD model is not pre-determined (like, a customer intends to upgrade to another resolution in the future or you don't know if the particular reference will be available later), I have wondered what would make LCD-handling interfaces more flexible.
One solution is to add jumpers, or pads, or things like that, on the PCB. This is not really practical because when changing the module, the jumpers or pads must also be updated, which is error-inducing. This also wastes precious pins...
I know that some recent LCD controlers have advanced features but most of what I find today is cheap, standard, even old modules so I rule out advanced protocols.
A particularly simple solution that I have just found is to solder some SMD resistors (>100K) on the data bus, either to ground or Vdd. These pull-ups or pull-downs provide a few bits that the host CPU or uC can read when it does not drive the bus itself. So there is no additional pin to reserve.
HD44780 displays are also often used in "reduced wiring" : Write enable is tied to write and only 4 data bits are used. This is compatible with the pull-up/down system, because in this situation the LCD module never drives the data bus.
I remember that there may be other pull-up/downs, maybe on the LCD side, but I can't be sure now, it could vary with the manufacturer or model... Anyway, the resistors are mounted on the module and not the host PCB so the value (could be 10K or less if needed) can be adjusted without affecting the host board.
So we have 4 bits : I guess that the encoded values on the data bus can be very easy :
bits 4 & 5 : number of char/line : 0 0 8 1 0 16 0 1 20 1 1 40 ?
bits 6 & 7 : number of lines 0 0 1 1 0 2 0 1 4 1 1 error ?
So during power-up, the host CPU/uC can hold the data bus in HiZ, read the 4 bits of data and determine the dimensions. The handling routines are then updated with correct values (start addresses etc.).
More bits could be read by feeding the pull-ups with the backlight's power, for example (don't forget the diodes to prevent messing with the values) or simply with the lower nibble. But it is more important to know whether the module has the pull-up/down resistors, so the dimensions could fall back to 1x8 for example. If most modules have pull-ups, then we could encode the dimensions in reverse order so
1111 means 1x8, and then there are only pull-downs to wire...What do the readers think about this ? Is there something similar in the wild ? Is it worth it to modify my modules to implement this method ? Am I going to get annoying side effects ? (like different addresses with different makers of modules)
YG