AnsweredAssumed Answered

ADIS16209 SPI Interface

Question asked by tribeca23 on May 7, 2014
Latest reply on May 8, 2014 by NevadaMark

I have set up the ADIS16209 and looked at some example code for the ADIS16210 and I think that just confused the matter even more... when I wish to read data from the device I do this:

 

uint16_t readRegister(uint8_t address) {

uint16_t res;

// PULL CS LOW HERE

spi_read(0x00);

res = (spi_read(0x00) << 8);

// Wait a moment (does not seem to matter, my micro is probably slow)

res = res | spi_read(address);

spi_read(0x00);

// PULL CS HIGH HERE

return res;

}

 

*spi_read() just writes to the SPI buffer and waits for the shift register to empty then returns the result. This code works as expected:

 

uint16_t value;

// release reset line on ADIS16209

value = readRegister(0x00);

// value is 0 (but could be anything, it is undefined)

value = readRegister(0x4a);

// value is 0x0011 (the value of the ENDURANCE register (0x00))

value = readRegister(0x0a);

// value is 0x3f51 (the value of the PROD_ID register (0x4a))

 

In my code, naturally the first read is garbage but the following reads return the value of the register at address from the last read, as expected. Reading the datasheet I expected the interaction to be quite different, can you tell me where I am going wrong? What is odd to me is that the code above does work and I cannot imagine why.

Outcomes