I am new to programming and I am trying to obtain the inclination data from ADIS16209 from analog device. Here is the code:
Code: Select all
int HiByte;
void readADIS()
{
_SPI1IP = 4;
_SPI1IE = 1;
_SPI1IF = 0;
SPI1CON1bits.MSTEN = 1;
SPI1CON1bits.MODE16 = 1;
SPI1CON1bits.PPRE = 0;
SPI1CON1bits.SPRE = 2;
SPI1CON1bits.CKE = 1;
SPI1CON1bits.CKP = 1;
SPI1STATbits.SPIEN = 1;
_LATB10 = 0; // Set RB10 as CS pin
SPI1BUF = 0x0C; // Accelerometer's register address
_LATB10 = 1;
_LATB10 = 0;
HiByte = SPI1BUF;
_LATB10 = 1;
HiByte = (HiByte & 0b0011111111111111); //Strip off the ND and EA flags
}
http://www.analog.com/static/imported-f ... S16209.pdf