2024-01-25 11:06 AM
I'm trying to use SPI to communicate with a display (BT817) and whenever it tries to send data, the while (!LL_SPI_IsActiveFlag_RXNE(EVE_SPI)) {} never returns. I've attached my CUBE IDE project. Could anyone possibly give some guidance? Am I missing a setting, have the clock misconfigured? The board has a STM32F030R8Tx.
Kindest regards
Solved! Go to Solution.
2024-01-25 01:36 PM - edited 2024-01-25 01:40 PM
Usually LL_SPI_Enable is called after LL_SPI_Init and before the SPI is used to move data.
2024-01-25 11:57 AM
> the while (!LL_SPI_IsActiveFlag_RXNE(EVE_SPI)) {} never returns.
This is because the while loop in C language will loop until the expression becomes false. If it never becomes false, the loop will be endless. What you can do to avoid endless loop:
1. Add timeout check: while ((condition) && !timeout_expired(...)) {} or while (condition) { if (timeout_expired(...)) break; }
2. Add a software or hardware watchdog
2024-01-25 12:07 PM
Thanks for the reply and explanation. I actually got it to work, I was missing the call to, LL_SPI_Enable(EVE_SPI). Which leads me to my next question, in the main.c file, it initializes the SPI via, MX_SPI1_Init() but it won't work until I call the LL_SPI_Enable method. At which point should I make the call to, LL_SPI_Enable(...)?
Thanks!
2024-01-25 01:36 PM - edited 2024-01-25 01:40 PM
Usually LL_SPI_Enable is called after LL_SPI_Init and before the SPI is used to move data.