0

I am trying to use both an SRAM (23LC1024) and SD card reader on an SPI bus.

My connections (for SPI):

  • Arduino pin 11 (MOSI) -> SRAM pin 5 (SI/SIO0)
  • Arduino pin 12 (MISO) -> SRAM pin 2 (SO/SIO1)
  • Arduino pin 13 (SCK ) -> SRAM pin 6 (SCK)
  • Arduino pin 10 -> SRAM pin 1 (CS )

In this way, I can read data from the SRAM.

To connect the SD I connected:

  • SRAM pin 2 (SO/SIO1) -> SD MISO
  • SRAM pin 5 (SI/SIO0) -> SD MOSI
  • SRAM pin 6 (SCK ) -> SD SCK
  • Arduino pin 9 -> SD CS

Currently the SD card works, but read-byte commands to the SRAM always gives the same (wrong) value.

If I remove the wire between SRAM pin 2 and SD MISO the SRAM gives correct values, but the SD card does not have a MISO connection and seems to always return the same data (but still functions).

I also tried to first make the connections from the Arduino to the SD and than to the SRAM (but same result, not working).

What am I doing wrong?

Update: The problem is solved, however I do not understand why. I reconnected all pins, removed the shield to access the SRAM directly which worked. Than I put the shield back on (and moving the pins back) ... maybe it was something stupid that one pin did not have good contact. I'm sorry for the inconvenience.

New question (related):

Now it works with the Data logger shield, but not with the (cheap) SD reader breakout cards.

However, my eventual solution needs more proto space than is available on the Data logger shield.... do I really need to use a complete shield (and later the Arduino Mega), and a Mega proto shield ... that will be a big box. While for the data logger, I don't need the RTC neither.

0

1 Answer 1

3

It doesn't sound like you are doing anything wrong as such, it all sounds fine.

However SD cards, certainly some cheap ones, don't like to play nicely with other devices on a shared bus. Also some SD card adapters with level shifting don't play nicely.

By not playing nicely I mean tri-stating the MISO line in a timely fashion (or at all in some cases) which stops any data getting out of other devices, and can even cause damage in some cases.

You should check out the level shifting on the SD card adapter to see if it has tri-stating control of MISO (if it is shifting that line, not all do), try other brands of SD cards, and maybe add your own tri-state buffer to the SD card signals.

10
  • 1
    It is for this reason I always use an SD card on a dedicated SPI bus rather than sharing it.
    – Majenko
    Apr 9, 2017 at 8:58
  • Mine is very cheap so maybe that is the reason. I'm new to electronics, but how should I check the level shifting of the adapter if it has tri-stating? I don't have an oscilloscope ... I have one other SD card. Also I have an SD protoshield, but that one is so huge, I definitely do not want to use it in a prototype. Apr 9, 2017 at 11:43
  • 1
    Without a scope you can guess and try. It is the harder way to do this. For example, in your case we can disconnect the MOSI pin from the SRAM and see if we then can talk to the SDCard. To verify we can replace the SRAM's MOSI pin and disconnect the MOSI from the SDCard and verify we can talk to the SRAM.
    – st2000
    Apr 9, 2017 at 12:25
  • 1
    Arduino's now are made with many different processors. Some have more hardware (more SPI buses) than others. Also, there are now many Arduino libraries some which might emulate a SPI bus. However, such libraries usually run slower than hardware and such libraries usually place a heavy burden on the processor not leaving much time to do other things.
    – st2000
    Apr 9, 2017 at 12:28
  • 1
    I work almost exclusively with PIC32. Some have 4 or more SPI buses. You need the schematic of your SD adapter.
    – Majenko
    Apr 9, 2017 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.