Pages: 1 ... 4 5 [6] 7 8   Go Down
Author Topic: A fast PCD8544 library (Nokia 5110)  (Read 19553 times)
0 Members and 2 Guests are viewing this topic.
Israel
Offline Offline
Sr. Member
****
Karma: 5
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not sure what could be wrong. I can't see anything obvious. The SD card module already has a voltage regulator and filter/decoupling caps.
Did you add a 100nF cap between the vcc and gnd pins of the 4050?
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

First of all let me state that I'm really new to Arduino and to this forum aswell smiley
I was really happy when I found your library. I'm using Adafruit's one but I feel it too "heavy" and resource consuming, which (considering the low memory of microcontrollers) can be frightening.

I have an Arduino Leonardo board. Following the instructions lead me to the following PIN layout:
- DC of Nokia display goes to Leonardo PIN 8
- RST of Nokia display goes to Leonardo PIN 9
- CE of Nokia display goes to Leonardo PIN 10
Here comes the tricky part. I understand that the hardware SPI pins are not mapped on Leonardo as it was used to be, but they can be found on the ICSP header. So I connected:
- DIN of Nokia display goes to Leonardo ICSP PIN 4 (MOSI)
- CLK of Nokia display goes to Leonardo ICSP PIN 3 (SCK)

Unfortunately when I upload the benchmark - nothing is shown on the Nokia display.
The device itself must be fully functional as using the previous library I still can do magic smiley

Any ideas, what am I doing wrong?

Thanks, and keep up the good work! smiley
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 5
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The pins on the Atmega32u4 (Leonardo) are mapped differently than on Atmega328p chips.
http://arduino.cc/en/Hacking/PinMapping32u4

For the configuration you described (pins 8, 9, 10), replace this part of the PCD8544_SPI.h
Code:
#define PIN_DC 0x01 // D8
#define PIN_RESET 0x02 // D9
#define PIN_CE 0x04 // D10
With this:
Code:
#define PIN_DC 0x10 // D8
#define PIN_RESET 0x20 // D9
#define PIN_CE 0x40 // D10
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

Thanks for the prompt reply! I did the mentioned changes in the PCD8544_SPI.h file, but unfortunately my Nokia screen is still dark and silent. While trying to figure out what could be wrong a question popped up in my mind. As mentioned on Adafruit's forum:

Quote
The SPI pins for the Micro, Leonardo, and Esplora (the 32u4 chip powered devices) do map the SPI pins but different than the Uno.
MISO - Digital 14
SCK - Digital 15
MOSI - Digital 16
SS - Digital 17

I could not find these references in the file above. Are they hardcoded? Should't those also be changed somewhere?
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 5
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The Library uses the chips SPI hardware, so there is no need to define which pins SPI is on. On the Leonardo you can only use the ICSP header to access hardware SPI, so the only way is to use ICSP pins 3 and 4.

Since the port/pin mapping is different between the Atmega328P and the Atmega32u4 (Leonardo) chips, you need to edit the control pins the library uses (as I mentioned in my previous post). If you did that and it still isn't working, I'm not sure why that happens. I don't have a Leonardo to try this library on, so I can't try it out and debug if there is indeed something wrong with the code.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Too bad smiley-sad
I'll try to make some investigations and/or tests but - as I'm a newbie - I doubt I'll even know what should I check first smiley

Thanks for the help anyway, I hope one day I'll be able to use your library!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I actually can't belive it but it seems my problem is solved. The solution can come in handy for someone else, so here it comes:

Adding a SPI.setClockDivider(SPI_CLOCK_DIV8); (changing SPI clock speed to 2 MHz instead of the default 4) right after SPI.begin(); in both PCD8544_SPI.cpp and SCD8544_SPI_FB.cpp put life back to the screen. It's slower than yours in the demo but it works!

If I will be brave enough I'll try to remove the 10k resistors from the CLK and DIN pins to see if it can run on 4 MHz that way, but I already turned a Nokia screen to a smoke machine before, so I'm a bit afraid.

Thank you for the awesome library, I'm really looking forward to rebuild my test projects with it! smiley
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 5
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can try using a voltage divider with lower value resistors, such as 2.2K and 4.7K to get very close to 3.3v.
Although I would still highly recommend using a voltage level shifter. A CD4050BE works well for me (there are other 4050 variants as well), but any shifter which can handle the frequency will do the job.
Logged


Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can anyone provide me a full working code of a simple Hello World at line 1 ??

Logged

Israel
Offline Offline
Sr. Member
****
Karma: 5
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
#include <SPI.h>
#include "PCD8544_SPI.h"

PCD8544_SPI_FB lcd;

void setup(void)
{
lcd.begin();
lcd.print(F("Hello world"));
lcd.renderAll();
}

void loop(void)
{
}
Logged


Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know whats wrong...

Used the code below and nothing happened, the led doesn't even blinks...

Code:
#include <SPI.h>
#include "PCD8544_SPI.h"

PCD8544_SPI_FB lcd;
int led = 13;

void setup(void)
{
lcd.begin();
lcd.print(F("Hello world"));
lcd.renderAll();
pinMode(led, OUTPUT);
}

void loop(void)
{
 digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);      
}
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 5
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As I mentioned in the OP, this library uses the SPI bus, which uses pin13 for the serial clock signal. You can't use the same pin when SPI hardware is enabled, so that is why the LED won't blink.
Logged


Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As I mentioned in the OP, this library uses the SPI bus, which uses pin13 for the serial clock signal. You can't use the same pin when SPI hardware is enabled, so that is why the LED won't blink.

My fault... I´ll check the pinout of my Nano V3 and change the SPI pin to another free one.
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 5
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can't change the pins SPI runs on, you can on the other hand add a LED with a resistor to any other non-SPI pin.
Logged


Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

TheCoolest, sorry to bloat your topic with dumb questions... Since pin13 is connected to the LED onboard, i should remove it in order to make the SPI work? Or even with the LED the SPI should work, just with the led blinking as data passes thru it?
Logged

Pages: 1 ... 4 5 [6] 7 8   Go Up
Jump to: