Sorry NevadaMark, I meant to say that the code I have written (as in the above post) works correctly (or at least it returns the values I expect from the datasheet). I did not expect it to be correct based on the information in the datasheet, from the datasheet I expected to do this:
uint16_t readRegister(uint8_t address) {
uint16_t res;
// PULL CS LOW HERE
res = (spi_read(address) << 8);
res = res | spi_read(0x00);
// PULL CS HIGH HERE
// Wait for Stall Time
return res;
}
But this does not work. Also, the example code for the ADIS16210 does not seem to return the correct values:
short int read_reg(unsigned char address) {
short int data;
short int hi_byte, lo_byte;
GP2DAT &= ~0x00010000; // lower !CS pin
// send address (1st two bytes)
spi_rw(address);
spi_rw(0x00);
delay_us(45); // stall time is 40us on adis16210 with normal mode
// send dummy bytes for data
hi_byte = spi_rw(0x00);
lo_byte = spi_rw(0x00);
GP2DAT |= 0x00010000; // raise !CS pin
data = (hi_byte << 8) + lo_byte;
delay_us(45); // stall time is 40us on adis16210 with normal mode
// return data read from device at 'address'
return data;
}
I did wait for initialisation after reset but thank you for pointing that out.