HAL_SPI_TransmitReceive() on SPI1 of Discovery board giving HAL_BUSY
Hello STM32 community,
I'm currently working with the Discovery board and trying to implement SPI communication using the HAL library. Specifically, I am attempting to write data from the MOSI line and simultaneously read data from the MISO line using the HAL_SPI_TransmitReceive() function on SPI1.
However, I'm facing an issue where the HAL_SPI_TransmitReceive() function returns HAL_BUSY. I have verified the MOSI and MISO connections, and they are correctly wired. The SPI peripheral (SPI1) on the Discovery board is properly initialized and configured.
Here's a snippet of the code I'm using:
uint8_t txData = 0xAB; // Data to be transmitted
uint8_t rxData; // Data to be received
// Perform simultaneous transmit and receive
if (HAL_SPI_TransmitReceive(&hspi1, &txData, &rxData, 1, HAL_MAX_DELAY) == HAL_OK)
{
// Transmission and reception successful
// Process the received data as needed
}
else
{
// Transmission and reception failed
// Handle the error condition
}
I have tried increasing the delay using HAL_Delay() before calling HAL_SPI_TransmitReceive(), but it did not resolve the issue.
I would appreciate any insights or suggestions to help me understand why HAL_SPI_TransmitReceive() is returning HAL_BUSY. Is it possible to perform simultaneous transmit and receive on SPI1 of the Discovery board using this function?
Thank you in advance for your assistance.
