Recently I managed to get my hands on a LCD3310 module by Olimex. It consists of a LCD display together with a PCD8544 driver chip. After reading up on the PCD8544 and examining some of the example code that’s floating around out there, I finally managed to get it working with an msp430 and now I have assembled a pretty complete driver for this combo.
There were a few problems to overcome however. There seem to be two different versions of the PCD8544 floating around; one that is happily running at 84×48, and one that seems to be more recent that comes with a much bigger display buffer with the top left 84×48 mapped to the display. This more recent version also seems to offset the display by 5 pixels, making the bottom row 3 pixels high and the top pixels unusable. To overcome this problem if you have it on your display, add -DPCD8544_FIX_YALIGN to the compiler options and you should be good.
This driver currently implements software SPI. Support for hardware SPI on the controllers that support it is on its in the works.
Connecting the display
Olimex designed the UEXT connection, which is now open for anybody to use in their designs. Making an adapter to connect the display via UEXT to the msp430 is just about connecting a 10P IDC connector to two rows of five pin headers (or maybe even stackable pin headers). If you got another connection to your display, just make sure to hook up the lines accordingly.
Currently the pin mappings are hardcoded in the driver, but this will probably change eventually. However, for now it expects the following pins to be connected from the UEXT connector (or display) to the msp430:
- D/_C on P2.0 (to SDA)
- SDIN on P2.1 (to MOSI)
- SCE on P2.2 (to SSEL)
- SCK on P2.3 (to SCK)
- RES on P2.4 (to SCL)
The display is updated 8 pixel rows at a time and the communication is done over SPI with the addition of a D/C pin for data/command selection and a RES pin to reset the controller.
The PCD8544 can use two adressing modes, horizontal and vertical. In horizontal mode, the next data byte will be inserted to the right of the current byte and wrap at the end of the line, while in vertical mode the next data byte would be inserted below the current byte, and it would wrap to the next column at the bottom of the display.
The driver however currently only operates in horizontal mode but this should be enough for most applications.
The display is initialized by a call to lcd_init(). From this point on you can use the lcd_cursor(row,col) method to position the insert position on the display. The lcd_draw_text(text,x,y) and lcd_draw_text_block(text,x,y,invert,width) methods can then be used to draw text to the display. In order to draw graphics or icons, you can either use lcd_draw_glyph(glyph,x,y) and lcd_tile_glyph(glyph,x,y,width) to draw from a predefined buffer or you can go hardcore with the lcd_write_byte(byte) method.
The main.c file contains working example code demonstrating how to build a simple menu like in the picture at the top of this post.
When the define PCD8544_FIX_YALIGN is set, virtual wrapping will be performed on all drawing operations to ensure that the data you write to the display shows up where it was intended to be.
The full documentation as well as the latest source code is available in the GitHub repository. It can be used standalone by including pcd8544.c and the header files in your project, and it is licensed under GNU GPL version 3.
______ ____ __ _