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

Files at this revision

API Documentation at this revision

Comitter:
roscop
Date:
Mon Dec 29 11:03:29 2014 +0000
Parent:
6:e8cd76f38fa9
Commit message:
this code is tho put in evidence a bug in the TIMER implementation on Nordic nRF51822. Example was created for plateform nRF51-DK.; Led 2 will stop blinking (crashed main) when user button 2 is pressed several time.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- 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
--- a/mbed.bld	Fri May 09 19:58:03 2014 +0300
+++ b/mbed.bld	Mon Dec 29 11:03:29 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file