japaric / f3

Board Support Crate for the STM32F3DISCOVERY
Apache License 2.0
95 stars 35 forks source link

the led roulette example misbehaves when compiled in release mode (+LTO) #23

Closed japaric closed 8 years ago

japaric commented 8 years ago

For example, this variation of the original example:

#[export_name = "main"]
pub extern "C" fn main() -> ! {
    loop {
        for led in LEDS.iter() {
            led.on();
            delay::ms(100);
            led.off();
            delay::ms(100);
        }
    }
}

when compiled in debug mode, produces the expected result: all the LEDs light on in a circular cycle.

But if the code is compiled in release mode, then only three, the "first" three, LEDs participate in the "circular" cycle.

This is the only example that misbehaves when compiled in release mode. It also happens to be only example that uses interrupts so perhaps that's the cause of the problem.

japaric commented 8 years ago

The problem seems to be the delay::ms function. Let's try rolling that function back to use busy polling instead of interrupts.

japaric commented 8 years ago

fixed in #31 by roll backing the implementation