SPI pin control

Two pro mini’s sharing a sd card reader. Number 1 can read the card and do it’s task when number two is powered off. Both are hard wired to the sd card reader. The second arduino can write to the sd card if I set all spi pins to inputs on the first arduino. The question is how to return the spi pins on the first
arduino to their spi function without rebooting it.

Does it help if you use the SPI begin() and end() functions to turn off SPI when you are not using it?

If they are hardwired you must always power both the Arduino's together to prevent phantom-powering via the shared connections.

I will try that today. One thing I have found is the onboard led being on the serial clock pin prevents it from going into a high impedance state. Seems like an odd design decision to put it on a pin that can’t be changed but easily fixed by removing the led.

you can try maybe placing diodes on the lines for shared usage

Here’s what works. I used the get card info example to test. I hard wired 4 spi pins together on each card. I removed the led on 13 because it’s on the serial clock pin. I am using a 3V card reader that is always powered on connected to both audrino’s spi pins. At the end of the get card info sketch I did a spi stop and then pin mode input to 10, 11, 12 and 13 which are the spi pins I used. This works if both arduino’s are powered or just one is. There’s a parasitic current draw of 2 milliamps to the powered down audrino which I can ignore as total draw with one on and one off is 15 milliamps. Thank you for your help.

Larry

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.