With C/C++ optimization level = 01 or 02, this while loop code will not work. It will become while (1);
timerdone = false;
led_timer0.p_api->start(led_timer0.p_ctrl); // required because autostart = false.
while (1) {
if (timerdone) {
break;
}
}
void led_timer0_callback(timer_callback_args_t * p_args)
{
SSP_PARAMETER_NOT_USED(p_args);
led_timer0.p_api->stop(led_timer0.p_ctrl);
led_timer0.p_api->reset(led_timer0.p_ctrl);
timerdone = true;
}
It will only work if I make optimization = 00
How can I make this while loop work with 02 optimization?
Thank you
Michael