My Wired World‎ > ‎

Interfacing 128x64 pixel graphics LCD with 8 bit PIC

March 2012, Microcontroller Design Lab

Well, I wanted to integrate a touch screen in a project and nothing was quicker to start with, than a resistive touchscreen overlay on a 128x64 graphics LCD - that is what I thought - Actually, it was a pain.

Before this, I had only worked with the conventional JHD402A controller based 16x2 line LCD modules - and those were pretty easy to work with; mainly because of the ease of sending desired data to be displayed. Moreover, the datasheet also provides comprehensive interfacing algorithms with the help of which, you can start straight forward.

But, a graphics LCD (GLCD) doesn't have inbuilt ASCII converter/generator; rather you can control state of a single pixel and hence its not easy to send data to it (well, that is the reason to use GLCD, if you just want to display characters, interface a 16x2 or a 16x4 LCD!!). I bought NT7108C controller based GLCD (which is quite similar to KS0108B module). Even though being a more complicated device than a 16x2 LCD, the datasheet that manufacturer provided along with the module was really crappy and technically insufficient - and I realized this after getting one (bad luck, eh!). The first time, when I referred the datasheet, I couldn't even understand the architecture properly. When I developed the code referring the timing diagram given, the GLCD just didn't respond. After a while, it started giving junk. Well, finally, it after lot of code optimization, I was finally able to get through and print the favorite phrase - Hello World!.

I would like to document all my efforts here on my webpage for (1) my own ready reference, and (2) for the reader who would like to save time experimenting with and adjusting the timing cycles.



Understanding the Architecture:

A 128X64 GLCD has 128 columns and 64 rows. Refer the figure below:

1. The 128 columns are divided into sets of two 64 columns; each controlled by independent NT7108C controller (yes - there are two NT7108C chips). The columns are addressed by Y address. Thus, for both the sets (both the controllers), Y varies from 0 to 63 (0x00 to 0x3F).
2. The 64 rows are divided into 8 pages of 8 rows (bits) each. Each page can be addressed by X address (or a page address) which varies from 0 to 7 (0x00 to 0x07).
3. Each page comprises of 8 bits x 128 columns (Y address) = 1024 pixels. A byte is a row of a page with its LSB (i.e. D0) on top and MSB (i.e. D7) at bottom. Writing digital '1' to a pixel, turns it on and darkens it. Thus, if you send 8 bit data, say 0xFF to (x,y) = (0,0), all the 8 pixels of 1st column of 1st page turns on.

To control the other half - the right side of the display, you need to activate the NT7108C controller of that section and repeat the procedure. There are hardware pins to select a specific controller and I'll discuss that in next section - the pin layout.



Pin Layout:


The pin layout is comparable to the 16x2 LCD module. Let me quickly go through pin functionality:

Pin 1 & 2: These are chip selection lines. A low on CS1 selects the NT7108C of right half of the screen and low on CS2 selects the other half. If you want to write simultaneously on  both the halves, you can select both. CAUTION: Refer your manufacturer datasheet to know exact active level of these pins.

Pin 3 & 4: These are power supply lines for the module. Works on +5VDC.

Pin 5: This is GLCD contrast control. Connect this pin to the viper of a 10kohm pot. One end of the pot goes to gnd and the other goes to pin 18 (Vee) of the GLCD.

Pin 6: RS (D/I) - This is data / instruction selection pin. A high on this pin indicates to the NT7108C that a data byte is being written and a low indicates that an instruction is being fed.

Pin 7: RW - Read/Write pin - A high on this pin enables reading from NT7108C and low enables writing to it.

Pin 8: E - Enable pin - A high on this pin enables the GLCD and a high to low transition latches the data (read or write). For exact timings of these, refer the datasheet of your module - although, I'll present a fully workable algorithm in later sections.

Pin 9 to 16: Data lines from LSB, D0 to MSB, D7.

Pin 17: RST - Reset line - A low on this resets the module. While working with GLCD, this must be held high.

Pin 18: Vee - Negative voltage output pin - refer description of pin 5, above.

Pin 19 & 20: These are back light LED lines. +5V with proper polarity on these lines lights up the back light. Although GLCD internally consists of a limiting resistor and you can directly feed in +5V to these lines, I would recommend to add a small resistor of 20 ohms in between. To control the back light, you need to give PWM signal via a switching transistor like BC846. I'll discuss this at length as later section.



Upcoming sections: I'll soon be adding following sections to this article:

Interfacing with the Microcontroller
Algorithm to Write to GLCD
Code Download



Further Help:

Quality Counter
Comments