Graphical LCD controller for ST8024+ST8016
based displays
A few months ago I bought "cheap" LCD PG320240WRM-HNNIS3.
Viewing area is about 80x60mm, so pixels are very small (0.22mm)
and therefore this LCD is able to display simple error difusion images too.
LCD has LED backlight and also the DC-DC voltage converter
so there is no need for external 20V as it's described in datasheet
(for contrast correction). Pin numbers and their functions
Pin 1 is marked on the board.
LCD module comunication
CL1 and CL2 are sensitive on the falling edge (negative pulses).
When the LCD is not clocked by CL1/CL2, D-OFF have to be in log.0 otherwise
the liquid crystals are DC driven and this can dammage LCD!
When the FLM pin is log.1 then CL1 negative pulse resets vertical counter to the first line
(frame sync.). Pin M is some driver signal for the "glass" timing. It should be
200-400Hz. Some M frequencies can interferate with refresh rate, so
you have to set it experimentaly. My experimatal AVR based controller
Because one image is 9600B big external SRAM in needed.
The smallest AVR with XRAM interface is ATmega64 (or ATmega128 in the same package).
It's not possible to drive CL2 pin by SW loop beacause it's very slow. So the CL2
signal is taken directly from RAM RD pin. The second very slow operations is
selecting low/high nibble from the byte for 4-bit LCD data lines so there is
external multiplexer connected directly to the XRAM data port.
It's controlled by XMEM interface A0 pin and 32kB
SRAM is connected on A1-A15 pins. It means that the LSB of XMEM address selects
low/high nibble for the LCD.
With theese two HW updates the AVR is capable
to send 2,66MB/s to the LCD at 16MHz (with no wait cycles for the external RAM).
It means 5,33M LCD words per second.
Because MCU is not as busy as I thought first time I added touchscreen controler through the ADC
pins. You can read directly ADC values in X,Y or values corrected to the 320x240 resolution by
calibration values which you have to send into it. There is also implemented
digital filtering for the touchscreen with some options. You can also setup
contrast, M frequency, switching one of 3 image buffers (usefull for double buffering),
setting address in actual image buffer and some others.
Table with instructions and fuse settings are in the sources.
Connection to the LCD is via MLW16 connector because I haven't found the right one.
LCD pin numbers corresponding with MLW16 pin nubers.
Touchscreen is connected via MLW06 and unfurtunately there is no marking
so you have to connect 4 lines experimentaly (use ohmmeter to find the right ones).
Demonstration code and connection
This simple application sends a few texts on the LCD in some variation Arial 10pt font and it reads the touchscreen values. If you press TS the corresponding coordinates are displayed. This MCU has only 2kB RAM - it's not possible to draw some complicated graphics.
In the code you can find some bin/BCD conversion routines,
string write from the FLASH, BCD without leading zeroes write routines and some others.
There are the most important comunication routines for the LCD.
each line is generated with verticaly organized bytes because it's
much more faster with proportional texts. After the line is completed
some routine transforms it to the horizontal organized bytes.
Then the image is send on LCD.
Because of only 2kB RAM it takes some time to redraw entire image
there is simple double buffering.
Last update: 16.12.2006 |