Well, I wanted to integrate a touch screen in a project that used a 8-bit PIC and nothing else was more resource friendly to use, other than a 128x64 graphics LCD with a resistive touchscreen overlay.
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. Manufacturer datasheet and various application notes also provides comprehensive interfacing algorithms which gives a quick start. Moreover, it's the favorite child of the open source community which means enormous online support without the need of any licensing worries.
A graphics LCD (GLCD) does not have an 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 primary reason to use GLCD. If you just want to display alphanumeric characters, a 16x2 or a 16x4 LCD is a better choice.
I bought a 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 poorly written and technically insufficient - and I realized this after getting one. When I developed the code referring the provided timing diagram, GLCD just didn't respond. It took better part of my time to fully iron out all the assumptions that I had made due to lack of relevant information in the datasheet and optimize the firmware, before the GLCD gleamed with a Hello World!
I would like to document the architecture here for my own ready reference, and for anyone who would like to have a quick start.
A 128X64 GLCD has 128 columns and 64 rows:
(0x00 to 0x3F)
.(0x00 to 0x07)
.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.
The pin layout is comparable to the 16x2 LCD module. Let me quickly go through pin functionality:
To control the page, line and cursor positions, we need to send instruction bytes over the data bus. The module needs to be told that it is an instruction as opposed to a data byte by pulling RS (D/I) (pin 6) low.
Line number (row selection): There are 8 lines (rows) and any of them can be selected by setting the L2, L1 & L0 bits in this instruction byte:
|1|0|1|1|1|L2|L1|L0|
Cursor location (column selection): Once the row is set, any of the 64 columns within that row can be selected by setting the C5 through C0 bits of the following instruction byte:
|0|1|C5|C4|C3|C2|C1|C0|
Ok, now with the details aside, this is what needs to be done to start writing to the GLCD:
(0xB8|L)
; where L ∈ [0, 8]
. (0x40|C)
; where C ∈ [0, 63]
. Here is the full set of instruction set from manufacturer:
References & Further Reading:
Related but unrelated: