SPI troubles, pull up/down?

Hey, I’m originally from a programmers perspective so if any of you electro-wizards could help me out I would be grateful.

My current setup is pretty basic with an mfrc522 and a sd card reader sharing sck, miso and mosi with mfrc522 using the SS pin (10) and the sd card reader using pin 9.
For reasons that are magic to me this works when i try either component alone, but when i do them together things start acting weird.

I am able to read from sd and then the mfrc522, but if i try to read from the sd card again it wont connect. If i restart the Arduino the problem remains, and I am still unable to connect to the sd reader. I have to physically remove power from the sd reader to “reset” it.

To me a line is either powered or not (digital yay!) but it appears that isn’t always the case(?). I’ve tried to read up on these things but honestly its all new territory to me and terribly slow. I think this could be solved with a pull up/down resistor or two somewhere, but why and where i have no clue.

If any of you guys have a solution and/or some pointers to where i could learn this powerful magic that would be really cool.

Thanks!

To me a line is either powered or not (digital yay!) but it appears that isn't always the case(?).

No, there is a third state, so called high impedance. In this state it acts as if it isn't connected. Usually any SPI device who's CS line is HIGH should set it's MISO pin into high impedance state.

I think this could be solved with a pull up/down resistor or two somewhere, but why and where i have no clue.

I don't think so. I guess that any of the two devices doesn't handle the SPI bus interface correctly, it's not easy to find out which one it is.

Start by providing links to the hardware you're using. Maybe we know some fo them and are able to tell you which one should be replaced. In the past I had a case where the SD card reader (a cheap Chinese part) was the problem but it may be on the mfrc522 board.

phenalor: Hey, I'm originally from a programmers perspective so if any of you electro-wizards could help me out I would be grateful.

My current setup is pretty basic with an mfrc522 and a sd card reader sharing sck, miso and mosi with mfrc522 using the SS pin (10) and the sd card reader using pin 9. For reasons that are magic to me this works when i try either component alone, but when i do them together things start acting weird.

I am able to read from sd and then the mfrc522, but if i try to read from the sd card again it wont connect. If i restart the Arduino the problem remains, and I am still unable to connect to the sd reader. I have to physically remove power from the sd reader to "reset" it.

To me a line is either powered or not (digital yay!) but it appears that isn't always the case(?). I've tried to read up on these things but honestly its all new territory to me and terribly slow. I think this could be solved with a pull up/down resistor or two somewhere, but why and where i have no clue.

If any of you guys have a solution and/or some pointers to where i could learn this powerful magic that would be really cool.

Thanks!

Check that both the MFRC552 and the Sdcard use the same SPI mode.

you might need to change your code to reconfigure the SPI bus before switching to each device.

SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0)); //correct speed, bit order, mode

sdCard(); // sdcard function calls

SPI.endTransaction();

SPI.beginTransaction(SPISettings(4000000, LSBFIRST, SPI_MODE2)); // use correct speed and mode for other device
digitalWrite(CS,LOW);
SPI.write();
...
digitalWrite(CS,HIGH);
SPI.endTransaction();

Depending on your sdCard library, it might already include the SPI.beginTransaction() SPI.endTransaction() calls internally.

Also, verify that you have adequate power for your devices, a sdCard can use 200~300mA during writes.

Chuck.