Currently trying to set up communication from my STM32L471ZETx to the ADS1261 to read load cell data. I believe I have the code structured correctly from following the example code ( https://www.ti.com/product/ADS1261#design-development##software-development) and something configured poorly since I'm receiving a response to commands sent to the ADC but the responses are only echoing the data I send (every data byte, not just the initial echo byte that should be expected). Is there anything I should be looking for or a resource I can use to troubleshoot? I've attached the setup and actual communication of the SPI, if there's anything else I can attach, let me know. Thanks in advance!
static void MX_SPI3_Init(void)
{
/* USER CODE BEGIN SPI3_Init 0 */
/* USER CODE END SPI3_Init 0 */
/* USER CODE BEGIN SPI3_Init 1 */
/* USER CODE END SPI3_Init 1 */
/* SPI3 parameter configuration*/
hspi3.Instance = SPI3;
hspi3.Init.Mode = SPI_MODE_MASTER;
hspi3.Init.Direction = SPI_DIRECTION_2LINES;
hspi3.Init.DataSize = SPI_DATASIZE_8BIT;
hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi3.Init.CLKPhase = SPI_PHASE_2EDGE;
hspi3.Init.NSS = SPI_NSS_HARD_OUTPUT;
hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi3.Init.CRCPolynomial = 7;
hspi3.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
hspi3.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
if (HAL_SPI_Init(&hspi3) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI3_Init 2 */
/* USER CODE END SPI3_Init 2 */
}
void SPITask(void *arguments) {
uint8_t transmission_buf[6] = { 0x12, 0x03, 0x00, 0x00, 0x00, 0x00};
uint8_t start_conversion_buf[2] = { 0x08 ,0x03 };
uint8_t reset_buf[2] = { 0x06,0x03 };
uint8_t receive_buf[6] = { 0x00,0x00,0x00,0x00,0x00,0x00 };
uint8_t id_buf[6] = { 0x20,0x00,0x00 ,0x00,0x00,0x00 }; //read id register
HAL_GPIO_WritePin(GPIOB, ADC1_nPWDN_Pin, GPIO_PIN_SET); //pwdn pin is high before conversions
HAL_GPIO_WritePin(GPIOB, ADC1_nRESET_Pin, GPIO_PIN_SET); //reset pin is high before conversions
HAL_GPIO_WritePin(GPIOB, ADC1_START_Pin, GPIO_PIN_SET); //start pin is high before conversions
//poll for the drdy bit
while(HAL_GPIO_ReadPin(GPIOB,ADC1_nDRDY_Pin) == 1);
for (;;) {
HAL_SPI_Init(&hspi3);
HAL_SPI_TransmitReceive(&hspi3, (uint8_t*)id_buf,(uint8_t*) receive_buf, 6, 100);
HAL_SPI_DeInit(&hspi3);
}
}