Go Down

Topic: Nokia 5110 works until I add SD library (also SPI) (Read 4 times) previous topic - next topic

synfinatic

Oops, shoulda done a full test I guesss.

Turns out there's a 4th step:

4. You may also need to edit SD/SD.cpp to lower the SPI speed since the LCD max speed is 4.0Mhz and the SD default speed is 1/2 clock rate, so for the Arduino Uno which has a default clock rate of 16Mhz you need to drop the SPI speed to 1/4 clock:

Code: [Select]
boolean SDClass::begin(uint8_t csPin) {
  /*

    Performs the initialisation required by the sdfatlib library.

    Return true if initialization succeeds, false otherwise.

   */
  return card.init(SPI_QUARTER_SPEED, csPin) &&
      volume.init(card) &&
      root.openRoot(volume);
}


I will say I'm kinda disappointed in many of the Arduino libraries... I know they're designed to be easy to use, but there are so many hard coded values (which pins to use, speeds, etc) it really makes it hard to consider them as "reusable" across multiple projects.  Not to mention for SPI related libraries, it would be nice to see a consistent use of hw vs. sw SPI to reduce the number of pins required without significant debugging & hacking.  Not to say I don't appreciate the effort the library authors have put in (after reading the data sheet for the LCD I'm amazed anyone can figure out how to program it), but I guess it would be nice if the Arduino community came up with a set of standards for how libraries should be configured that authors could follow.

Go Up