Christian Weiß / Mbed 2 deprecated Timer

Dependencies:   mbed

Committer:
Wizo
Date:
Thu Nov 15 18:05:27 2018 +0000
Revision:
0:65dee900759a
Timer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wizo 0:65dee900759a 1 #include "mbed.h"
Wizo 0:65dee900759a 2 Timer timer1; // define timer object
Wizo 0:65dee900759a 3 DigitalOut output1(p5); // digital output
Wizo 0:65dee900759a 4 void task1(void); // task function prototype
Wizo 0:65dee900759a 5 //*** main code
Wizo 0:65dee900759a 6 int main()
Wizo 0:65dee900759a 7 {
Wizo 0:65dee900759a 8 timer1.start(); // start timer counting
Wizo 0:65dee900759a 9 while(1) {
Wizo 0:65dee900759a 10 if (timer1.read_ms()>=200) { // read time in ms
Wizo 0:65dee900759a 11 task1(); // call task function
Wizo 0:65dee900759a 12 timer1.reset(); // reset timer
Wizo 0:65dee900759a 13 }
Wizo 0:65dee900759a 14 }
Wizo 0:65dee900759a 15 }
Wizo 0:65dee900759a 16 void task1(void) // task function
Wizo 0:65dee900759a 17 {
Wizo 0:65dee900759a 18 output1=!output1; // toggle output
Wizo 0:65dee900759a 19 }