271
LCD using DIO Bit-Banging
Some MSP430 devices, especially the 14-pin parts have limited number of pins and so it is wise to use
port expanders like MCP23S17 or MAX7300, serial LCDs and shift register-based LCDs. Everything is
same here just as in the LCD example. The only exception is the method of handling the device
responsible for port-expansion task. In some cases, it may be necessary to use additional hardware
like UART/I2C/SPI or emulate these methods using software when such dedicated hardware is either
unavailable or used up for some other jobs. Thus, in such cases, things are no longer as simple as with
digital I/Os. In the software end, we will also need to code for the additional interface too.
Everything that has an advantage must also have a disadvantage. The primary disadvantages that we
are left with when using port-expanded LCDs are slower displays and vulnerability to EMI. Noise and
glitches are big issues when your device is working in a harsh industrial environment surrounded by
electromagnetics. Likewise, if the wires connecting the LCD pack with the host MCU are too long, it is
highly likely to fail or show garbage characters after some time. The simplest solution to these issues
are to use shorter connection wires, slower communication speed and frequent but periodic
reinitialization of the LCD pack. Again, all these lead to slow functioning. Thus, a careful system design
is an absolute must.
The most popular methods of driving alphanumeric LCDs with fewer wires include:
• SPI-based solutions using shift registers like 74HC595 and CD4094B
• I2C-based solutions using I2C port expander ICs like PCF8574 and MCP23S17.
We can use either hardware-based SPI/I2C modules or emulate these in software using bit-banging
methods. The former adds some much-needed processing speed which is impossible with bit-banging.
In this segment, we will see how to use a CD4094B CMOS shift-register with software SPI to drive an
alphanumeric LCD.