root@fandigunawan

June 18, 2008

LCD Nokia 3310 (PCD8544) Driver in WinAVR(avr-gcc)

LCD Nokia 3310 is widely known to be monochrome graphic LCD targeted for embedded devices. It is a 84×48 pixels LCD that can be interfaced trough SPI protocol. This is the detail of the LCD’s pins configuration.

Taken from : http://www.myplace.nu/mp3/images/nokia_lcd_small.jpg

The driver is targeted for avr-gcc or WinAVR.

In case you need to recompile to suit your need, please download the following tools :

This design is targeted to be clocked at 4 Mhz, you may change it by modifying makefile or change the configuration of clock in AVR Studio. You can use avrprog or Pony Prog to program your fuse bits (CKSEL) or you may recompile the code to suit your clock speed.

New version :

0.2.6 rev 1 (new)

A silly mistake I made in header file. Please update your version 0.2.6 to 0.2.6 rev 1.

 http://fandigunawan.googlepages.com/lcd_pcd8544_v026rev1.zip

* + Header file (pcd8544.h) PIN definition fixed

0.2.6 (dont use this)

 http://fandigunawan.googlepages.com/lcd_pcd8544_v026.zip

* + Optimization using Memset and Memcpy
* + Bug fix and sample program reviewed
* + Commented <stdio.h>

Many thanks for Jakub Lasinski for code review and suggestions.

0.2.5

http://fandigunawan.googlepages.com/lcd_pcd8544_v025.zip

Changelog from version 0.2.4

* Version 0.2.5 ( December 25, 2008 ) x-mas version
* + Boundary check is added ( reported by starlino on Dec 20, 2008 )
* + Return value is added, it will definitely useful for error checking

0.2.4 rev 1

http://fandigunawan.googlepages.com/lcd_pcd8544_v024rev1.zip

Changelog from version 0.2.4 :

* Version 0.2.4 revision 1 ( December 25, 2008 )
* + Some of boundary checking added (reported by starlino) and this is actually as a part of version
* 0.2.5 but I think i need to add it to this version also.

Old version

 http://fandigunawan.googlepages.com/lcd_pcd8544.zip

Note : If you find out my code working in your design please let me know about it.

——————————————————————————–

Generating hex from BMP using BMP2HEX by Jakub Lasinski :

You will need .NET framework 2.0 to use this application.

 http://fandigunawan.googlepages.com/bmp2hex.zip

———————————————————————————————–

As a request from AGA33, I have posted the picture of the project, schematic as well as the project source code of my thesis (yes, my thesis using old version driver).

The project was clocked using internal oscillator at 4 Mhz, see AVR datasheet regarding to internal clock setting.

The corresponded source code of my thesis.

http://fandigunawan.googlepages.com/water_level_monitor.zip

[Updated May 3, 2009]

Credit

Many thanks to : http://www.myplace.nu/mp3/images/nokia_lcd_small.jpg for awesome PCD8544 picture. Thanks for visitor who told me about this picture credit. Actually I don’t remember actually where I picked the picture since it has been more than a year ago and I used Google image search engine. Actually I don’t remember removing the label myplace.nu from the image but it is fine for me. If you have any problem with my post or project please kindly tell me, I can’t do anything right without your feedback. Thanks.

Links which came to my post:

Other links on 3310 LCD (PCD 8544) driver

75 Comments »

  1. thank you.

    Comment by jack manchester — June 30, 2008 @ 2:01 am

  2. Hello, I used your library. It was very useful, but did you read atmega8 datasheet?
    According to the datasheet, if SPI module used, MISO pin is forced to set input.
    My target board didn’t worked because MISO pin can’t be set as output. Did your target worked?

    Comment by Anonymous — August 24, 2008 @ 8:59 pm

  3. Like others you could also have taken the short cut to writing this article but you desisted from it because the primary objective of writing this article about LCD was my satisfation. And after reading this article, i can yourself feel it.

    Comment by Tony — September 29, 2008 @ 7:08 am

  4. Hi,

    Thanks sharing this
    Great project indeed

    I tried to run the simulation in Proteus, and got the message :

    cannot find model file ‘PCD8544.MDF’

    I googled arround, without being able to find that particular lib

    i have proteus 7.2 so i don’t believe this is a version issue

    can you please tell where i could find this model file ?

    Thanks in advance

    Comment by Tewfik — October 22, 2008 @ 7:05 pm

  5. Eventually, a quick search with ‘pcd8544 vsm’ did the job (yahoo search was better than google on this one)

    i found a nice vsm model for nokia 3310 display

    http://www.tanu-sha.narod.ru/nokia3310.html

    even in demo version, still it is usefull for testing purposes

    cheers

    Comment by Tewfik — October 22, 2008 @ 7:19 pm

  6. Unfortunately vsm model for nokia 3310 display on website:
    http://www.tanu-sha.narod.ru/nokia3310.html
    didnt work for me. I have Proteus 7.2 SP2 and i receive an error trying to run simulation “Error in PCD8544.DLL Failed to auhorize L1″…
    Who knows the solution? Or maybe you have a vorking model for Proteus 7.2?

    Comment by Montis — December 2, 2008 @ 12:05 pm

  7. Thank you for the code it rocks, I was able to change few things and use it for Arduino.

    Just two things. I still haven’t been able to use fonts with PROGMEM and would appreciate if you could help me with 16×16 icon code.

    cheers

    Comment by FireBALL — December 20, 2008 @ 4:12 pm

  8. Thank you for the code. I think it needs some updates.

    1)
    In main.c you have
    LcdGotoXYFont(0,3); while the range for this function is 1,1 .. 14,6 as specified in pcd8544.c

    2)In pcd8544.c all places where you have

    LcdCache[LcdCacheIdx++] = ..

    this needs to be updated to

    LcdCache[LcdCacheIdx] = ..
    LcdCacheIdx = (LcdCacheIdx + 1) % LCD_CACHE_SIZE;

    This will make sure you never exceed LCD_CACHE_SIZE and do not address data outside the allocated range for buffer. The index will rather wrap to the beginning of buffer .

    This bug seems to be inherited from Sylvain Bissonette’s original code .
    http://www.microsyl.com/nokialcd/nokialcd.html

    It would be a good idea to put the code on SVN (google code or similar) so contributers can fix bugs.

    Comment by Starlino — December 20, 2008 @ 10:42 pm

  9. I would highly appreciate if someone could help me with following

    I have an encoder which sets delay value, which I would like to display on the screen

    whenever I put LcdStr (1, value);
    i get following msg

    In function ‘void loop()’:
    error: call of overloaded ‘LcdStr(int, byte&)’ is ambiguous

    and if I use LcdChr (1, value);
    it appears as garbled text (iguess LcdChr sees value as byte)

    i’m not really well acquainted with programming

    would appreciate if some could help

    I’m using a combination of code found here and

    http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1142523140/15

    with arduino

    Comment by confused — December 26, 2008 @ 7:23 am

  10. @starlino :

    Thanks for tour constructive response. I’ve update the code but I’ve not managed to test it.

    @confused :
    You must cast the string if it generate compiler error message. e.g LcdStr(1, (byte *) str_variable);

    @fireBall
    Currently I havent managed to test all of functions in this LCD driver. But I thing you can try see the code itself.

    Comment by fandigunawan — December 26, 2008 @ 12:19 pm

  11. Gracias

    the simulation dont work, cannot find model “PCD8544.MDF” please adjunt this archive.

    Por favor sube el archivo de nuevo pero con tus archivos PCD8544.MDF, el otro http://www.tanu-sha.narod.ru/nokia3310.html dont work

    cali – colombia

    Comment by oscareev — March 10, 2009 @ 6:08 am

  12. @Gracias :

    As I lost my DLL library for 7.x PCD8544, you may download from http://www.tanu-sha.narod.ru/nokia3310.html but please be advised that DLL library provided is for Proteus 6.x

    Comment by fandigunawan — March 14, 2009 @ 12:07 pm

  13. please can you upload this very type of proteus model of the nokia 3310 that u used in this circuit. thanks for coop

    Comment by tunde — March 17, 2009 @ 3:48 pm

  14. @tunde:
    Ive lost the proteus model. Dont use the schematic if you use proteus 7.x. If you wanna enable simulation use proteus 6.x and download the model from http://www.tanu-sha.narod.ru/nokia3310.html. Let me know if your problem persist.

    Comment by fandigunawan — March 18, 2009 @ 1:27 pm

  15. The driver didn’t work with my ATmega8. LCD showed bursted picture. Words were cut in pieces. I also tried originaly added HEX file the result was the same

    Comment by AGA33 — March 20, 2009 @ 1:17 pm

  16. This project does not work with my ATmega8 too. I tried to recompile it, but the result has not changed. I’m using WinAVR-20090313. Project on codevision from (http://radiokot.ru/forum/viewtopic.php?t=138&postdays=0&postorder=asc&start=100&sid=3d54de55f1864494be3b6bef29d6ef4f) works well with my ATmega8.

    Comment by chyvack — March 20, 2009 @ 11:58 pm

  17. @AGA33 && chyvack
    Please show me the schematic of your design. This project has been made with clock speed at 4 MHz. It might be the main cause of your problem. If your problem continue to exist please let me know the symptom and or the design you use.

    Comment by fandigunawan — March 21, 2009 @ 2:03 pm

  18. To anybody who use my code and find out it is working please kindly tell me so that I am convinced that the code has no bug. Thanks.

    Fandi.

    Comment by fandigunawan — March 21, 2009 @ 2:05 pm

  19. I’ tried to use 1, 4 and 8Mhz internal oscillator. All versions of code v.2.4-v.2.6. Schematic I use is shown in picture named “schematics”. Also tried older newer version of AVR studio and WinAVR. My MCU is Atmega8-16PU. Text or picture was cut in to pieces and shown bursted. Also in project file “pcd8544.h” i found that pins defined incorect:
    /* ATMega8 port pinout for LCD. */
    #define LCD_DC_PIN PB3 /* Pin 0 */
    #define LCD_CE_PIN PB2 /* Pin 2 */
    #define SPI_MOSI_PIN PB5 /* Pin 3 */
    #define LCD_RST_PIN PB4 /* Pin 4 */
    #define SPI_CLK_PIN PB7 /* Pin 5 */

    But still after change result is bad. The only project i found which .hex file worked correctly was at http://www.dharmanitech.com/2008/10/thermometer-design-using-ds1621.html

    Maybe someone could show how exactly fuse bits should be configure, in picture or somehow. Also it would be interesting to see how it’s working in reality (picture or video). Thanks.

    Comment by AGA33 — March 21, 2009 @ 8:30 pm

  20. As I said, the new version have bad definitions of pins in pcd8544.h file for ATmega8, maybe it’s for other ATmega, the older versions are ok. But still even with external oscillator i get the same result (I am 100% sure I used 4Mhz (have experienced )), but still picture or words were cut in half by horizantal and moved.

    Comment by AGA33 — March 22, 2009 @ 11:42 am

  21. @AGA33: I too get the same problem.
    I think the issue is with the LCD which i got from local market
    Please let me know if something could be done.

    Comment by Embedder — April 13, 2009 @ 6:12 am

  22. Hello, I was wondering if it is possible to change output pins on ATmega8. Everything is OK while I am using default pinout definition:
    #define LCD_DC_PIN PB0 /* Pin 0 */
    #define LCD_CE_PIN PB2 /* Pin 2 */
    #define SPI_MOSI_PIN PB3 /* Pin 3 */
    #define LCD_RST_PIN PB4 /* Pin 4 */
    #define SPI_CLK_PIN PB5 /* Pin 5 */

    If I change D/C pin to PB1 for example, it is running OK, but when I try to change MOSI pin, display will stop working (or funny thing is, that even if i change definition in source, display will work just when MOSI is connected to do MOSI, doesn’t matter that definition was changed). Is there any possibility to change the output pins? In my project, I cannot use exactly those default settings. I have to use another port, but I don’t know how. PLEASE, if you know about some solution, let me know.

    Thanks!
    (And sorry, I am not native English speaker🙂 )

    Comment by matelko — April 14, 2009 @ 2:44 pm

  23. That’s really cool that you shared your code with everyone, big props for that!
    Though, I think you used pictures from http://www.myplace.nu/mp3/ and didn’t give any credit. It’s not a crime, but it basically is quite lame thing to do😉 You’ve already received some negative reputation in AVR community because of that. Maybe you should fix it. Believe me, I did the same mistake before.

    Comment by Visitor — May 3, 2009 @ 5:23 am

  24. […] to : http://www.myplace.nu/mp3/images/nokia_lcd_small.jpg for awesome PCD844 picture. Thanks for visitor who told me about this picture credit. Actually I don’t remember actually where I picked the […]

    Pingback by LCD Nokia 3310 (PCD8544) Driver in WinAVR(avr-gcc) « root@fandigunawan — May 3, 2009 @ 6:51 am

  25. @Visitor, Hi thanks for your feedback. I actually dont remember where I took the picture since it has been almost 2 years. I got the image from Google image search. Anyway, thanks for your constructive comment.

    Comment by fandigunawan — May 3, 2009 @ 7:19 am

  26. Someone upload pcd8544.mdf please!

    Comment by atakan — May 12, 2009 @ 10:57 am

  27. […] LCD Nokia 3310 PCD8544 Driver in WinAVR avr gcc root fandigunawan Posted by root 2 hours 10 minutes ago (https://fandigunawan.wordpress.com) But i thing you can try see the code itself comment by fandigunawan december 26 2008 12 19 pm powered by mypagerank net middot blog at wordpress com Discuss  |  Bury |  News | LCD Nokia 3310 PCD8544 Driver in WinAVR avr gcc root fandigunawan […]

    Pingback by LCD Nokia 3310 PCD8544 Driver in WinAVR avr gcc root fandigunawan | Wood TV Stand — May 31, 2009 @ 11:38 pm

  28. Hi! I’m trying to build this in AVRStudio w/ WinAVR, but I get an odd error:

    rm -rf main.o pcd8544.o lcd_pcd8544.elf dep/* lcd_pcd8544.hex lcd_pcd8544.eep lcd_pcd8544.lss lcd_pcd8544.map
    process_begin: CreateProcess(NULL, “E:/Warrens Work/WinAvr/utils/bin/sh.exe -c E:/Warren\s Work/WinAvr/utils/bin/sh.exe -c mkdir\ dep\ 2\>/dev/null”, …) failed.
    process_begin: CreateProcess(NULL, “E:/Warrens Work/WinAvr/utils/bin/sh.exe -c E:/Warren\s Work/WinAvr/utils/bin/sh.exe -c rm\ -rf\ main.o\ pcd8544.o\ \ lcd_pcd8544.elf\ dep/\*\ lcd_pcd8544.hex\ lcd_pcd8544.eep\ lcd_pcd8544.lss\ lcd_pcd8544.map”, …) fail
    ed.

    make (e=3): The system cannot find the path specified.
    make: [clean] Error 3 (ignored)
    Build succeeded with 0 Warnings…

    HELP!!!

    Comment by Kyle James — June 26, 2009 @ 4:11 am

  29. great post(why i keep getting an error when i try to subscribe to your feed)?thanks

    Comment by Chicken Coop — July 2, 2009 @ 5:42 pm

  30. Sir,

    In your circuit you have connected

    PIN4 of LCD to PB0
    PIN5 of LCD to SS
    on Atmega8

    But on Atmega128 PB0 and SS are on same PIN. What should I do and how should I make connections?
    Should I directly give a 0(zero) on SS of LCD?

    Please Help

    THanking You
    Naveen

    Comment by Naveen — August 1, 2009 @ 5:44 am

  31. Works great with my mega 8 clocked at 12mhz.

    I used 2 LCD’s off of a Nokia 6160 & 5190. (same daughter boards on both phones)

    If i can, I will try and write a few functions to handle numbers and or timers (to avoid non-c expert confusion around pointers) and will post if I make any headway.

    Keep up the great work!

    Comment by matt deren — September 3, 2009 @ 12:53 am

  32. Oh, before is forget:

    Great notes on the nokia phones.. old but works like a charm.
    http://www.selbing.com/_jakob/electronics/nokia.htm

    Comment by matt deren — September 3, 2009 @ 12:57 am

  33. Hope this helps some people… This function converts an unsigned int to a string. I am sure there are cleaner ways to do this, but it works.

    void LcdNumber(unsigned int font_size,unsigned int c) {
    char str[100];
    int a;

    itoa(c, (char *)str, 10);

    for(a=0; a<strlen(str); a++) {
    LcdChr(font_size, str[a] );
    }
    }

    Comment by matt deren — September 4, 2009 @ 11:29 pm

  34. […] is a lot of info and code on talking to the Phillips PCD8544 display driver with AVR (and other micros). There is also a […]

    Pingback by quick reference of problems past » Blog Archive » Graphics for the Nokia 3310 LCD and AVR — November 15, 2009 @ 12:53 pm

  35. Hi! you have a great blog here! I’m definitely going to bookmark you! Thank you for your info.

    Comment by HD LCD TV — May 16, 2010 @ 2:38 pm

  36. Hi,

    5 V on PCD8544’s Vdd and everything was OK? Everywhere I read says Vdd should be between 2.7 and 3.3 V!? What about the transmiter and receiver circuits/data? These would also be interesting.

    Comment by Chupo_cro — June 13, 2010 @ 1:11 pm

  37. I have modified this excellent driver to a C++ templated object design, with support for multiple instances (with distinct DC/CE/RST pins).

    http://github.com/AretCarlsen/Philips_PCD8544_driver

    Comment by Aret Carlsen — July 30, 2010 @ 3:08 pm

    • Wow, cool. I have never tried the G++ things for embedded system. I will look to your code and I will try to put link to your side.

      Comment by fandigunawan — July 31, 2010 @ 3:21 am

  38. Hi,

    I saw I can wirte a word using: LcdFStr(FONT_1X,(unsigned char*)PSTR(“test”));
    But if I have a character array (char c = {‘a’, ‘b’, ‘c’}), how do I write this on the screen?
    If I try this: LcdFStr(FONT_1X,(unsigned char*)PSTR(c)); it gives me an error: invalid initialization

    How do I write a character array?

    Comment by Iulian — March 26, 2011 @ 7:31 pm

    • use LcdStr instead. LcdFStr is to write data which is in flash.

      Comment by fandigunawan — April 16, 2011 @ 5:02 pm

  39. Hi, i’m getting some problems to put it work with atmega8, the same code works great in atmega328p but not in atmega8, any solution?!
    Thanks🙂

    Comment by Jose Xavier — April 15, 2011 @ 7:54 pm

    • Wow, it is a new case. The code was actually developed for Atmega8, can you specify the detail of the problem?

      Comment by fandigunawan — April 16, 2011 @ 4:52 pm

  40. The library set the MISO as output to control the reset of the LCD but i read in atmega datasheet that the MISO must be INPUT when the atmega act as slave.
    First i set the MISO as INPUT and second i use another pin the control the RESET of the LCD, now it is working

    BTW i still don’t know why work in atmega328p and not in atmega8 :S

    Comment by Jose Xavier — April 15, 2011 @ 11:53 pm

    • My code should works on ATmega8 since it was developed for it. The MOSI part is for data transmission, SCK is for clocking the communication to device. Incidentally, the MISO part is not SPI, it is for controlling Reset and the SS is designed to control Controller Enable which should be driven manually. If your project does not work, separate the control for Reset and Controller Enable to other pin.

      Comment by fandigunawan — April 16, 2011 @ 5:01 pm

      • i need to change the PB4 to another pin.
        #define LCD_RST_PIN PB1 /* Pin 4 */

        and i need to set the MISO as input:
        LCD_DDR &= ~(_BV( PB4 ));

        At page 122 (datasheet: http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf ) they say that in SPI master mode MISO should be input.

        I don’t know why but the true is that your code works with the atmega328p but not with atmega8 maybe some fuse bits :s

        Comment by Jose Xavier — April 16, 2011 @ 8:52 pm

  41. Can anyone just confirm that the LcdImage only works with images save to flash!?

    Comment by Jose Xavier — April 16, 2011 @ 3:00 pm

    • Yes it is, LcdImage will only load image on flash.
      However, you can modify my code.

      1. Make LcdCache visible from header file (make it as extern)
      2. Modify LcdCache as you wish
      3. call LcdUpdate()

      If you are confused, please see LcdImage function. The pgm_* function is function to read data from flash, the other lines should be self explained.

      Comment by fandigunawan — April 16, 2011 @ 4:51 pm

      • I already add functions for that🙂 thanks anyway
        if you want i can send them to you so you can add it if think is good.

        Comment by Jose Xavier — April 16, 2011 @ 8:47 pm

  42. Перевод веб сайтовТехнический перевод документов, перевод паспорта с нотариальным заверением, профессиональный устный перевод. Наше бюро переводов отличают демократичные цены на перевод и высокое качество.

    Comment by Кирилл и Мефодий — May 19, 2011 @ 3:21 pm

  43. I’m using ATmega88PA and I tried to change RST from PB4 to PB1 and D/C from PB0 to PB4 by making changes to #defines in lcd_pcd8544.h. RST-pin change works but when I also change D/C-pin it doesn’t work properly.
    I put some images to the display and every time the picture changed it moved little to the right. Same happened to text. When the picture went over from right side the over gone part came from left side of screen and it was little lower than it should have been.

    …5 mins later: I just tested and changed only D/C to PB1 and it works. Seems like you can’t connect D/C to PB4.

    Comment by Pertti Perusingenjoor — July 11, 2011 @ 2:49 am

  44. Hi,
    I’ve tried to use your driver on ATmega128A. I use original example. I have only switched pins of MCU:
    #define LCD_DC_PIN PB4
    #define LCD_CE_PIN PB0
    #define SPI_MOSI_PIN PB2
    #define LCD_RST_PIN PB5
    #define SPI_CLK_PIN PB1
    but it doesn’t work. Nothing displays. What’s wrong? Is there something what needs to be changed for M128 in your code?
    Thank you for answer

    Comment by Jan Mrázek — August 25, 2011 @ 1:53 pm

  45. […] […]

    Pingback by interfacing of glcd with atmega16 — August 29, 2011 @ 1:52 am

  46. halo guys.i am new micro-controller user.i am using PIC 16F877A for my spectrum analyzer project. can anybody tell how the pin cnfiguration for the LCD if i use PIC 16F877A? and how about the driver..?? someone please give me guide..so stress now =(

    Comment by kyle — December 4, 2011 @ 9:33 am

  47. ahm does any one knows the code to interface arduino to nokia 3310 as a modem?

    Comment by john — December 27, 2011 @ 10:23 am

  48. Hi,
    I searched pcd8544, and I found your page.
    I ported your program in STM32 .
    I am remodeling your Driver now so that Japanese (kanji) displays it.
    thanks you.

    Comment by norakuro3501999 — April 5, 2012 @ 1:03 pm

  49. hi,
    for two days trying to connect one character, but it did not work. It is a degrees symbol “°”. Could anyone advise how to do it? thanks a lot

    Comment by George — January 9, 2013 @ 7:07 pm

    • Problem solved. Instead we have to write the symbol ° = {.
      But before that, we must add: {0x00, 0x00, 0x02, 0x05, 0x02}

      Comment by George — January 9, 2013 @ 9:12 pm

  50. http://oshibka.elektrosha.ru/?p=76 Samba ошибка подключения ресурса windows

    Comment by hckydnjv — October 13, 2013 @ 4:40 pm

  51. Hi,

    I’m with problems displaying a variable on the screen. I want to display a variable with the temperature (using a LM335) but I can’t display the variable. I can only display predefined text using PSTR, but I can’t use a variable… Anyone can help?

    Comment by Pedro Silva — January 16, 2014 @ 1:58 pm

  52. Порекомендуйте сайт где надежно продвинут в интернете сайт? Приходилось сталкиваться с недобросовестными работниками,ничего не сделали. Нужен серьезный подход к сайту для моего бизнеса.

    Comment by AnthonyParl — February 15, 2014 @ 6:58 pm

  53. my lovely phone nokia 3310 stiil in trouble ,
    my lcd is broken and need to search replacement,
    i love this old phone😦

    Comment by Halra — March 29, 2014 @ 5:18 am

  54. There is something going horribly wrong with this library, if you change the Data pin of LCD from MOSI to any other pin the whole thing just doesn’t work anymore. Why is it so stubborn about that MOSI pin? I see other people having this problem as well.

    Comment by FrozenHaxor — March 29, 2014 @ 8:51 pm

    • that is the way it works, MOSI is a pin of SPI interface that is implemented on hardware level so in atmega328p there is only one pin capable of it.

      Comment by josexavier69792992 — March 29, 2014 @ 8:57 pm

      • Right, so I assume the CLK is as well.

        Why doesn’t it work on ATMega16 under those settings then?
        /* LCD Port */
        #define LCD_PORT PORTB
        #define LCD_DDR DDRB

        /* ATMega8 port pinout for LCD. */
        /* 0.2.6 bug, fixed */
        #define LCD_DC_PIN PORTB1 /* Pin 1 */
        #define LCD_CE_PIN PORTB2 /* Pin 2 */
        #define SPI_MOSI_PIN PORTB5 /* Pin 5 */
        #define LCD_RST_PIN PORTB3 /* Pin 3 */
        #define SPI_CLK_PIN PORTB7 /* Pin 7 */

        Everything is properly connected.

        Comment by FrozenHaxor — March 29, 2014 @ 10:24 pm

      • Okay, I got it partially working – it works on 8MHz but won’t run on 16… interesting…

        Comment by FrozenHaxor — March 29, 2014 @ 11:43 pm

      • Did you change the external crystal?

        Comment by josexavier69792992 — March 30, 2014 @ 1:34 am

      • Prescaled the SPI even further (by 8) to get 2MHz of CLK speed and it’s working okay now, was simply too fast😛

        Comment by FrozenHaxor — March 30, 2014 @ 1:01 am

  55. Duh, this library is a menace to use. Has anybody succeeded in displaying numeric variables with this?

    Comment by FrozenHaxor — March 30, 2014 @ 4:18 pm

    • I had the same problem as you. I solve it by “transformin” the variable with n digits in to a vector with n elements, like this:

      vector[1] = ((unsigned char)((variable)%10)) | 0x30;
      vector[0] = ((unsigned char)((variable/10)%10)) | 0x30;

      \\…..\\

      LcdStr(FONT_2X,tempDisplay);

      Hope this helps.

      Comment by Pedro Silva — March 31, 2014 @ 11:24 am

      • There is a mistake on the last line. The variable isn’t “tempDisplay”, it’s “vector”. Sorry

        Comment by Pedro Silva — March 31, 2014 @ 11:44 am

      • No worries, I ditched this garbage library already. Try this one out: http://agock.com/software/glcd-graphic-lcd-library/

        Excellent.

        Comment by FrozenHaxor — March 31, 2014 @ 3:53 pm

      • I don’t think this library is that bad. It takes a bit of time to know how to work with the variables, but that was the only problem I got.
        I don’t know why I didn’t use that other library (glcd), but I know I had tried it and it didn’t work…

        Comment by Pedro Silva — March 31, 2014 @ 4:02 pm

      • I had some problems setting it up too. Was worth it though, the best LCD library out of all! Well all you have to do is set up the MCU and the LCD driver correctly then set the correct SPI pins and connect the LCD to the hardware SPI.

        Comment by FrozenHaxor — March 31, 2014 @ 4:56 pm

      • Maybe that was my problem only. In fact, when I try it it was on version 0.5.1. Maybe there was something different there that makes it fail on my code. The only thing I know is it’s working like a charm now and it only needed a little patience figuring out what’s wrong displaying the variables.

        Howsoever, it’s good to know that library works really well although

        Comment by Pedro Silva — March 31, 2014 @ 5:06 pm

  56. – – – Atmega32 UPDATE Atmega32 – – –
    Hi all and author,
    please make little update of this “classical” PCD8544 library.

    SPI block on Atmega32 (and other mcu) contains outputs as: MISO + MOSI + SCK + SS.

    Although we don´t use MISO and SS outputs of SPI block in these application, these outputs MUST BE set as OUTPUT.

    In file pcd8544.h add:
    //Other SPI pins (UNUSED, but muset be set as output):
    #define unused_AVR_SS_PIN PB4
    #define unused_AVR_MISO_PIN PB6

    In file pcd8544.c repair one line in method “LcdInit”:
    LCD_DDR |= _BV( LCD_RST_PIN ) | _BV( LCD_DC_PIN ) | _BV( LCD_CE_PIN ) | _BV( SPI_MOSI_PIN ) | _BV( SPI_CLK_PIN ) | _BV( unused_AVR_SS_PIN ) | _BV( unused_AVR_MISO_PIN );

    Successfully tested on Atmega32 / 16Mhz.

    Comment by MichalS — May 1, 2015 @ 2:21 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: