Go Down

Topic: SPI exchange pin? (Read 473 times) previous topic - next topic

Jérôme

Hello,
i'm working on a Arduino duemilanove. And I would like to know if it's possible to exchange some pins in the SPI protocol..?
In place of,

13      Spi Clock
12      (Datain) //not used
11      Dataout
10      Slaveselect

I would like to define:

13      Spi Clock
12      Dataout
11      Slaveselect1
10      Slaveselect2
7      (Datain)

I just try to exchange Datain and Dataout,... but the Dataout signal don't seems to work in this configuration on my oscilloscope,...?

Any Idea?
thanks

wayoda

Hi Jerome.

No, this is not possible when using the Hardware SPI feature of the ATMega.

But if you don't need to read back any data through the DataIn-pin you can code the SPI-Protocol in software by simply toggling any pin you like.
It will be much slower than the Hardware SPI (Clock is in the 100Khz range), but you have full control of the pins used.

I did this for a SPI-driven LCD http://code.google.com/p/doglcd/
and for a LedMatrix driver chip http://www.arduino.cc/playground/Main/LedControl

Its fast enough for these two projects

Eberhard

Jérôme

Thank you for your reply.

Indeed, impossible to exchange spi pin of places (13,12,11,10),...except that you can add more than one slave select on the desired pin you want.

and if you dont use the MOSI or MISO pin, you can assign it for another use.

right?

thanks.

wayoda

Quote
indeed, impossible to exchange spi pin of places (13,12,11,10),...except that you can add more than one slave select on the desired pin you want.

Yes, you can use any other digital pin to select the slave you want to talk to.
Quote

and if you dont use the MOSI or MISO pin, you can assign it for another use.

No, the MOSI and MISO pins are not available for "normal" IO when you activate the Hardware-SPI module.

Eberhard

Go Up