Go Down

Topic: Connecting to SPI interfaced to Arduino Mega2560 (Read 989 times) previous topic - next topic

vidhugop

Hi
my name is vidya . I am currently doing a project which requires two SPI interfaces to be connected to the Arduino Mega  2560 . One is an SD card and the other is a TI-CC1101 transceiver . I know that there are one set of pins for SPI interfacing in this MCU which is 50 51 52 53 . Please could any one tell me if there is an work around to this.

Vidya

retrolefty


Hi
my name is vidya . I am currently doing a project which requires two SPI interfaces to be connected to the Arduino Mega  2560 . One is an SD card and the other is a TI-CC1101 transceiver . I know that there are one set of pins for SPI interfacing in this MCU which is 50 51 52 53 . Please could any one tell me if there is an work around to this.

Vidya


Hi Vidya;

Typically one can use multiple slave devices with one SPI interface. There is just a requirement for one additional output pin for each extra device (slave select). So in your mega example pin 53 is the default slave select for a slave device, and you would be free to use pin 54 as a second slave select for the second device. Pins 50,51, and 52 would wire to both slave devices. The rest is just software.

Lefty

winner10920

There's no pin 54 btw
when you start the sd library and other it will define cs or chipselect
that one you change
the others are the spi bus,
53 is default but you can have like cs 5 for sd cs 6 for the other

retrolefty

Quote
There's no pin 54 btw


?
Pin 54 is PF.0 and certainly exists on the mega1280/2560 boards. The fact that it's also analog pin 0 on the mega boards does not prevent one from using it as a digital output pin as a additional slave select signal:

https://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0

Lefty




winner10920

Ah I didn't know that 54 == A0
that's good to know tho, so if I did digitalWrite(51, 1); it would turn on A0?

retrolefty

Quote
that's good to know tho, so if I did digitalWrite(51, 1); it would turn on A0?


Pin 51? Turn on A0?

If you first did a pinMode(54,OUTPUT); then a digitalWrite(54,HIGH) then pin 54 (also known as pin A0) would output a active +5vdc HIGH voltage. You treat it just like you would any other Arduino I/O pin.

Lefty



winner10920

Oops typo meant 54
that's awesome tho I just tried it lol

Go Up