Pages: [1]   Go Down
Author Topic: Arduino DUE and SPI 9 bits  (Read 1443 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46265
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 18
Posts: 1173
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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^)
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23839
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 2
Posts: 49
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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

US
Offline Offline
Full Member
***
Karma: 4
Posts: 182
Electronics are the new Legos
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: