This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Optimization Level 03 - Cortex M-4

Hello,

could someone explain to me why -if(EXTI0Flag)- is optimized in level-03 in a different way when it is inside the while(1) or outside ?

(when outside everything works fine but inside the while, it´s always true, even when EXTI0Flag = 0)

volatile int8_t EXTI0Flag = 0;
int main(void)
{
    /* Juego de luces de inicio de programa - se ha cargado correctamente en elµC */
    Test_Leds_Ini();
    printf("Testing printf .....");
    BUTTON_initialize();

    while(1)
    {
        /* Infinite loop - only interruptions enabled */
        if(EXTI0Flag)
        {
            delay_ms(500);
            EXTI0Flag = 0;
            led_OFF(GPIO_Pin_9); //Led Azul
        }
    }
}