Multiple Spi devices with Arduino mega

Thread Starter

Karavela

Joined Jul 6, 2022
13
I made can bus(mcp2515) and datalogger with Arduino mega. Since they both use spi to communication, I separated the cs pins and connected them to sck, miso, mosi. Can bus worked but sd didn't work. I tried with microsd module. Sd card working, this time can bus is disabled. what do you think is the problem?
 

d67830

Joined Mar 25, 2018
1
I made can bus(mcp2515) and datalogger with Arduino mega. Since they both use spi to communication, I separated the cs pins and connected them to sck, miso, mosi. Can bus worked but sd didn't work. I tried with microsd module. Sd card working, this time can bus is disabled. what do you think is the problem?
You have made sure to update the sketch for the can bus and the sd card to reflect the selected CS pins for each of them?
Which pins are you using?
 

Thread Starter

Karavela

Joined Jul 6, 2022
13
I solved the problem. It is a problem caused by the sd card module. The SD card continuing to run miso even when CS is not active. I'm thinking of solving it using a tristate buffer IC. (like 74HC126) Is there an IC you can recommend?
 

nsaspook

Joined Aug 27, 2009
13,279
I solved the problem. It is a problem caused by the sd card module. The SD card continuing to run miso even when CS is not active. I'm thinking of solving it using a tristate buffer IC. (like 74HC126) Is there an IC you can recommend?
Sometimes you can fix this by sending the SD card a dummy byte and clocks to flush the buffer after SD access before a CS high.
C:
data=SPI.transfer(0);
 

Thread Starter

Karavela

Joined Jul 6, 2022
13
I'm still a beginner. Is it okay if I add this to the end of the sd code? Will the miso pin be disabled?
 
Top