Pages: [1]   Go Down
Author Topic: SPI multiple slaves - SD Card and another Arduino  (Read 1392 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!
I am using an Arduino Mega 2560 as a master device. Its SPI bus is connected to 2 slaves; an SD Card and an Arduino Nano v3.0.

Basically, Arduino Nano takes measurements of sensors and send them to Arduino Mega. Then, Arduino Mega sends the data to SD Card to be logged in.

If I connect each slave seperately to Arduino Mega, they work properly. However, when I connect them together, sharing the same bus, the data received from Arduino Nano is corrupted (I dispay the data on Hyper Terminal from Arduino Mega). SD Card still works properly, since the received corrupted data is logged there.

When I played with some cables, I realized that if I disconnect the MISO pin of SD Card, the data is received from Nano correctly. MISO pin of SD Card is the only pin that is connected to SPI directly. The other lines are connected via resistors to divide the voltage from 5V to 3.3V.

I would appreciate any help that will solve the problem. Do I need to connect something to MISO pin of SD Card (maybe a buffer?)?

I am using regular SS pin (53) to chip select Arduino Nano and pin 24 to chip select SD Card. I am quite sure that the SS pins are correct. (chip select -> LOW; Otherwise -> High).

Thanks!!!

Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would prefer to see your code, and your circuit. We have seen before people who are "quite certain" their circuit (or code) is correct when it isn't. No offence.
Logged

0
Offline Offline
Edison Member
*
Karma: 44
Posts: 1484
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Which SD library are you using? 

The Arduino SD.h library is a wrapper for a very old version of SdFat that I designed years ago.  It has a lot of bugs and I have totally rewritten the low level SPI/SD part.

SD cards are tricky on the SPI bus.  They require extra clocks after chip select is high to release MISO to tri-state.
Logged

Pages: [1]   Go Up
Jump to: