Other Parts Discussed in Thread: ADS1220, CC2640
Tool/software: Code Composer Studio
Hello,
I have been trying to interface ads1220 with cc2640 launchpad. When I am connecting to ground the AIN2, values received by me are:
SPI Initialized!
Sample 0: 255
Sample 1: 255
Sample 2: 255
Sample 3: 255
Sample 4: 255
Sample 5: 190
Sample 6: 190
Sample 7: 190
Sample 8: 190
Sample 9: 190
Sample 10: 255
Sample 11: 255
Sample 12: 255
Sample 13: 255
Sample 14: 255
Sample 15: 255
Sample 16: 255
Sample 17: 255
Sample 18: 255
Sample 19: 255
SPI closed!
Basic interfacing code is as follows:
uint16_t sample;
//uint16_t temperature;
uint8_t txBuffer[] = {0x43,0xA1,0x04,0x00,0x02} ;
uint8_t rxBuffer[20];
GPIO_init();
SPI_init();
Display_init();
SPI_Handle handle;
SPI_Params params;
SPI_Transaction transaction;
display = Display_open(Display_Type_UART, NULL);
if (display == NULL) {
while (1);
}
Display_printf(display, 0, 0, "Starting the Ads1220 example\n");
// Init SPI and specify non-default parameters
SPI_Params_init(¶ms);
params.bitRate = 1000000;
params.frameFormat = SPI_POL0_PHA1;
params.mode = SPI_MASTER;
// Configure the transaction
transaction.count = sizeof(txBuffer);
transaction.txBuf = txBuffer;
transaction.rxBuf = rxBuffer;
// Open the SPI and initiate the first transfer
handle = SPI_open(Board_SPI_MASTER, ¶ms);
if (handle == NULL) {
Display_printf(display, 0, 0, "Error Initializing I2C\n");
while (1);
}
else {
Display_printf(display, 0, 0, "SPI Initialized!\n");
}
for (sample = 0; sample < 20; sample++) {
if(SPI_transfer(handle, &transaction))
{
Display_printf(display, 0, 0, "Sample %u: %d",
sample, rxBuffer[sample]);
}
else {
Display_printf(display, 0, 0, "I2C Bus fault.");
}
sleep(1);
}
SPI_close(handle);
Display_printf(display, 0, 0, "SPI closed!");
return (NULL);
}
Chip select pin is low throughout the proces.