2026-05-20 8:32 AM - last edited on 2026-05-20 8:37 AM by Andrew Neil
I am using the Analog Devices EVAL-ADE9430 Evaluation board for testing one of their devices. The Evaluation board uses the NUCLEO-144 STM32F413ZH processor. I am using the Keil uVision development setup to run and debug code. I am specifically concentrating on the SPI Bus Driver and the timing. I have no previous experience with STM Devices and how the SPI transfers happen in the processor.
While walking through the code and following it on my scope to see the SPI Bus timing I am seeing something that does not make sense. The AFERead32BitBuffer() function is called when you read a 32-bit register from the SPI Device which is an Analog Devices ADE9430 Chip (see Below).
I am trying to understand what is causing the SPI Bus to generate the timing for this third byte when the code is only transmitting a 2 byte command header.
Thanks - mike
uint32_t AFERead32BitBuffer(uint16_t addr, uint16_t numSamples, uint32_t *pData)
{
int32_t status = SYS_STATUS_SUCCESS;
cmdBuffer[0] = (addr >> 4);
cmdBuffer[1] = ((addr & 0x0F) << 4) + 8;
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_RESET);
status = HAL_SPI_Transmit(&hSPI, (uint8_t *)&cmdBuffer, 2, SPI_TIMEOUT);
/* FIXME : Handling SPI_Transmit error*/
if (status != 0)
{
status = HAL_SPI_Transmit(&hSPI, (uint8_t *)&cmdBuffer, 2, SPI_TIMEOUT);
}
if (status == 0)
{
status = HAL_SPI_Receive(&hSPI, (uint8_t *)&pData[0], 4 * numSamples, SPI_TIMEOUT);
}
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_SET);
SwapEndian32Bit(&pData[0], numSamples);
DEBUG_MSG("REG32RD,0x%x,0x%x", addr, pData[0]);
return status;
}
2026-05-20 9:34 AM - edited 2026-05-20 9:35 AM
Hi Mike,
How is your SPI configured?
Did you enable CRC for the transfer?
2026-05-20 10:54 AM
Hi,
Yes CRC is enabled.
The SPI Clock is running at 6.25 MHz here is the contents of the hspi structure which I think has the SPI Configuration information. If not let me know what I can provide.
I took a picture of the same read with CRC is not enabled it looks to be what I would expect. The command from the processor to the ADE9430 is a 16bit wide command. Followed by four 8 bit transfers which make up the 32bit register data.
I just can't figure out how and why it is sending the 24bits as a group when CRC is enabled and the code indicates send 2 bytes.
Thanks - mike