Interfacing PIC18F46K22 MCU with Nokia 5110 LCD

This PIC MCU project shows how to interface PIC18F46K22 microcontroller with Nokia 5110 (Nokia 3310) graphical LCD screen. In this project I’m going to use CCS C compiler.
The name Nokia 5110 (3310) comes from Nokia 5110 (or Nokia 3310) mobile phone. The Nokia 5110 LCD has a controller named PCD8544, it is similar to the Nokia 5110 mobile phone LCD, it uses SPI interface protocol with maximum clock frequency of 4MHz, it requires 5 control pins (at most), it’s low cost and easy to use.

The resolution of this LCD is 84 x 48 which means it has 4032 pixels. This module works with 3.3V only and it doesn’t support 5V (it’s not 5V tolerant), this means interfacing it with 5V microcontroller such as PIC18F46K22 MCU may require voltage level shifter.

The Nokia 5110 LCD module is shown below:

Nokia 5110 LCD module

This module has 8 pins (from left to right): RST (reset), CE (chip enable), DC (or D/C: data/command), Din (data in), Clk (clock), VCC (3.3V), BL (back light) and Gnd (ground).

The pins which may be connected to the microcontroller are: RST, CE, DC, Din and Clk.

Hardware Required:

  • PIC18F46K22 microcontroller   —->  datasheet
  • Nokia 5110 (3310) LCD module
  • AMS1117 3V3 voltage regulator
  • 10 uF capacitor
  • 100 nF ceramic capacitor
  • 5 x 3.3k ohm resistor
  • 5 x 2.2k ohm resistor
  • 5V source
  • Breadboard
  • Jumper wires

Interfacing PIC18F46K22 MCU with Nokia 5110 LCD circuit:
The following image shows example circuit schematic diagram.

The Nokia 5110 which is shown in the circuit diagram has 8 pins (from left to right): RST (reset), CE (chip enable), DC (or D/C: data/command), Din (data in), Clk (clock), VCC (3.3V), BL (back light) and Gnd (ground).

PIC18F46K22 Nokia 5110 LCD interfacing circuit

All the grounded terminals are connected together.

The Nokia 5110 LCD works with 3.3V only (power supply and control lines). The LCD module is supplied with 3.3V which comes from the AMS1117 3V3 voltage regulator, this regulator steps down the 5V into 3.3V (supplies the LCD controller PCD8544 with regulated 3V3).

All PIC18F46K22 microcontroller output pins are 5V, connecting a 5V pin directly to the Nokia 5110 LCD may damage its controller circuit!
To connect the PIC18F46K22 to the LCD module, I used voltage divider for each line. That means there are 5 voltage dividers. Each voltage divider consists of 2.2k and 3.3k resistors, this drops the 5V into 3V which is sufficient.

So, the Nokia 5110 LCD pins are connected to PIC18F46K22 MCU as follows (each one through voltage divider):
RST (reset) pin is connected to pin RD0 (#19),
CE (chip enable) pin is connected to pin RD1 (#20),
DC (data/command) pin is connected to pin RD2 (#21),
DIN (data in)  pin is connected to pin RD3 (#22),
CLK (clock) pin is connected to pin RD4 (#27).

VCC and BL are connected to AMS1117 3V3 regulator output pin and GND is connected to circuit ground (0V).

In this project the PIC18F46K22 microcontroller runs with its internal oscillator @ 32 MHz, MCLR pin is configured as an input pin.

Interfacing PIC18F46K22 MCU with Nokia 5110 LCD C code:
The following C code is for CCS C compiler, it was tested with versions 5.051 and 5.083.

To be able to compile project C code with no error, 2 libraries are required:
The first library is a driver for the Nokia 5110 LCD (PCD8544 controller), its full name (with extension) is PCD8544.c, download link is below:
Nokia 5110 LCD library for CCS C compiler

The second library is graphics library, its full name is GFX_Library.c, download link is the one below:
Graphics library for CCS C compiler

after the download of the 2 library files, add both of them to the project folder.

Hints:
The 2 library files are included in the main code as shown below:

Connections of LCD pins to the microcontroller are defined as:

Software SPI is initialized using #use function as shown below:

And the LCD is initialized as:

Rest of code is described through comments.

Full CCS C code:

My breadboard circuit result is shown by the following video:

Proteus simulation:
This example works with Proteus simulation software since it contains the Nokia 5110 (3310) LCD library. The video below shows the simulation result:

Proteus simulation file download link is below, use version 8.6 or higher to open it:
PIC18F46K22 and Nokia 5110 Proteus simulation


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

2 thoughts on “Interfacing PIC18F46K22 MCU with Nokia 5110 LCD”

  1. #use SPI(DO = LCD_DAT, CLK = LCD_CLK, MODE = 0, BITS = 8, STREAM = LCD)

    I need some explanation on:
    #use SPI(DO = LCD_DAT, CLK = LCD_CLK, MODE = 0, BITS = 8, STREAM = LCD)
    What does the DO stands for? IS this a port?

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top