![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
solve the time of a loop 0:100
Dependencies: mbed
Fork of Timer_HelloWorld by
main.cpp@2:c979a2f3b744, 2014-10-21 (annotated)
- 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?
User | Revision | Line number | New 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 | } |