SPI Control of Newhaven Graphic Display

This page is about implementing SPI control of a Newhaven Display International COG (Chip-On-Glass) LCD display module with a Microchip Technology PIC32.



COG (Chip-On-Glass) displays are monochromatic passive or active matrix LCD displays that can display information as text or in a dot matrix pattern. Unlike typical LCD displays, COG displays don’t have a built-in PCB board and instead have the IC directly mounted on the glass of the display. This type of technology is perfect for less demanding applications since they require less power than VFDs, are smaller in size and are typically less expensive than other display technologies (additional information available here ).

The Microchip PIC32 used in this example easily drives the display via its’ SPI peripheral. Components of Microchip SPI example software is reused where possible. Aside from SPI initialization and several delay routines that rely on PIC32 specific capabilities, this code could be used as a reference and ported, with modifications, to any of the Microchip PIC families that include an SPI peripheral.


The application example mates a PIC32MX795F512L with a Newhaven 128 X 64 pixel COG LCD display. The embedded software implements a SPI communications protocol to control the LCD and display a message, “DIGI-KEY + NEWHAVEN”.

The Newhaven displays listed in Tables 1 and 2 utilize the same version of built-in controller, ST7565 (ST7565.pdf) and in a couple of instances a functionally equivalent controller SPLC501 (SPLC501.pdf). The communications interface can vary depending upon the P/N with serial only, or the ability to select parallel or serial communication by setting the logic state of an external pin. The demonstration source code and accompanying program file can be used without modification to drive the COG LCD displays listed in Table 1, all 128x64 resolution. The displays in Table 2 have 128x32 or 128x65 pixel resolution, and can be successfully driven with minor changes to the embedded source code.

Part Number Description
NHD-C12864WC-FSW-FBW-3V3 gray pixel, white bckgnd, white LED, P/S
NHD-C12864WC-FSW-FBW-3V3-M black pixel, white bckgnd, white LED, P/S
NHD-C12864M1R-FSW-FTW-3V6 black pixel, gray bckgnd, white LED, P/S
NHD-C12864CR-FSW-GBW blue pixel, gray bckgnd, white LED, P/S
NHD-C12864LZ-FSW-FBW-3V3 black pixel, gray bckgnd, white LED, P/S
NHD-C12864WO-B1TFH#-M black pixel, white bckgnd, white LED,P/S
NHD-C12864WO-B1TGH#-M blue pixel, gray bckgnd, white LED, P/S
NHD-C12864WO-B1TMI#-M white pixel, blue bckgnd, white LED, P/S
NHD-C12864WO-B1TTI#-M white pixel, black bckgnd, white LED, P/S
NHD-C12864A1Z-FS(RGB)-FBW-HT1 black pixel, RGB bckgnd, RGB LED, Ser. only
NHD-C12864A1Z-FSW-FBW-HTT black pixel, white bckgnd, white LED, Ser. only
NHD-C12864A1Z-FSR-FBW-HTT black pixel, red bckgnd, red LED, Ser. only
NHD-C12864A1Z-FSB-FBW-HTT black pixel, blue bckgnd, blue LED, Ser. only

Table 1.

Part Number Description
NHD-C12865AR-FSW-GBW blue pixel, gray bckgnd, white LED, P/S, SPLC501C
NHD-C12865BR-FSW-GBW blue pixel, gray bckgnd, white LED, P/S, SPLC501C
NHD-C12832A1Z-FS(RGB)-FBW-3V black pixel, RGB bckgnd, RGB LED, Serial only
NHD-C12832A1Z-FSW-FBW-3V3 black pixel, white bckgnd, white LED, Serial only
NHD-C12832A1Z-NSW-BBW-3V3 white pixel, blue bckgnd, white LED, Serial only
NHD-C12832A1Z-FSR-FBW-3V3 black pixel, red bckgnd, red LED, Serial only
NHD-C12832A1Z-FSB-FBW-3V3 black pixel, blue bckgnd, blue LED, Serial only

Table 2.

Hardware Requirements

In this demonstration a PIC32 USB Starter Kit II, PIC32 I/O Expansion Board, prototype PICtail™ plus daughter board, Newhaven COG display, and the NHD-FFC30 FFC connector adapter board are used as an off-the-shelf alternative to a custom PCB for control and communication of the COG LCD (figure 1). The PIC32 USB starter has an integrated debugger, only a USB cable is needed. Flying lead connections are required from the PICtail Plus Daughter board and the NHD-FFC30 FFC adapter board, and to electrically connect the FFC on-board capacitor pads.

PIC32 USB Starter Kit II, DM320003-2-ND, PIC32MX795F512L.

Newhaven COG LCD, 128x64, NHD-C12864WC-FSW-FBW-3V3-M.

PIC32 I/O Expansion Board, DM320002-ND.

Prototype PICtail™ Plus Daughter Board, AC164126-ND.

Newhaven PCB Adapter Board, NHD-FFC30-ND. This is an unpopulated PCB and requires the installation of capacitors to meet the design requirements documented in the COG LCD data sheet.

Figure 1.

The power requirements of this board assemblage are relatively low and can be powered through a USB cable from a PC, the very same USB cable used for power and debugging the PIC32 software.

Interface Connections

The Prototype PICtail Plus board and the FFC Adapter board provide thru-hole pads with a 0.100” pitch. Soldering the individual interface wires between the Prototype PICtail Plus board and the FFC Adapter board is an option, as is installing dual and single row headers to facilitate wiring.

The dual row thru-hole pads on the FFC Adapter Board have a one-to-one relationship to the FFC connector (figure 2), i.e. FFC pin 1 has continuity to thru-hole pad 1.

Figure 2.

Follow table 3 for wiring connections from the Prototype PICtail Plus board to the FFC adapter board thru-hole (TH) pads.

PICtail Plus pad FFC Adapter Board, thru-hole pad
RA6 (GP I/O) 2 (/RES)
RB11 (GP I/O) 1 (CS1B)
RB12 (GP I/O) 3 (A0)
RB13 (GP I/O) 4 (RD, /WR)
RB14 (GP I/O) 5 (E, /RD)
RG6 (SCK2) 12 (SCL (DB6))
RG8 (SDO2) 13 (SDI (DB7))
GND 14, 21
3V3 22

Table 3.

The FFC adapter board provides unpopulated pads for installing the required decoupling and DC boost capacitors detailed in the COG LCD data sheet (page 4 of datasheet). 3V3 power and GND connections to the capacitors can be made from the Prototype PICtail Plus board.

Terminal FFC Adapter Board, thru-hole pad
TB1 23
TB2 24
TB3 25
TB4 26
TB5 27
TB6 No Connection
TB7 15
TB11 No Connection
TB12 14 or 21 (GND)
TB16 14 or 21 (GND)

Table 4.


The demonstration software is written in ‘C’, and makes use of Microchip’s PIC32MX Peripheral Library for SPI configuration and write functions. Peripheral function and macro descriptions can be found in the XC32 Peripheral Libraries documentation. One method to access this information is through the MPLAB X IDE help feature. Navigate to MPLAB X help menu and select “Help Contents”, then select “XC32 Toochain”, then select “XC32 Peripheral Libraries”, and finally, select “SPI”.

The PIC32 is the SPI master and the display is the slave. System clock frequency of the PIC32 is 80MHz and the Peripheral clock is at 40MHz. . Any changes to the system or peripheral clock will require revising the delay function timing. SPI channel 2 is used to control the display.

The COG LCD display used in this example has a 128x64 resolution but the ST7565 can address up to a 132x65 resolution display (thus the broad range of displays that use the ST7565 controller). Display data RAM stores the dot data, and in the case of a 128x64 display, as a 64 (8 page x 8 bit) x 128 bit structure. Inspection of the source code bit map data in the source file may leave the reader a bit confused (refer to the ST7565 data sheet for details on bit map). This is because the data bits making up the data byte are mapped vertically. The letter “D” in the text message (figure 3), for example, is made up of 0x7F, 0x41, 0x41, 0x22, and 0x1C, the letter “I” is made up of 0x00, 0x7F, 0x00, and the letter “G” is made up of 0x00, 0x3E, 0x41, 0x41, 0x51, 0x32, 0x00.

Figure 3.

Project Build and Load

This is an MPLAB X project, so the reader must install and familiarize themselves with MPLAB X IDE and the XC32 compiler to build and program the PIC32.

Expand/copy project/source zip file " “NHD_COG_128x64_PIC_SPI_X.zip” to desired system location. Open MPLAB X IDE, connect the hardware to your computer, and open project “NHD_COG_128x64_PIC_SPI”. Open the project properties to verify hardware and software tool selection matches your installation. Make and Program device.

Supporting Files

Demo Software

NHD_COG_128x64_PIC_SPI_X.zip (97.3 KB)