2025-04-02 5:25 AM - last edited on 2025-04-02 5:34 AM by mƎALLEm
Hello Everyone,
I am currently configuring SPI on the STM32F765ZGT board and using both blocking (polling) and interrupt-based methods for SPI transmission and reception. However, I am encountering an issue where the following condition evaluates to true, resulting in a HAL_BUSY error:
if (hspi->State != HAL_SPI_STATE_READY)
{
errorcode = HAL_BUSY;
goto error;
}
Thank you in advance!
2025-04-02 1:21 PM
That piece of code is inside the HAL SPI functions. We need to see what YOUR code does - how and when it calls the HAL SPI functions. And which call results in the BUSY return.
Is your program using an RTOS (FreeRTOS, ThreadX, etc.)?
In general, BUSY means the HAL SPI code thinks the interface is already doing something. So (in general) look for an SPI call when the previous IT (interrupt) or DMA based SPI operation is still in progress.
2025-04-02 10:27 PM - edited 2025-04-02 10:30 PM
2025-04-03 12:38 AM
But what did you do before the call to HAL_SPI_Transmit?
2025-04-03 11:39 AM
> But what did you do before the call to HAL_SPI_Transmit?
Actually show ALL of your calls to ALL of the SPI transmit/receive functions, or at least all the ones up to the call you showed above.
2025-04-07 7:07 AM
Hello @anuj18ap
The issue arises because the SPI polling process is being called before the SPI interrupt process finishes.
To resolve this, you need to add a flag in the SPI transfer complete callback function. Then, check this flag in the main function before calling the polling process.