Mar
24

Nokia LCD Library

Author admin    Category All projects, Library     Tags , , ,

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

Schematic

Source code




33 Comments to “Nokia LCD Library”

  • BBenj May 30, 2010 at 4:05 pm

    Le lien vers le schéma conduit à une erreur 404… :-(

  • admin June 1, 2010 at 12:46 pm

    It’s now correct
    Sylvain

  • xoom July 20, 2010 at 6:32 pm

    i love this LCD :)

  • Chupo_cro July 23, 2010 at 12:42 pm

    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

  • admin July 23, 2010 at 12:51 pm

    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

  • Chupo_cro July 23, 2010 at 2:27 pm

    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?

  • admin July 23, 2010 at 2:34 pm

    I power the LCD via PB0, no transistor, avr output can easyly drive the LCD power

  • Chupo_cro July 23, 2010 at 2:45 pm

    Thanx for answering me! I'll try to play with the display these days so I am collecting the data.
    Cheers

  • cata October 22, 2010 at 12:33 pm

    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

     

  • admin October 22, 2010 at 12:45 pm

    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

  • astaza March 8, 2011 at 5:16 am

    it's realy nice but any body built this and run ok ?
    thank you

  • Iulian March 26, 2011 at 7:14 pm

    Hi,
    How do I write on the screen a character array?
    Iulian

  • admin March 27, 2011 at 3:48 pm

    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);
    }
    }

  • nidhin June 4, 2011 at 3:03 pm

    pls mail me the codes to interface this lcd to AT89S52MCU.

  • admin June 4, 2011 at 3:18 pm

    Hi Hi Hi a pizza with that??????

  • Albert van Dalen October 15, 2011 at 9:02 am

     
    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

  • compushh October 27, 2011 at 2:24 am

    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.

  • admin October 27, 2011 at 11:41 am

    There is some syntax to modify for AVR Studio, but I can’t help you I had never work with AVR Studio

  • compushh October 31, 2011 at 3:36 am

    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. :)

  • john November 27, 2011 at 1:03 am

    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.

  • admin November 27, 2011 at 1:08 am

    I can’t help you

  • cheri December 4, 2011 at 6:49 pm

    hello, can u tell me how to simulate a nokia lcd with isis using a pic16F877 ?? and thank u :)

  • admin December 4, 2011 at 7:02 pm

    Don’t know

  • cheri December 5, 2011 at 3:47 pm

    ok thank u

  • BigAlex January 26, 2012 at 1:08 pm

    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

  • admin January 26, 2012 at 1:34 pm

    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

  • Peremptor March 1, 2012 at 4:37 pm

    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

  • admin March 1, 2012 at 11:36 pm

    It’s make to long time I had wrote this code, I don’t remember,
    Sylvain

  • steve June 8, 2012 at 2:49 pm

    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)

  • mohamed July 31, 2012 at 2:46 pm

    guys plz i didnt have macros.h & iom8v.h file can someone send me theese header files 

  • admin July 31, 2012 at 3:11 pm

    Just define
    #define ushort unsigned char
    #define uint unsigned int

    it should work

  • bawix February 11, 2013 at 11:19 pm

    macros.h & iom8v.h  ?? :(

  • Dicky March 23, 2013 at 6:22 pm

    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.

Post comment

Please note

All my source codes were taken from my personal projects.

Everything is for your information only. The C/C++ codes have been written
with ICCAVR. You can find the header and source CRT files by downloading their compiler.

All is for your information and everything is AS IS without any warranty of any kind. No other files are available and I don't make any modification for any body.

Categories

Blogroll

Electronic Links

Tags

AGC Anemometer AVR AVR Bootloader Bootloader Capacitence Capacitor Clock Color Control DCC Debugger Devices Digital driver Function Generator High Gain Microphone Humidity Inductance Inductor Laser LCD LED 3W Library Lightning Detector MegaLoad Meter Moodlight Mood Light MS5534 Nixie OscilloScope projector Rain Fall Sensor rgb RGB LED Scop Sensor SHT75 Temperature Terminal Tipping Bucket Train Modeling Vintage Water Detector