Esempio di latenza di un Interrupt

Dependencies:   mbed

Revision:
0:046cbaef2d68
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Nov 06 12:39:18 2016 +0000
@@ -0,0 +1,22 @@
+ /* Program Example 2: Tests interrupt latency. External input causes interrupt, which
+ pulses external LED.
+*/
+ #include "mbed.h"
+ InterruptIn squarewave(D2); //Connect input square wave here
+ DigitalOut out(D3);
+ DigitalOut out2(D4);
+ void pulse() //ISR sets external led high for fixed duration
+ {
+     out = 1;
+     wait_us(50);
+     out = 0;
+ }
+ int main()
+ {
+     squarewave.rise(&pulse); // attach the address of the pulse function to
+     // the rising edge
+     while(1) { // interrupt will occur within this endless loop
+         Out2=!out2;
+         wait_ms(25);
+     }
+ }
\ No newline at end of file