SPI Multiple Device Comms Issue

Hi,

Having real difficulty with two SPI devices and an Arduino Mega. The first is an SD card reader (two completely different types) and an NRF24L transmitter.

I have read dozens of posts and after the entire weekend, I have decided for my own sanity, that I need to see if anyone can help.

Build as follows:

  • Arduino Mega
  • SD Card
  • NRF24L Module

When I use either the SD card or NRF24L Module individually, they work flawlessly. To prove this, I physically remove one of the devices, not changing any wiring or configuration in the sketch and which ever one is left works. This proves the SPI bus cabling configuration and CS pin configurations within the sketch.

Some of the more helpful posts I have tried:

  1. https://forum.arduino.cc/index.php?topic=360718.0

  2. http://www.vishnumaiea.in/projects/hardware/interfacing-catalex-micro-sd-card-module

  3. I have left pin 53 of the mega empty, setting the output to high

  4. All devices installed are running on external power supplies, with a smoothing capacity on the NRF24L

  5. One of my SD card modules uses logic level shifting, which on the Catalex has various posts saying it needs a mod, which I have tried in point 1 & 2

  6. I have then switched to SD card on a TFT screen (ignoring the TFT), which doesn’t use logic level shifting

  7. Being a Mega, it has plenty of SRAM and flash, so confident it’s not a memory problem

Does anyone have any advice or guidance on SPI and in particular knowledge of interfacing SD with NRF24L on the same bus?

Regards,

Christopher

From reading the forum posts it does appear that if somebody is having issues with SPI and one of the devices that is being used is an SD card module, then the problem is most likely to be with the SD card module.

The frustrating thing when debugging this type of issue is that each device works fine on its own, as you've discovered

The usual suspect in this type of scenario is the MISO signal coming out of the SD card module.

If you can post a link to the actual SD card modules you have, then you may get specific advice to help you fix the problem. However, your point (5) is likely to already be providing the answer.

Simple solution is to have MISO from the SD card go thru a part like 74HC125 with the gate controlled by the SS pin going to the SD card. That keeps MISO from being corrupted by the SD card when not selected.
Could do the same for the nrf24L01 to keep if off MISO when not selected.

markd833:
From reading the forum posts it does appear that if somebody is having issues with SPI and one of the devices that is being used is an SD card module, then the problem is most likely to be with the SD card module.

The frustrating thing when debugging this type of issue is that each device works fine on its own, as you've discovered

The usual suspect in this type of scenario is the MISO signal coming out of the SD card module.

If you can post a link to the actual SD card modules you have, then you may get specific advice to help you fix the problem. However, your point (5) is likely to already be providing the answer.

Thanks Mark - product is https://www.amazon.co.uk/gp/product/B06X1DX5WS/ref=ppx_yo_dt_b_asin_title_o06_s02?ie=UTF8&psc=1

CrossRoads:
Simple solution is to have MISO from the SD card go thru a part like 74HC125 with the gate controlled by the SS pin going to the SD card. That keeps MISO from being corrupted by the SD card when not selected.
Could do the same for the nrf24L01 to keep if off MISO when not selected.

Thanks CrossRoads, I’ll try that after work later and report back.

This thread may help you out.

CrossRoads:
Could do the same for the nrf24L01 to keep if off MISO when not selected.

The NRF24L01+ does not share the idiotic SD card 3.3V/5V translation used on many SD card modules, it is directly 5V compatible.

CrossRoads:
Simple solution is to have MISO from the SD card go thru a part like 74HC125 with the gate controlled by the SS pin going to the SD card. That keeps MISO from being corrupted by the SD card when not selected.
Could do the same for the nrf24L01 to keep if off MISO when not selected.

Thanks CrossRoads, just tested it with a 74HC125 across the MISO of the SD card and immediately both the SD and RFL24L are co-existing.

Both modules pass their "IF" statements in my sketch and the oscilloscope is showing the lines going low from the CS/SS pins. I can now continue.

I will try the RFL24L MISO as well, I can see it could give stability if I add more SPI devices.

Have a virtual beer on me!

Thanks to everyone else who contributed.

c_m_cooper:
I will try the RFL24L MISO as well, I can see it could give stability if I add more SPI devices.

How so? The NRF24L01+ tristates its MISO if not selected.

Apologies for not replying, my alerts were not configured as I thought.

In the end, the tri state buffer for the SD card solved all problems and the nRFL devices have been working seamlessly since, so I didnt need to do anything more.