12864B V2.0 LCD module

It’s 128×64 monochrome pixels, with a backlight, and can display graphics and ASCII text. It can also display Chinese, Japanese, Korean, characters using built-in fonts, but I didn’t investigate those facilities.

Using the built-in ASCII font, the text resolution is fairly low – four rows with sixteen characters per row. The graphics can be switched off, or displayed at the same time as text. Of course, you can just clear the text display for graphics only.

In parallel mode, the interface is a four or eight bit data bus, with three extra control I/O needed, so you need either seven or eleven GPIO lines from your microcontroller. The display can also be driven using two SPI lines, MOSI and SCLK (plus one chip select if you also connect other SPI devices). However, in SPI (serial interface) mode the display is write only – which makes graphics programming more difficult unless your microcontroller has plenty of spare RAM to hold a graphics buffer.

LCD module pin number: nameArduino pin
1: GNDGND
2: VCCVCC
3: VON/C (no connection)
4: RSD10
5: R/WD11
6: ED12
7 – 14: DB0 -DB7D2 – D9
15: PSBVCC
16: NCN/C (no connection)
17: RSTVCC
18: VOUTN/C (no connection)
19: BLAVCC via 470-ohm resistor *
20: BLKGND
Connections I used

* Note that without the external, current-limiting resistor on the BLA (back light anode, positive supply to backlight) pin, my LCD module only had a 30-ohm resistor (R10) fitted onboard. So without the external limiting resistor, the backlight current would be excessively high. When using the LCD module with an STC microcontroller development board, where this pin is linked directly to the 5V VCC, I shall change the onboard R10 resistor to a higher value (470-ohm or 510-ohm).

The parallel mode allows the display’s RAM (graphic, character, and custom character) to be both written and read – which makes for relatively simple graphics programming, without tying up the microcontroller’s own RAM.

The module has enough RAM (both character display and graphics) to hold double the data that can actually be displayed at one time.

Scrolling the display is possible, but because of the strange layout of pixels, horizontal scrolling of ASCII text isn’t very useful. It’s probably designed for the larger Chinese characters (16 x 16 pixels) but with ASCII characters (8 x 16 pixels) row 0 of the display wraps onto row 2, and row 1 wraps onto row 3.

Vertical smooth scrolling is possible, but I chose to implement my ‘driver’ to give two separate screens: usually text and graphics are written to the not-currently-displayed half of the RAM, and then that can be switched into view. This allows double-buffered display for drawing graphics – when the display is blanked ready to draw the next ‘frame’ to the currently off-screen RAM buffer, so the user sees no display tearing or other artifacts during the redrawing process.

I wrote a sort of ‘driver’ in C – didn’t want to use C++ and put it in a normal Arduino library, because I plan to port the code to an STC microcontroller and use the Small Device C Compiler (SDCC) which is C only, not C++. For the Arduino just unzip the sketch as normal and when you open it in the IDE you’ll see two extra tabs – gd.h and gd.cpp, which hold the ‘driver’ (gd is short for ‘graphic driver)’. It’s worth looking at the .h one because it has some comments up near the top on how to make the connections. But you can ignore the code in the .h and .cpp files, and just concentrate on the relatively simple code in the usual .ino file if you want to make use of the ‘driver’ for your own purposes. There are only a handful of functions and all their names are prefixed with GD, so you won’t accidentally create functions with the same names in your own code. You can download the Arduino sketch using this link.

Here’s a link to download a copy of the driver datasheet https://ceptimus.co.uk/LCD12864BV2_0datasheet_driver.pdf


Posted

in

,

by

Tags:

Comments

6 responses to “12864B V2.0 LCD module”

  1. Ido G avatar

    Thank you for this post! I just wasted an evening trying to get such a display to work, believing it was based on the KS0108 chip… until by some lucky accident it started showing random Japanese characters, which the KS0108’s not supposed to have. Can you please direct me to the correct chip identity/datasheet?

      1. Ido G avatar

        So it’s an ST7920… excellent, thanks again!

  2. artps avatar

    Thanks for the information and explanation, Can I give an example to display the adc conversion value on the display?

    1. ceptimus avatar

      Do you mean you want to give an example? If so, please do. Or do you want me to give one?

      1. artps avatar

        oh sorry, i mean an example from you with the library used in your post. thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *