2021-06-20 10:38 AM
I am trying to read registers from an ADS8686S ADC from TI. It has the following timing diagram for register reads (from https://www.ti.com/lit/ds/symlink/ads8686s.pdf?ts=1624204868114&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FADS8686S):
The device register is 0x10, with a supposed value of 0x2002.
I have the following SPI initialization:
static void MX_SPI1_Init(void)
{
/* SPI1 parameter configuration*/
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi1.Init.NSS = SPI_NSS_SOFT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi1.Init.CRCPolynomial = 10;
if (HAL_SPI_Init(&hspi1) != HAL_OK)
{
Error_Handler();
}
}
I then have the following snippet of code for reading this register:
// Read register device id (0x10 << 9) & 0xFF00
uint8_t tx[2] = { 0x20, 0x00 };
uint8_t rx[2] = { 0x00, 0x00 };
// Send read register command
set_adc_cs(GPIO_PIN_RESET);
HAL_SPI_TransmitReceive(&hspi1, tx, rx, 2, 1000);
set_adc_cs(GPIO_PIN_SET);
// Don't care
HAL_SPI_TransmitReceive(&hspi1, tx, rx, 2, 1000);
// Receive register result
set_adc_cs(GPIO_PIN_RESET);
HAL_SPI_TransmitReceive(&hspi1, tx, rx, 2, 1000);
set_adc_cs(GPIO_PIN_SET);
I read back rx as { 0x00, 0x02}. Almost like I am getting half the register. Just really unsure of the issue at this point, and have been smacking my head against the wall.
2021-06-21 03:26 AM
Observe the signals using logic analyzer.
JW