2021-08-23 03:56 AM
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:
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:
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!
2021-08-23 04:33 AM
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
2021-08-24 05:12 PM
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)