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:
- http://radiokot.ru/forum/viewtopic.php?t=138&postdays=0&postorder=asc&start=80
- http://blog.goo.ne.jp/sirius506/e/f5783cf36cb12bddd7c71524e0458dfa
- http://arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1229787524
Other links on 3310 LCD (PCD 8544) driver
- http://www.100acre.org/elec/nokia_lcd/
- http://www.quantumtorque.com/content/view/32/37/
- http://www.embedds.com/tag/nokia-3310-lcd/
- http://www.youritronics.com/build-a-cool-thermometer-using-nokia’s-3310-lcd/
- http://www.microsyl.com/nokialcd/nokialcd.html
- http://www.dharmanitech.com/2008/10/thermometer-design-using-ds1621.html














thank you.
Comment by jack manchester — June 30, 2008 @ 2:01 am
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
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
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
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
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
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
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
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
@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
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
@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
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
@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
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
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
@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
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
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
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
@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
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
That’s really cool that you shared your code with everyone, big props for that!
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.
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
Comment by Visitor — May 3, 2009 @ 5:23 am
[...] 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
@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
Someone upload pcd8544.mdf please!
Comment by atakan — May 12, 2009 @ 10:57 am
[...] LCD Nokia 3310 PCD8544 Driver in WinAVR avr gcc root fandigunawan Posted by root 2 hours 10 minutes ago (http://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
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
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
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
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
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
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