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.

Dependencies:   mbed

Fork of mbed_blinky by Mbed

Revision:
7:a121fc972b2a
Parent:
4:81cea7a352b0
--- a/main.cpp	Fri May 09 19:58:03 2014 +0300
+++ b/main.cpp	Mon Dec 29 11:03:29 2014 +0000
@@ -1,12 +1,40 @@
-#include "mbed.h"
-
-DigitalOut myled(LED1);
-
-int main() {
-    while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
-    }
-}
+#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);
+    }
+}
\ No newline at end of file