Loading...
 
Skip to main content

System Workbench for STM32


SW4STM32 doesn't move to main loop

Another way you can force the inclusion of the infinite while() loop (with optimization on) would be to declare the i variable volatile, like this:

volatile uint32_t i;
while (1)
{
i++;
}

Doing this is also useful when you want to create a software delay and don't care about accuracy, like this:

volatile uint32_t i;
for (i = 100000; i > 0; i--) ;

As for use of compiler optimization, I normally set the optimization level to "optimize for debug (-Og)" for the debug build of my projects, and use higher level optimization, normally "optimize for size (-Os)" for the release build.