Go Down

Topic: Using 2 SPI devices (Read 39 times) previous topic - next topic

cdb0ewm

I'm trying to write a sketch that uses an adafruit ble nrf8001 breakout for data input from my iphone and output to a MCP4261 pot chip using an Arduino Uno. I can get the adafruit / Uno communication working and the Uno / MCP chip working but I don't how to assign the 2 different pins for SS.

I'm could use some help with an example of a sketch that using 2 SS pins, one for input and one for output.

I'd really appreciate an example.  Thanks


CrossRoads


Example:

byte ssPin1 = 9;
byte ssPin2 = 10;

pinMode (ssPin1, OUTPUT);
pinMode (ssPin2, OUTPUT);

Physically, make take more effort to connect the actual pins being used.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

GoForSmoke

Tutorial: Arduino and the SPI bus
http://tronixstuff.com/2011/05/13/tutorial-arduino-and-the-spi-bus/

Nick Gammon on SPI and Arduino
http://www.gammon.com.au/spi

If you have an AVR with an open serial port, you can run master-mode SPI on that as Nick shows how.
Find USART on his blog page there, subtitle is SPI from the USART ... an alternative

When you have dedicated SPI bus for a single device or chain of devices, you only have to init once and you don't need an extra select pin, just ground select on the device. It does mean a few extra lines of code which Nick gives there.

Crossroads, that means the 1284P and the Bobduinos can be USB connected and still provide two SPI buses. It should be possible to transfer high speed data coming in on one right out to the other. The simple example would be an SD to SD file copier, the transfer would be at least twice as fast as with 2 SD's on the same bus.
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy