Nokia LCD Library
History
I found this LCD make for cellular phone Nokia 3310 by browsing the web at www.jelu.se. There is many interesting things about this LCD: low price, easy to interface via SPI port, can support graphic and text and consume low current. The only thing that I did is writing code who gives you friendly functions to support this LCD. The last version of the library only send the bytes who had changed since the last update. It's considerably reduce the refresh time who can be very important in a batteries powered system.
Functions Features
LcdInit(void)
LcdClear(void)
LcdUpdate(void)
LcdGotoXY(byte x, byte y)
LcdChr(LcdFontSize size, byte ch)
LcdStr(LcdFontSize size, byte *dataPtr)
LcdPixel(byte x, byte y, LcdPixelMode mode)
LcdLine(byte x1, byte y1, byte x2, byte y2)
Pictures
Download
33 Comments to “Nokia LCD Library”
Post comment
Please note
Categories
- All projects
- Audio
- Clock
- Electric Train
- Gadjet
- General Posting
- Laser
- Lastes News
- LED
- Library
- Sensor
- Software
- Work Bench Tools

admin

All my source codes were taken from my personal projects.
Le lien vers le schéma conduit à une erreur 404…
It’s now correct
Sylvain
i love this LCD
Hi,
I have two 2 short questions:
1:
PCD8544 datasheet says: 'Immediately following power-on, the contents of all internal registers and of the RAM are undefined. A RES pulse must be applied. Attention should be paid to the possibility that the device may be damaged if not properly reset.', and there's only 30 ms to reset the display after connecting it to the power.
I can see a preety long delay before
PORTB &= ~LCD_RST_PIN;
in your LcdInit routine, how is that possible?
2:
In .h file, there's:
#define LCD_POWER 0×01 // PB0
but in the schematics PB0 is connected to RES :-/
similarly there's:
#define LCD_RST_PIN 0×10 // PB4
but there's nothing on PB4 in the schematics :-/
Best regards
Hmmmm, For the possibility of damage it’s strange, I never got problem with that, how a chip can be damage is there is no reset,….. and for the reset pin the schematic may be don’t reflect the code, it’s depend from what project I take the code.
Sylvain
Maybe because of the undefined RAM contents – there are some notes in the datasheet. Here's the note about the possibility of damaging the display due to the improper reset:
http://img401.imageshack.us/img401/8192/pcd8544reset.png
In your code I can see:
#define LCD_POWER 0×01 // PB0
and
PORTB |= LCD_POWER;
inside LcdInit before reset.
Does it mean you connected PB0 directly to display's Vdd? Or did you use the transistor and connected PB0 to the it's base?
I power the LCD via PB0, no transistor, avr output can easyly drive the LCD power
Thanx for answering me! I'll try to play with the display these days so I am collecting the data.
Cheers
HI…. i use AVR Studio 4 and i wrote this code
#include <NokiaLCD.h>
int main()
{
LcdInit();
LcdChr(5,'a');
}
it returns me two errors:
undefined reference to `LcdInit'
undefined reference to `LcdChr'
what should i write to display a simple character on the lcd? thank you
Hi,
Don’t forget that all my code is written with ICCAVR so it’s can be different in AVRStudio, For more info check my frequancy counter project all you need is there
Sylvain
it's realy nice but any body built this and run ok ?
thank you
Hi,
How do I write on the screen a character array?
Iulian
Check this code
//**************************************************************************
// Frequancy Meter
// Version 1.0 Mars 2003
//
// 1.0 -> -First Release
//
//
// Sylvain Bissonnette
//**************************************************************************
/*********************************************************/
/* I N C L U D E */
/*********************************************************/
#include “macros.h”
#include “iom8v.h”
#include
#include
#include
#include “NokiaLCD.h”
/*********************************************************/
/* E X T E R N */
/*********************************************************/
extern char UpdateLcd;
/*********************************************************/
/* P R O T O T Y P E */
/*********************************************************/
void Delay(int del);
void timer1_compa_isr(void);
void timer0_ovf_isr(void);
void GetCount(void);
void PrintFreq(void);
void Presentation(void);
void main(void);
/*********************************************************/
/* D E F I N E */
/*********************************************************/
#define TRUE 1
#define FALSE 0
#define CLR 0×20
#define OEH 0×10
#define OEM 0×08
#define OEL 0×04
/*********************************************************/
/* G L O B A L V A R I A B L E S */
/*********************************************************/
unsigned long Count;
unsigned long Time;
/*********************************************************/
void Delay(int del)
{
int i,j;
for (j=0;j
{for (i=0;i<320;i++);
}
}
/*********************************************************/
#pragma interrupt_handler timer1_compa_isr:7
void timer1_compa_isr(void)
{
if ((PINB & 0×02) == 0×02)
{
GetCount();
PrintFreq();
}
}
/*********************************************************/
#pragma interrupt_handler timer0_ovf_isr:10
void timer0_ovf_isr(void)
{
if (UpdateLcd == TRUE) LcdUpdate();
}
/*********************************************************/
void GetCount(void)
{
Count = 0;
PORTD &= ~OEH;
Delay(1);
Count = (unsigned long)((PINC & 0×3f) + (PIND & 0xc0));
PORTD |= OEH;
Count = Count << 8;
PORTD &= ~OEM;
Delay(1);
Count += (unsigned long)((PINC & 0×3f) + (PIND & 0xc0));
PORTD |= OEM;
Count = Count << 8;
PORTD &= ~OEL;
Delay(1);
Count += (unsigned long)((PINC & 0×3f) + (PIND & 0xc0));
PORTD |= OEL;
PORTD &= ~CLR;
Delay(1);
PORTD |= CLR;
}
/*********************************************************/
void PrintFreq(void)
{
char Str[7];
char Tmp[7];
unsigned char Len;
LcdGotoXY(1,4);
LcdStr(2,” “);
LcdGotoXY(2,4);
LcdStr(2,” “);
ltoa(&Str[0],Count,10);
Len = strlen(&Str[0]);
Str[Len] = 0×00;
if (Count < 1000)
{
LcdGotoXY(12-(2*Len),4);
LcdStr(2,&Str[0]);
LcdGotoXY(13,3);
LcdStr(1,” ” );
Time = 100000 / Count;
ltoa(&Str[0],Time,10);
if (Count <= 1000)
{
Tmp[0] = Str[0];
Tmp[1] = ‘.’;
Tmp[2] = Str[1];
Tmp[3] = Str[2];
}
if (Count <= 100)
{
Tmp[0] = Str[0];
Tmp[1] = Str[1];
Tmp[2] = ‘.’;
Tmp[3] = Str[2];
}
if (Count <= 10)
{
Tmp[0] = Str[0];
Tmp[1] = Str[1];
Tmp[2] = Str[2];
Tmp[3] = ‘ ‘;
}
if (Count == 0)
{
Tmp[0] = ‘ ‘;
Tmp[1] = ‘ ‘;
Tmp[2] = ‘0′;
Tmp[3] = ‘ ‘;
}
Tmp[4] = ‘m’;
Tmp[5] = ’s’;
Tmp[6] = 0×00;
LcdGotoXY(9,6);
LcdStr(1,&Tmp[0]);
return;
}
if (Count < 10000)
{
Tmp[0] = Str[0];
Tmp[1] = ‘.’;
Tmp[2] = Str[1];
Tmp[3] = Str[2];
Tmp[4] = Str[3];
Tmp[5] = 0×00;
LcdGotoXY(2,4);
LcdStr(2,&Tmp[0]);
LcdGotoXY(13,3);
LcdStr(1,”K” );
Time = 1000000 / Count;
ltoa(&Str[0],Time,10);
Tmp[0] = Str[0];
Tmp[1] = Str[1];
Tmp[2] = Str[2];
Tmp[3] = ‘ ‘;
Tmp[4] = ‘u’;
Tmp[5] = ’s’;
Tmp[6] = 0×00;
LcdGotoXY(9,6);
LcdStr(1,&Tmp[0]);
return;
}
if (Count < 100000)
{
Tmp[0] = Str[0];
Tmp[1] = Str[1];
Tmp[2] = ‘.’;
Tmp[3] = Str[2];
Tmp[4] = Str[3];
Tmp[5] = Str[4];
Tmp[6] = 0×00;
LcdGotoXY(1,4);
LcdStr(2,&Tmp[0]);
LcdGotoXY(13,3);
LcdStr(1,”K” );
Time = 10000000 / Count;
ltoa(&Str[0],Time,10);
Tmp[0] = Str[0];
Tmp[1] = Str[1];
Tmp[2] = ‘.’;
Tmp[3] = Str[2];
Tmp[4] = ‘u’;
Tmp[5] = ’s’;
Tmp[6] = 0×00;
LcdGotoXY(9,6);
LcdStr(1,&Tmp[0]);
return;
}
if (Count < 1000000)
{
Tmp[0] = Str[0];
Tmp[1] = Str[1];
Tmp[2] = Str[2];
Tmp[3] = ‘.’;
Tmp[4] = Str[3];
Tmp[5] = Str[4];
Tmp[6] = 0×00;
LcdGotoXY(1,4);
LcdStr(2,&Tmp[0]);
LcdGotoXY(13,3);
LcdStr(1,”K” );
Time = 100000000 / Count;
ltoa(&Str[0],Time,10);
Tmp[0] = Str[0];
Tmp[1] = ‘.’;
Tmp[2] = Str[1];
Tmp[3] = Str[2];
Tmp[4] = ‘u’;
Tmp[5] = ’s’;
Tmp[6] = 0×00;
LcdGotoXY(9,6);
LcdStr(1,&Tmp[0]);
return;
}
if (Count < 10000000)
{
Tmp[0] = Str[0];
Tmp[1] = ‘.’;
Tmp[2] = Str[1];
Tmp[3] = Str[2];
Tmp[4] = Str[3];
Tmp[5] = Str[4];
Tmp[6] = 0×00;
LcdGotoXY(1,4);
LcdStr(2,&Tmp[0]);
LcdGotoXY(13,3);
LcdStr(1,”M” );
Time = 1000000000 / Count;
ltoa(&Str[0],Time,10);
Tmp[0] = Str[0];
Tmp[1] = Str[1];
Tmp[2] = Str[2];
Tmp[3] = ‘ ‘;
Tmp[4] = ‘n’;
Tmp[5] = ’s’;
Tmp[6] = 0×00;
LcdGotoXY(9,6);
LcdStr(1,&Tmp[0]);
return;
}
}
/*********************************************************/
void Presentation(void)
{
unsigned char i;
LcdClear();
LcdUpdate();
LcdGotoXY(3,1);
LcdStr(1,”Freq Meter” );
for (i=0;i<9;i++) LcdLine(0,i,83,i,PIXEL_XOR);
LcdGotoXY(5,3);
LcdStr(1,”Sylvain”);
LcdGotoXY(3,4);
LcdStr(1,”Bissonnette”);
LcdGotoXY(4,6);
LcdStr(1,”Ver : 1.0″);
LcdUpdate();
Delay(10000);
LcdClear();
LcdUpdate();
}
/*********************************************************/
void main(void)
{
unsigned char i;
LcdInit();
LcdClear();
LcdUpdate();
Presentation();
LcdGotoXY(3,1);
LcdStr(1,”Freq Meter” );
for (i=0;i<9;i++) LcdLine(0,i,83,i,PIXEL_XOR);
LcdGotoXY(12,4);
LcdStr(1,” hz” );
LcdGotoXY(2,4);
LcdStr(2,” 0″);
LcdGotoXY(1,6);
LcdStr(1,”Period: ” );
TCCR0 = 0×05; //start timer0 / 1024
DDRB = 0×3f;
DDRC = 0×00;
DDRD = 0×3e;
PORTD |= OEH;
PORTD |= OEM;
PORTD |= OEL;
PORTD |= CLR;
//TIMER1 initialisation – prescale:256
// WGM: 4) CTC, TOP=OCRnA
// desired value: 2000mSec
// actual value: 2000.000mSec (0.0%)
TCCR1B = 0×00;
OCR1AH = 0×7A;
OCR1AL = 0×11;
TCCR1A = 0×40;
TCCR1B = 0×0C;
TIMSK = 0×11; //timer interrupt sources
SEI(); //re-enable interrupts
while(1)
{
Delay(10);
}
}
pls mail me the codes to interface this lcd to AT89S52MCU.
Hi Hi Hi a pizza with that??????
Operation at 5V
The Nokia 5110 LCD Module uses a Philips PCD8544 LCD driver, which is designed for mobile phones with a supply voltage of 3.3V. But according to the datasheet, the maximum supply voltage VCC is 7V. The maximum input voltage of all inputs is VCC + 0.5V. No level shifter IC is required for operation at 5V.
See here for the LCD 3 wire control and 5V operation:
http://www.avdweb.nl/arduino/nokia-5110-lcd.html
Great work, thanks for the help. I have a Nokia 5510 LCD, I haven't tested it yet but I'm sure it'll work fine. I'm using AVR Studio 5 for this. Will there be any problems I have to fix? I'm not sure what you meant with the frequency thing.
If there's any complications with the 5510 please let me know
I'm still a rookie at graphic LCD programming, but this stuff is well written and I'm sure I can work it out somehow. Any tips/advice will be awesome. Thanks.
There is some syntax to modify for AVR Studio, but I can’t help you I had never work with AVR Studio
Hi,
I just downloaded a ICC AVR (v7) trial, and compiled the code, but I got this:
!ERROR file 'NokiaLCD.o': undefined symbol '_UpdateLcd'
I have no experience w/ icc avr and I don't get what this error means…
Help would be great, thanks a lot.
hello,
I'd like to tell me if I can print Decade numbers. Have you a function for this? I have the HC-SR04 module and I like to print the cm on nokia lcd 5110 modulo.
I can’t help you
hello, can u tell me how to simulate a nokia lcd with isis using a pic16F877 ?? and thank u
Don’t know
ok thank u
Hi Louis and Sylvain,
your LCD library (http://www.microsyl.com/index.php/2010/03/24/nokia-lcd-library/#more-197) is very useful and I was able to make it work with a Nokia 4310 display. I would like to use this code in the scope of a project that will be hosted on github and will therefore be publicly available.
My question: can I put your code (with due references of course) on github as well? The unwieldy alternative would be referencing your code and providing a patch file. The project itself will probably come under GPL 3 License, Hardware under CC BY NC SA.
Or, much better, could you put up your code on github (with any license you like) yourself, so that anyone can reuse it, contribute to it and it might be possible to reference it as a git submodule?
Best regards, Alex
Hi Alex
Yes you can give my code for free all on my web site if free. I’m please to know that my code had help you, When your project will be finish please informe me I will check a look to !!!
Sylvain
Hi,
Your code runs smoothly on my Nokia display, however I've got a problem with it: I want to add some symbols to the list but I don't understand how they are read.
I think it must be within this code lines:
void LcdCharacter(char character)
{
LcdWrite(LCD_D, 0×00);
for (int index = 0; index < 5; index++)
{
LcdWrite(LCD_D, ASCII[character - 0x20][index]);
}
LcdWrite(LCD_D, 0×00);
}
Maybe you could help me and others looking for this?
Regards,
Peremptor
It’s make to long time I had wrote this code, I don’t remember,
Sylvain
Hi! Thanks for all the great projects and ideas. I just found a NOKIA 3310 LCD on ebay for a very cheap price (about $4.) Looks nicer than the ones I have ripped out of phones before as it only has 8 pins. Very nice work.
regards,
steve (london)
guys plz i didnt have macros.h & iom8v.h file can someone send me theese header files
Just define
#define ushort unsigned char
#define uint unsigned int
it should work
macros.h & iom8v.h ??
Extracted dsiplay from a defunct 3310. Used successfully with Arduino Uno using examples from http://playground.arduino.cc/Code/PCD8544. Can verify that pin out in photo and schematic are correct. Also operation at VDD = 5V and driving data lines direct from Uno worked fine (as per Philips data sheet).
Thanks.