Pages: [1]   Go Down
Author Topic: Connecting to SPI interfaced to Arduino Mega2560  (Read 914 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
 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
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17307
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17307
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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



Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17307
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


 
Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: