This code is tho put in evidence a BUG in the TIMER implementation on Nordic TIMER bug nRF51822. This Example was created for plateform nRF51-DK. Led 2 will stop blinking (crashed main) when user button is pressed several time. User button start an interrpt, the interrupt set a tickker timer 200ms laterthe change LED 1. Meanwhile in the main loop LED 2 is changing state. You will see taht after a chile LED2 will sotp blinking meaning that program is crashed.
Fork of mbed_blinky by
main.cpp
- Committer:
- roscop
- Date:
- 2014-12-29
- Revision:
- 7:a121fc972b2a
- Parent:
- 4:81cea7a352b0
File content as of revision 7:a121fc972b2a:
#include "mbed.h" Ticker flipper1; Timer t1; InterruptIn button(p17); DigitalOut led1(p24); DigitalOut led2(p23); void trigger() { t1.reset (); led1 = !led1; button.enable_irq (); flipper1.detach(); // the address of the function to be attached (flip) and the interval (2 seconds) } void interrupt_in() { flipper1.attach_us(&trigger, 200000); // the address of the function to be attached (flip) and the interval (2 seconds) button.disable_irq (); } int main() { button.rise(&interrupt_in); // attach the address of th t1.start(); while(1) { led2 = !led2; wait(0.5); } }