Go Down

Topic: Arduino DUE and SPI 9 bits (Read 1 time) previous topic - next topic

duayfabi

Hello,

I want use the functionality of the arduino DUE to send 9 bits SPI data.

I havn't found anything in your SPI documentation about the SPI data length..

Any hint for me?

Thanks and regards,

Fabien D.

PaulS

What function would you actually be using to transfer the data? Perhaps there's a clue in the data type.

KeithRB

You might have write your own code to do it manually, and not depend on libraries or hardware. 8 bit bytes are pretty well ingrained nowadays. 8^)

Nick Gammon


I want use the functionality of the arduino DUE to send 9 bits SPI data.


Why do you want to? For what device? Link to datasheet please.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

CrossRoads

You will have to "bit bang" 9 bits - SPI uses internal 8 bit register to output 8 bits.
Or send out 16, first 7 as don't cares and the final 9 as the keepers, if your device will ignore them and just latch the last 9 on CS/SS going high.
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.

bobcousins


I want use the functionality of the arduino DUE to send 9 bits SPI data.

I havn't found anything in your SPI documentation about the SPI data length..

Any hint for me?



The SPI peripheral in the SAM3X can do 9 bit transfers, but this is not supported by the SPI library. It would be very easy to add though.
Please don't PM me asking for help. Ask questions in the forum.

duayfabi



The SPI peripheral in the SAM3X can do 9 bit transfers, but this is not supported by the SPI library. It would be very easy to add though.




Exactly, in the SAM3X datasheet, on page 679, you can read :

- 8- to 16-bit Programmable Data Length Per Chip Select

My question was on the implementation of this functionality in the new arduino framework.
In the documentation, nothing is said about this but perhaps the doc isen't up to date...

I will see to add it myself.

Thank you.

TheKitty

Moderator Gammon asks what is the application for 9 bit SPI and asks for data sheets.

A common application is for graphic LCDs where the 9th bit is clear for a data byte and set for a command byte.  Two displays using this are:
http://adafruit.com/products/797 and http://adafruit.com/products/358

It would be a well received extension to the current library (documentation at http://arduino.cc/en/Reference/DueExtendedSPI) if this type of addressing could be accommodated for rather than a bitbanging method.

Several AVR libraries exist - they mostly turn off the hardware SPI, toggle the line manually if needed and clock, then turn it back on.  This is very hard to do if one is using the SPI library, the functionality is not exposed.

If this cannot be accomplished, there is some code for bitbanging the SAM in a way similar to the AVR but it has not been ported to a tidy library.  Tom Carpenter's gLCD libary appears to do this.

Go Up