Interfacing Nokia 3310 LCD with PIC 18F2520

Nokia 3310 was an extremely popular mobile phone during it’s time. However with advent of newer colour mobile phones the old ones are discarded, but almost everyone possessed this magical phone. As the topic suggests we are going to interface a Nokia 3310 LCD (Type LPH7779) with a PIC18F2520. The LCD can be bought at any mobile repairing shop or can be hacked off an old Nokia 3310. Beware the Chinese LCD do not possess the entire pixels but still work pretty well if you cannot find the original. The LCD is based on PCD8544 controller, it can drive a 48X84 pixels matrix LCD. Please note that this type of LCD interfacing is different than the conventional HD44780 type LCD. The LPH7779 LCD displays pixels and the characters need to be first created in the PIC Micro Memory, unlike the 2X16 LCD where the characters can be directly printed on the screen.

 

The tutorial is aimed at providing basic information for beginners and does not include the complex character generation method used. However any advanced user may read the datasheet for the controller and understand the method of displaying character and other commands used to initialize the LCD.

 

The compiler used is MikroC from Mikroelektronika (www.mikroe.com) which is available for download with 2k demo limit.

 

The PIC 18F2520 is a 28 pin device with 25 I/O Pins. It has 32K program memory and 1536 bytes of data memory along with many on chip peripherals like ADC, EUSART, SPI, MSSP, Interrupts etc.

The LCD connects with PIC 18F2520 via SPI (Serial Peripheral Interface) and requires only 5 I/O lines.  The setup uses the internal RC oscillator of PIC micro and no external crystal is required. The setting for internal RC oscillator can be set in the CONFIG register during setting up a new project wizard of MikroC. Inexperienced users may utilize an external 4 MHz crystal.

 

LCD PIN Details

 

  • SDIN: Serial Data Input
  • SCE: Chip Enable
  • SCLK: Serial Clock
  • D/C: Data or Command
  • Reset: Reset’s Chip
  • VDD: 3V Supply
  • Vout should be connected to GND via a 4.7uF (or higher) value capacitor.

 

Nokia LCD Circuit Diagram

 

Note: The VDD & VSS pins of PIC 18F2520(not shown) should be connected with VDD & GND of power supply or battery. A 100nf capacitor should be connected between the VDD& VSS pins of PIC18F2520. The circuit should operate at 3 volts, a CR2032 lithium ion cell may be used. The circuit consumes very low power.

 

Few Pictures:

 

Nokia LCD Display

Nokia LCD

Nokia LCD breadboard circuit

 

A Microchip ICD2 is used for programming. The picture shows a 18F2520 running a Nokia 3310 LCD. The setup may seem a little crude, but you can do the pruning and making it look a little pretty.

 

Program:

 

/* Nokia 3310 LCD Interfacing

         BOTSKOOL

      SHOBHITKUKRETI

*/

#include<nokia3310botskool.h>

#include<all.h>

void main()

{

TRISC=0; // PORT C as output

PORTC=0;   // Intial Value at PORTC is Zero

cmcon=0x07;  // Turn off the comparators

nokia_init();     // Initialising the Nokia LCD

delay_ms(10);

nokia_clear_screen(); // Screen should always be cleared intially.

delay_ms(10);

nokia_clean_ddram();

while(1)

{

nokia_gotoxy(15,0);

printf("  BOTSKOOL");

nokia_gotoxy(15,1);

printf("  CAN BE");

nokia_gotoxy(15,2);

printf("  REAL");

nokia_gotoxy(15,3);

printf("  FUN  ");

nokia_gotoxy(15,4);

printf("  24/7  ");

delay_ms(1500);

nokia_clean_ddram();

nokia_gotoxy(0,0);

printf("MADE");

nokia_gotoxy(40,0);

printf("BY");

nokia_gotoxy(5,2);

printf("SHOBHIT");

nokia_gotoxy(5,3);

printf("KUKRETI");

delay_ms(1500);

nokia_clean_ddram();

}

}

 

 

Please place the two header files in the include folder of “C:/Program Files/Mikroelektronia/MikroC” before compiling the code.

Comments & Suggestions are welcome.

P.S. : - 

LCD Controller is PCD8544, google it for datasheet and understanding the various commands sent to LCD to initialize. It also provides a good example to show how fonts can be developed. To display a picture on this LCD, small program called FAST LCD may be used which will covert any bmp image into a table which needs to be fed to the microcontroller. Similar to character generation the picture is first created in the PIC Micro memory and then displayed on the LCD

 

 

  

Comments

Member since:
7 November 2010
Last activity:
6 years 15 weeks

Can you please upload the code for the function to display images on the LCD with the complete procedure? Thanks in advance.

Member since:
21 May 2010
Last activity:
6 years 15 weeks

 

Hi

I would like  to now what is the  best program for simulating nokia 3310 LCD  with PIC as i see in picture above?

Thanks


Member since:
20 May 2010
Last activity:
6 years 40 weeks

Wel nice tutorial,you have just explained it in easy way.I am a beginner and learning by reading and exeperimenting.

Member since:
28 April 2009
Last activity:
6 years 47 weeks

There are a lot of other associated registers with portc and portb. I have not gone through the data sheet of 16F887. Make sure comparators are off if any and , port is in Digital I/O mode and not the analog mode

Member since:
20 February 2010
Last activity:
6 years 49 weeks

Hi, I developed this circuit using a pic 16f887 and the result is great, now I want to set the display on the doors B.

I changed this part of code, but does not work:

TRISC = 0, / / Port C as output
PORTC = 0, / / Value at Intial PORTC is Zero

to

TRISB = 0, / / Port B as output
PORTB = 0, / / Value at Intial PORTB is Zero

and

# define nok_sclk portc.f0
# define nok_sda portc.f1
# define nok_dc portc.f2
# define nok_cs portc.f3
# define nok_res portc.f5

to

# define nok_sclk portb.f0
# define nok_sda portb.f1
# define nok_dc portb.f2
# define nok_cs portb.f3
# define nok_res portb.f5

The pins of the gates are different because I had followed another guide who brought her in this way and had already developed the circuit.

Anyway, with the pins changed on PORTC everything works, but when reprogrammed for PORTB no longer works.

How can I fix?

Thanks

Member since:
16 November 2009
Last activity:
7 years 14 weeks

I have built a program for driving the Nokia 3310 LCD. I bought 2 of these LCDs recently, while I had another older one with me(without the plastic frame). Now I am facing a problem interfacing these new LCDs that the display is garbled on both. The older one displays correctly (as in Proteus): 

 

What I am getting on both new LCDs is:

 

The older LCD:

 

see also the difference in graphics display for older & newer: 

http://lh5.ggpht.com/_Njeu3g-Ugm0/SwEr1nA5jqI/AAAAAAAABHM/7qrn4xQa7MI/s800/Clipboard04.jpg

 

http://lh6.ggpht.com/_Njeu3g-Ugm0/SwEr2p9aY4I/AAAAAAAABHQ/garYdv61FrU/s800/Clipboard05.jpg

 

The newer LCDs are not displaying the top 2 rows of the image & the last 11 rows of the LCD are always filled with random(?) dots. I also think the LCD is writing some data off-screen as some characters are not visible at all.I am using 5V for all the LCDs (according to some websites) & here's the (standard) initialization:


lcdcmd(0x21);  // Activate Chip and H=1.
lcdcmd(0x80 + 90); // contrast value (0 to 127): 60 enough for old LCD & 90 for new
lcdcmd(0x13);  // Adjust voltage bias.
lcdcmd(0x20);  // Horizontal addressing and H=0.
lcdcmd(0x09);  // Activate all segments.
clrdisp();  // Erase all pixel on the DDRAM.
lcdcmd(0x08);  // Blank the Display.
lcdcmd(0x0C);  // Display Normal.
pixelXY(0,0);  // Cursor Home.



The commands for setting contrast work (but different values  for old & new, as you can see above)
So finally here are my queries:
1) I suspect it is some different controller than PCD8544  (
http://www.edaboard.com/ftopic324477.html).  Is anyone aware of  a different controller than this in Nokia 3310 LCD?
2) Is 5V safe for this LCD/controller? datasheet says 7 V is absolute max.
3) I saw some people talking about setting an offset. What is it & how to use it? Cant find anything in the datasheet...



 

 

 

 

 

 

 

Note:- This post has been edited by munish4u911ex at Mon, 2009-11-16 19:34.

Member since:
4 November 2009
Last activity:
7 years 16 weeks

This is a great idea, which I intend to implement on my next project - many thanks!  One query though: is the wiring diagram 100% correct?  I ask because the LCD serial clock pin is shown connected to the PIC serial data out pin.  Similar issues with other pins.  ..unless I've missed something.  Many thanks.

Member since:
30 June 2009
Last activity:
7 years 34 weeks

Hi...

 

I have given 3.3 V to LCD's VDD pin......but all logic signals for the LCD coming from my pic micro are at 5V (or 0),,,,,,,is this OK....or shud i run the pic itself at 3.3V???My program is not working.....but i think the protocol is right....so ..........this doubt.....

 

all feedback appreciated....

i really like this