I2C NewHaven LCD Display
I wanted to add a lot of features into this design and that means that I/O lines are scare. I decided to look around and find a serial LCD. These displays typically require only two control lines. Now usually serial LCDs are a lot more expensive than parallel LCDs because of the need for a extra processor on the display. So when I saw a NewHaven 2x16 serial display going for about $10 I thought this would be quite the deal. The model I chose was the NHD-C0216CiZ-FSW-FBW-3V3 NewHaven LCD. It uses an I2C bus which is ideal since this bus can support multiple devices and I was already planning on using it extensively throughout the design. This display is a 2 row by 16 character display and uses COG or chip-on-glass technology. I didn't know anything about COG other than I thought it involved chips on a glass substrate.
The display has a lot of connections but only three lines from the processor are required; The two I2C lines SCL, SDA, and a RESET line. The rest are either power, ground, a small capacitor and power for the back light (the two lines on the side of the display)
So far so good. The I2C code that I'm using is based closely on the sample code provided by MicroChip. I run the interface at 400KHz. I haven't tested any faster rates for now.
In the I2C interface, the two lines SCL and SDA are pulled high by pull-up resisters. During operation either the master (the microcontroller) or the slave (the display) pull the lines to low by sinking current. I didn't realize when I bought the display that, because of the COG construction, it has a limited ability to pull down the I2C lines. This required some judicious selection of pull-up resistors to get it to work. In my case 2K on each line worked.
Initializing the display is fine as long as you follow the sample code in the datasheet exactly. Based on comments in the NewHaven forum some of the sample programs provided by NewHaven don't work. I have no first hand experience.
I did run into one really annoying problem that causes me to not generally recommend this display. The I2C models are write-only devices. Although the datasheet seems to imply that you can read from the display's memory and registers, you can not. For me this is a big problem because we also cannot read the busy flag.
When you send an I2C command to the display it acknowledges receipt but it does not tell you when it's finished processing the command. If you send another command while the display's processor is busy, the display can lock up. After a few seconds it seems to reset (perhaps a watchdog timer). Normally querying the busy flag would solve this. You would wait until the flag was cleared before proceeding. But questions asked in the official forum have verified that nothing can be read from the device. This means that I have to resort to the crude method of implementing dead-reckoning waits between commands. Very ugly.
At least I only plan to use the display for a few setup menus and some simple status displays. Once the code is running well I might even remove the display completely.
You live, you learn.
Next Section: Wireless Communication via the mRF24J40MA