Part Number: ADS131M06
Other Parts Discussed in Thread: MSP430FG4619
Tool/software:
We use a lot of TI products, especially mmwave and ADS112U04IPW . We are using the ADS131M06 with our MSP430FG4619. We are stumped trying to simply read the 6 Analog ports from the ADS131m06.
void ADS131_read() { //read all 6 channels into array. Assuming default start up gain=1, 24bit data, and other default conditions so it auto converts.
unsigned int byteHigh, byteMid, byteLow; unsigned long result;
IO_LOW(P9,BIT7); // Chip Select ADS13
IO_LOW(P9,BIT4);delay1ms(); IO_HIGH(P9,BIT4); // reset to sync data ??????? is it ok to use default Reset line instead of Sync ?
i=0; while((P9IN & BIT5)&& i++<1000); if(i>950) user_debug_msg("AD NOT READY"); //wait for Data Ready to go low
SPI_transfer(0x00); //??????? send an empty command and read response to initiate the transfer.
for(jj=0;jj<6;jj++) { //read 6 channels
byteHigh = SPI_transfer(0x00); // Dummy write to read high byte
byteMid = SPI_transfer(0x00); // Dummy write to read mid byte
byteLow = SPI_transfer(0x00); // Dummy write to read low byte
result = ((long)byteHigh << 16) | ((long)byteMid << 8) | byteLow; // Combine the three bytes into a 24-bit result
if(result & 0x800000) { result |= 0xFF000000; } // Perform sign extension if the ADC uses two's complement format
a_d[jj]=result; //put result into array
} //read 6 channels
IO_HIGH(P9,BIT7); ; // Deselect ADS131
}
//---------------------------------------------------------------------
// SPI_transfer Transmits one byte over SPI and returns the received byte.
unsigned int SPI_transfer(unsigned int data) {
while (!(IFG2 & UCB0TXIFG)); // Wait until TX buffer is ready
UCB0TXBUF = data; // Send data
while (!(IFG2 & UCB0RXIFG)); // Wait for reception to complete
return UCB0RXBUF; // Return received data
}