cancel
Showing results for 
Search instead for 
Did you mean: 

No while loop shown in tutorials in main.c

CHech.1
Associate III

Hi,

I've seen that in many stm32 tutorials (such as blinking LED and uart tutorials) they make use of a "while (1) " loop located in main.c: 0693W00000Dq5C4QAJ.png 

But, in the main.c generated by cubeMX for my stm32l496ag board i have only the following single while loop, which is indeed never reached:

0693W00000Dq5KHQAZ.png 

Why is that? is this a case of a newer version? If so, where can I find a similar loop to write ,for example, the blinking LED code in?

Thank you!

2 REPLIES 2
Peter BENSCH
ST Employee

The tutorials you cited usually work without an RTOS, while you work with an RTOS (FreeRTOS) in your CubeMX project. This RTOS starts after initialization with osKernelStart() and then typically remains in the scheduler loop, so that it never gets to the while loop (on line 192). For first attempts with the STM32, you should initially do without an RTOS until you know how everything works.

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Pavel A.
Evangelist III

Also, the compiler can use the while(1) as a hint that main() never returns, and so can optimize out few code bytes.

(GCC has a better way to express this hint)