EJEMPLO2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
fabeltranm
Date:
Sat Oct 28 01:46:22 2017 +0000
Commit message:
IRQ2;

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Oct 28 01:46:22 2017 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h" 
+
+
+Timer timer1;             // define timer object 
+Timer timer2;             // define timer object 
+DigitalOut output1(LED1); // digital output 
+Serial serial(USBTX, USBRX);
+
+
+void task1(void);       // task function prototype 
+void task2(void);       // task function prototype 
+
+
+
+//*** main code 
+
+void main() { 
+    timer1.start();     // start timer counting 
+    timer2.start();     // start timer counting 
+    while(1) { 
+        if (timer1.read_ms()>=200) // read time in ms 
+        { 
+            task1(); // call task function 
+            timer1.reset(); // reset timer 
+        }
+        if (timer2.read_ms()>=2000) // read time in ms 
+        { 
+            task2(); // call task function 
+            timer2.reset(); // reset timer 
+        }  
+    } 
+    } 
+    
+void task1(void){ // task function 
+
+    output1=!output1; // toggle output 
+    
+}
+
+void task2(void){ // task function 
+
+    serial.printf("1");;
+    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Oct 28 01:46:22 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/fb8e0ae1cceb
\ No newline at end of file