Other Parts Discussed in Thread: TMS320F280049
Tool/software:
I’m working with a TMS320F280049 to interface with an ADS1256. I’ve configured the F280049’s SPI for Mode 1 at 1 MHz, without using FIFO or interrupts, but I’m unable to read any ADS1256 registers correctly—even though my logic analyzer traces look reasonable, the ADC keeps returning spurious data. Below are my initialization code and the function I’m using to read a register:
void ADS1256_writeRegister(uint8_t reg, uint8_t value) { CS_LOW(); while (GPIO_readPin(ADS1256_DRDY_GPIO)) ; SPI_writeByte(ADS1256_CMD_WREG | (reg & 0x0F)); SPI_writeByte(0x00); // write one register SPI_writeByte(value); CS_HIGH(); } static void ADS1256_sendCmd(uint8_t cmd) { CS_LOW(); SPI_writeByte(cmd); CS_HIGH(); } void ADS1256_init(void) { while (GPIO_readPin(ADS1256_DRDY_GPIO)) ; CS_LOW(); SPI_writeByte(ADS1256_CMD_SELFCAL); while (GPIO_readPin(ADS1256_DRDY_GPIO)) ; CS_HIGH(); ADS1256_writeRegister(ADS1256_STATUS, 0x06); ADS1256_writeRegister(ADS1256_ADCON, ADS1256_PGA_GAIN_1); ADS1256_writeRegister(ADS1256_DRATE, 0x23); ADS1256_writeRegister(ADS1256_IO, 0x00); while (GPIO_readPin(ADS1256_DRDY_GPIO)) ; CS_LOW(); SPI_writeByte(ADS1256_CMD_SELFCAL); while (GPIO_readPin(ADS1256_DRDY_GPIO)) ; CS_HIGH(); } uint8_t ADS1256_readRegister(uint8_t reg) { uint8_t val; ADS1256_sendCmd(ADS1256_CMD_SDATAC); while (GPIO_readPin(ADS1256_DRDY_GPIO)) ; CS_LOW(); SPI_writeByte(ADS1256_CMD_RREG | (reg & 0x0F)); SPI_writeByte(0x01); // read one register DEVICE_DELAY_US(50); // val = SPI_receiveByte(ADS1256_SPI_BASE, 0x00); // val = SPI_receiveByte(ADS1256_SPI_BASE, 0x00); CS_HIGH(); return val; }
I ran the ADS1256_readRegister()
function inside a loop, and the results are shown in the figure below:
In the figure above, the MISO data stream is irregular. Instead of the two expected bytes from the registers I’m reading, the output appears garbled.
Zooming in on the capture, the SPI commands and data bytes sent by the master look as expected, but the data coming back from the ADS1256 remains garbled: two valid register bytes never appear on MISO.
Thank you in advance for assistance!