digitalWrite(slaveSelectPin,LOW);
//need extra clock cycle here
SPI.transfer(value); // trick to send additional clock cycle, works but inefficient
)
is there any way to send an additional clock cycle on the arduino?
or simply set the clock to be running at all times and then synchronize the data transfer.
Also if this requires some assembly work, how can I look at and edit the assembly of this program
After your value transfer, do
SPI.end();
pinMode (D13, OUTPUT);
then take D13 high/low as needed
finish with
digitalWrite(slaveSelectPin, HIGH); (// not LOW as your code shows - unless that is the problem?
and reset SPI for next time
SPI.begin();
I know it is weird, and the datasheet doesn't give you much information.
My boss was on the phone with the engineer that designed this for quite a while and that is what he found out.
-SS goes low
-16 bits are transferred in
-SS goes high
-one extra clock cycle registers the transfer to the device
Do it the way you are doing it now. The 1 extra SPI transfer costs next to nothing in terms of software, and can complete the 7 wasted clocks while your software is off startin the next task.
2 Run a bunch of extra instructions to take control of the Clock pin after the SPI transfers are done.
Write your own shiftout variation to do the 16 bits, change the SS line, do the 17th bit.
fat16lib has written a direct port access version of shiftout that is supposed to be quite fast.
Find some hardware that doesn't have odd after the transfer is over clock requirements.