Home / Tutorials / PIC Tutorial / Use the PIC16F877A with Nokia 3310 in XC8
nokia 3310 lcd

Use the PIC16F877A with Nokia 3310 in XC8

In this post, I’ll share with you how I got the Nokia 3310 LCD to run using a PIC16F877A microcontroller. How to use the Nokia 3310 LCD with the Arduino has been covered before. This one is more challenging because I had to create a library for the XC8 compiler. Read on if you’re interested.

I utilized the library used in the SPI PIC16F877A library to connect with the LCD. Here’s the schematic diagram:

pic16f877a-nokia-3310-lcd.png

[the_ad id=”3059″]

Some Discussion

The PCD8544, which is the controller on the Nokia 3310 LCD, accepts two types of input: data or command. The D/C pin is used to indicate if a data or command is sent by clearing or setting it. In this schematic above, the D/C pin is connected to RC0. I used two functions for command and data:

Before we can use the LCD normally, there is a set of commands to be sent to it. Explaining each command would be too extensive for this post so I’d rather suggest you read the PCD8544 datasheet. Anyway, the byte sequence is:

  • 0x21 – use extended instruction set
  • 0x14 – set bias
  • 0xA8 – set contrast
  • 0x20 – function set
  • 0x48 – use normal display mode

Setting the location of the character to be written on the display requires byte 0x80 or’d with the column and 0x40 or’d with the row. For example, if you want to write starting on the second line of the third column then this byte should be sent first:

To clear the screen, I just send 0’s as data to the whole screen.

The Whole Code

As mentioned, you need the SPI library before you can run this code. Place that file on the header folder of your project and also this PCD8544.h file.

A simple “hello world” text on the LCD would take only this short code:

[the_ad id=”3059″]

I hope this post was useful to you! Happy coding!

 

Check Also

Curiosity HPC Buttons

Using Buttons and LEDs on the Curiosity HPC

Last time, I showed how to get started with Microchip’s Curiosity HPC board. I will …

One comment

  1. can I use this code for PIC16F887 and nokia5110? or I have to make changes. Thank you very much

Leave a Reply

Your email address will not be published.