solve the time of a loop 0:100

Dependencies:   mbed

Fork of Timer_HelloWorld by mbed official

Committer:
shiyilei
Date:
Tue Oct 21 15:28:28 2014 +0000
Revision:
2:c979a2f3b744
Parent:
0:27e1de20d3cb
solve the time of a loop

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shiyilei 2:c979a2f3b744 1 /**************************************
shiyilei 2:c979a2f3b744 2 *file name: base time count
shiyilei 2:c979a2f3b744 3 *Creator:JacobShi
shiyilei 2:c979a2f3b744 4 *Time:2014/10/20
shiyilei 2:c979a2f3b744 5 *Description: solve the time of a loop
shiyilei 2:c979a2f3b744 6 ***************************************/
mbed_official 0:27e1de20d3cb 7 #include "mbed.h"
mbed_official 0:27e1de20d3cb 8 Timer t;
shiyilei 2:c979a2f3b744 9 int i;
shiyilei 2:c979a2f3b744 10 int timedata;
shiyilei 2:c979a2f3b744 11 int main(void)
shiyilei 2:c979a2f3b744 12 {
shiyilei 2:c979a2f3b744 13
shiyilei 2:c979a2f3b744 14 t.reset();
mbed_official 0:27e1de20d3cb 15 t.start();
shiyilei 2:c979a2f3b744 16 for(i=0;i<100;i++);
mbed_official 0:27e1de20d3cb 17 t.stop();
shiyilei 2:c979a2f3b744 18 timedata=t.read_us();
shiyilei 2:c979a2f3b744 19 printf("the time of the loos 0~99 is :%d us\n",timedata);
shiyilei 2:c979a2f3b744 20 }