Go Down

Topic: Using a SPI SD card reader and an SPI screen (Read 487 times) previous topic - next topic

Buleste

I have a project where I want to use a LCD that is SPI (in this case PCD8544) and be able to access an SD card. I'm using different CS pins (10 for the SD reader and 5 for the screen).
Most the time things work fine together but at other times there are issues, for example I will have to select a folder twice, or the screen just displays a black line when I attempt to access a certain folder.
I know there is nothing wrong with the SD card or the reader because I can use an I2C display with the same project and it works perfectly.

I'm trying this with both a Nano and a Mega 2560 so it's not a low memory issue either.

Can anyone help or give me pointers on using two SPI devices?

CrossRoads

Might want to review your code and confirm that one chip select is high before the other one goes low.
Also, some SD cards can be poor about releasing MISO when they are deselected, having a gated buffer (like a 74AHC125) where the gate is connected to chip select will ensure MISO is not active when chip select is not active.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Buleste

Okay.
I've tried tagging my SD card CS as LOW because with HIGH the SD Card reader failed to start. but still have the same issues.

Here is the relevant bit of code.
Code: [Select]
pinMode(chipSelect, OUTPUT);      //Setup SD card chipselect pin
  #ifdef P8544
    digitalWrite(chipSelect,LOW);
  #endif
  if (!sd.begin(chipSelect,SPI_FULL_SPEED)) { 
    printtextF(PSTR("No SD Card"),0);
  return;
  }


Now I've checked the pcd8544 library that I use and it sets the CS pin as LOW. Tried changing that to HIGH and the screen doesn't work.

Go Up