user35202: I'm trying to control AD7091-8 using Arduino Due.
This IC calls for 16 bit SPI R/W. I'd read that I can change the transmit and receive bits of Arduino DUE by changing a register (bits 4-7 of SPI_CSR). 
I was able to change the SPI of Due from 8 to 16 bits. Confirmed this by looking at SCLK and MOSI in the scope. However, the data I want to transfer is becoming intermittent.
I want to send 0x1000. On 8 bits, using the line
SPI.transfer(10,0x10,SPI_LAST);

I really can see this being sent on MOSI.
However, when I'm on 16 bits, the line
SPI.transfer(10,0x1000,SPI_LAST);

It's either becoming 0x0000 or 0x0008. I'm losing the bit or it's becoming LSB_FIRST. Not MSB_FIRST.
Below is the actual code.
#include <SPI.h>
#include "C:\Users\Smart Surface 2\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\system\CMSIS\Device\ATMEL\sam3xa\include\component\component_spi.h"
#include "C:\Users\Smart Surface 2\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\system\CMSIS\Device\ATMEL\sam3xa\include\instance\instance_spi0.h"

#define CS 10

void setup() {

  pinMode(CONV,OUTPUT);

  Serial.begin(9600);
  SPI.begin(CS);
  SPI.setDataMode(CS, SPI_MODE0);
  SPI.setClockDivider(CS,21);  

  REG_SPI0_WPMR=0x53504900;
  REG_SPI0_CR=0x1;
  SPI0->SPI_CSR[0]=0x00001580; 

  SPI.setBitOrder(MSBFIRST);
  delay(1);
}

void loop() {

  SPI.transfer(CS,0x1000,SPI_LAST);

  int a = SPI.transfer(CS,0x0000, SPI_LAST);
  delay(1000);

  Serial.println(a);
}

How can I make my data reliable and the order still with MSB first?

user35202: Found the problem on the SPI library.
When I do the command SPI.transfer, the data is stored on a byte type variable. And I'm passing a 16 bit data on it.
I've changed line 84 of SPI.h to
uint16_t transfer(byte _pin, uint16_t _data, SPITransferMode _mode = SPI_LAST);

so it will return and receive 16 bit data.
Also have to change the corresponding function on SPI.cpp (line 174)
uint16_t SPIClass::transfer(byte _pin, uint16_t _data, SPITransferMode _mode)

so they will match.
I've copied and renamed the SPI library that I've changed so it won't affect other codes.

35202: <p>I'm trying to control AD7091-8 using Arduino Due.</p>

<p>This IC calls for 16 bit SPI R/W. I'd read that I can change the transmit and receive bits of Arduino DUE by changing a register (bits 4-7 of SPI_CSR). </p>

<p>I was able to change the SPI of Due from 8 to 16 bits. Confirmed this by looking at SCLK and MOSI in the scope. However, the data I want to transfer is becoming intermittent.</p>

<p>I want to send 0x1000. On 8 bits, using the line</p>

<pre><code>SPI.transfer(10,0x10,SPI_LAST);
</code></pre>

<p>I really can see this being sent on MOSI.</p>

<p>However, when I'm on 16 bits, the line</p>

<pre><code>SPI.transfer(10,0x1000,SPI_LAST);
</code></pre>

<p>It's either becoming 0x0000 or 0x0008. I'm losing the bit or it's becoming LSB_FIRST. Not MSB_FIRST.</p>

<p>Below is the actual code.</p>

<pre><code>#include &lt;SPI.h&gt;
#include "C:\Users\Smart Surface 2\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\system\CMSIS\Device\ATMEL\sam3xa\include\component\component_spi.h"
#include "C:\Users\Smart Surface 2\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\system\CMSIS\Device\ATMEL\sam3xa\include\instance\instance_spi0.h"

#define CS 10

void setup() {

  pinMode(CONV,OUTPUT);

  Serial.begin(9600);
  SPI.begin(CS);
  SPI.setDataMode(CS, SPI_MODE0);
  SPI.setClockDivider(CS,21);  

  REG_SPI0_WPMR=0x53504900;
  REG_SPI0_CR=0x1;
  SPI0-&gt;SPI_CSR[0]=0x00001580; 

  SPI.setBitOrder(MSBFIRST);
  delay(1);
}

void loop() {

  SPI.transfer(CS,0x1000,SPI_LAST);

  int a = SPI.transfer(CS,0x0000, SPI_LAST);
  delay(1000);

  Serial.println(a);
}
</code></pre>

<p>How can I make my data reliable and the order still with MSB first?</p>
 35202: <p>Found the problem on the SPI library.</p>

<p>When I do the command SPI.transfer, the data is stored on a byte type variable. And I'm passing a 16 bit data on it.</p>

<p>I've changed line 84 of SPI.h to</p>

<pre><code>uint16_t transfer(byte _pin, uint16_t _data, SPITransferMode _mode = SPI_LAST);
</code></pre>

<p>so it will return and receive 16 bit data.</p>

<p>Also have to change the corresponding function on SPI.cpp (line 174)</p>

<pre><code>uint16_t SPIClass::transfer(byte _pin, uint16_t _data, SPITransferMode _mode)
</code></pre>

<p>so they will match.</p>

<p>I've copied and renamed the SPI library that I've changed so it won't affect other codes.</p>
