SPI outputing 16 bits with a continuous clock

I am trying to send out 16 bits of data with the SPI library.

the problem is the hardware requires an additional clock cycle at the end of a data transfer
after the SS is switched to HIGH.

the code i'm currently working with is

digitalPotWrite(int address,int value)
{
delay(1);
digitalWrite(slaveSelectPin,LOW);

SPI.transfer(address); //Most significant 8 bits
SPI.transfer(value); //Least significant 8 bits

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'm a beginner at this so I apologize but I need a little clarification on that. And yes that was a typo, the last part should be:

digitalWrite(slaveSelectPin, HIGH);

however, the point is to have the additional clock cycle happen after I switch to HIGH.

What is pin D13 and what do you mean by take it high/low as needed.

Again I apologize for not understanding but I am quite new at this.

D13 is the clock pin that you need to pulse to give the device the extra clock it apparently needs, but

the problem is the hardware requires an additional clock cycle at the end of a data transfer

This is unusual, can you point to the device you're interfacing to.

after the SS is switched to HIGH.

Also very unusual because it means you can never have any other devices on the SPI bus.


Rob

Exactly as Graynomad said.

http://camtech.com/products/servos/DC2000%20Digital%20Servo.html

this is the part that I am interfacing too.

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

The pins I am using are:

SS - 48
CLK - 51
MISO - 52

4 Options then.

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

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

  2. Find some hardware that doesn't have odd after the transfer is over clock requirements.

I can't change the hardware and I need this to be as time efficient as possible.

Option 3 sounds like the best one for me.

if you could offer some guidance or a link for how I can go about this I would greatly appreciate it.

Again, I am new working with arduinos, but I'm quite familiar with coding in C.

PM fat16lib, ask him about his software SPI library, I don't see it listed here
http://code.google.com/p/beta-lib/downloads/list