cancel
Showing results for 
Search instead for 
Did you mean: 

while (!LL_SPI_IsActiveFlag_RXNE(EVE_SPI)) {} Never Returns

kumaichi
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

Usually LL_SPI_Enable is called after LL_SPI_Init and before the SPI is used to move data.

 

View solution in original post

3 REPLIES 3
Pavel A.
Evangelist III

 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

 

 

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!

Pavel A.
Evangelist III

Usually LL_SPI_Enable is called after LL_SPI_Init and before the SPI is used to move data.