Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 5 months ago.
Timer ses causes LPC812 lockup
I have a very simple blink program that is implemented using wait_ms and Timer. The wait_ms version (f2) works as expected while the Timer based version (f1) works for around 70 seconds and stops, i.e. the LED stops blinking.
What am I doing wrong with the Timer based code?
#include "mbed.h"
DigitalOut ledpin(P0_14);
void f1() {
Timer ledtimer;
for (;;) {
ledpin = !ledpin;
ledtimer.reset();
ledtimer.start();
while(ledtimer.read_ms() < 500);
}
}
void f2() {
for (;;) {
ledpin = !ledpin;
wait_ms(500);
}
}
int main(void) {
//f1();
f2();
return 0;
}