Go Down

Topic: How SPI works with SD Card with Leonardo (Read 1 time) previous topic - next topic

ScottG

I've used the Ethernet shield with a few Arduino projects, but I've never used the SD card.  I'm looking at a project where I want to use a Leonardo with Ethernet connection and the SD card. I've been doing some reading and I want to make sure I understand how this works.

If I was using an UNO instead of Leonardo, I would need to use digital pins 11, 12 & 13 for SPI communication.  Pin 10 and pin 4 would be reserved for CS for the Ethernet and SD Card respectively.

But the Leonardo his separate SPI pins, it doesn't use digital pins 4, 10, 11,12, 13 to communicate with the Ethernet shield and SD card.

So, to use both the Ethernet and SD card with a Leonardo, do I need to do anything special?  I read on this forum that to enable software SPI, I need to change #define LEONARDO_SOFT_SPI 1 in SdFatConfig.h.  I'd appreciate any tips and best practices for this configuration.


PaulS

Quote
So, to use both the Ethernet and SD card with a Leonardo, do I need to do anything special?

As long as the Ethernet shield has the ICSP (6 pin) connector on the bottom, no.

Quote
I read on this forum that to enable software SPI, I need to change #define LEONARDO_SOFT_SPI 1 in SdFatConfig.h

So? Why do you think you need to use software SPI when there is a perfectly good hardware SPI available?

ScottG


Quote
I read on this forum that to enable software SPI, I need to change #define LEONARDO_SOFT_SPI 1 in SdFatConfig.h

So? Why do you think you need to use software SPI when there is a perfectly good hardware SPI available?


I  want to free up some I/O pins so I can use them for sensor inputs.

PaulS

Quote
I  want to free up some I/O pins so I can use them for sensor inputs.

How is software SPI going to accomplish that?

ScottG


Quote
I  want to free up some I/O pins so I can use them for sensor inputs.

How is software SPI going to accomplish that?


I assumed that using software SPI would free up pins 4,10,11,12 & 13.  But based on your questions, I'm starting to think these pins are freed up anyway and being able to use them for my sensors isn't linked to hardware/sofware SPI setting.  is that the case?


PaulS

Quote
is that the case?

The way I read it, hardware SPI does not use pins 11, 12, and 13 on the Leonardo. Pins 4 and 10, the slave select pins, are still used. Software SPI would tie up several pins, though not necessarily 11, 12, and 13.

I'm not convinced that software SPI is suitable for the Ethernet shield, since it is hardwired to the SPI pins.

ScottG


Quote
is that the case?

The way I read it, hardware SPI does not use pins 11, 12, and 13 on the Leonardo. Pins 4 and 10, the slave select pins, are still used. Software SPI would tie up several pins, though not necessarily 11, 12, and 13.

I'm not convinced that software SPI is suitable for the Ethernet shield, since it is hardwired to the SPI pins.


Okay, I get it now.  I'm glad you told me I still need to reserve pins 10 and 4 the CS.

Go Up