Hello everyone,
I ran into a bit of an odd (and also annoying) problem. I spent a couple hours trying to fix it, as I was convinced I was doing something wrong myself (that’s still very possible), but I ran out of ideas. So, here I am documenting what I’ve got and asking for help! To be clear, the problem does not occur at all when compiling on mbed.com, only through platformio. Hopefully you guys have some idea what is going on and can help me!
Environment
- OS: Arch Linux x86-64bit
- Python version 2.7.14 (version 3.6.4 also installed on system)
- Platformio version 3.5.0 (possibly occurs on older versions too, did not test)
- Toolchain versions:
- teensy @ 2.9.0
- framework-mbed @ 4.50701.0
- tool-teensy @ 1.21.0
- toolchain-gccarmnoneeabi @ 1.60301.0
platformio.ini
[env:teensy31]
platform = teensy
board = teensy31
framework = mbed
Code
#include "mbed.h"
DigitalOut myled(LED1); // Onboard LED
void step(){
myled = !(myled);
}
int main() {
Ticker t;
t.attach(&step, 0.1);
while(1) {
wait(1); // changing this duration seems to affect pattern of misbehaviour
}
}
Click here for github repo, and here for mbed repo.
Expected behaviour
Regular blinking of the LED, toggling once every 100ms.
Observed behaviour using mbed online compiler
Regular blinking of the LED at 100ms, as expected.
Observed behaviour using platformio
Irregular blinking of the LED, seemingly switching between two different modes, one where the LED toggles every 100ms as expected, and one where the LED toggles at extremely high frequency (measured period of around 8µs).
Measurement from logic analyzer
Pattern visible over 10 seconds. Low frequencey square wave indicates correct behaviour, high frequency sqaure wave (so high it shows as solid gray on this zoom level) is incorrect behaviour. This pattern seems to repeat indefinitely.
Close-up of start of first period of incorrect beahaviour (high-frequency square wave).
I am guessing that is enough information for now. Hopefully somebody will know what’s up.
Thanks for your time!
Arjen