The LowPowerTimer class is used to measure time. The time will be the amount of time between when the start() and stop() functions are run. The Timer class counts from 0 up.
Fork of Timer_HelloWorld by
main.cpp@5:13760b19fc77, 2018-05-25 (annotated)
- Committer:
- deepikabhavnani
- Date:
- Fri May 25 18:33:45 2018 +0000
- Revision:
- 5:13760b19fc77
- Parent:
- 2:9152128dba25
Example to show low power timer usage
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedAustin | 2:9152128dba25 | 1 | /* mbed Example Program |
mbedAustin | 2:9152128dba25 | 2 | * Copyright (c) 2006-2014 ARM Limited |
mbedAustin | 2:9152128dba25 | 3 | * |
mbedAustin | 2:9152128dba25 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbedAustin | 2:9152128dba25 | 5 | * you may not use this file except in compliance with the License. |
mbedAustin | 2:9152128dba25 | 6 | * You may obtain a copy of the License at |
mbedAustin | 2:9152128dba25 | 7 | * |
mbedAustin | 2:9152128dba25 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbedAustin | 2:9152128dba25 | 9 | * |
mbedAustin | 2:9152128dba25 | 10 | * Unless required by applicable law or agreed to in writing, software |
mbedAustin | 2:9152128dba25 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbedAustin | 2:9152128dba25 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbedAustin | 2:9152128dba25 | 13 | * See the License for the specific language governing permissions and |
mbedAustin | 2:9152128dba25 | 14 | * limitations under the License. |
mbedAustin | 2:9152128dba25 | 15 | */ |
mbed_official | 0:27e1de20d3cb | 16 | #include "mbed.h" |
mbed_official | 0:27e1de20d3cb | 17 | |
deepikabhavnani | 5:13760b19fc77 | 18 | LowPowerTimer t; |
mbed_official | 0:27e1de20d3cb | 19 | |
mbed_official | 0:27e1de20d3cb | 20 | int main() { |
mbed_official | 0:27e1de20d3cb | 21 | t.start(); |
mbed_official | 0:27e1de20d3cb | 22 | printf("Hello World!\n"); |
mbed_official | 0:27e1de20d3cb | 23 | t.stop(); |
mbed_official | 0:27e1de20d3cb | 24 | printf("The time taken was %f seconds\n", t.read()); |
mbed_official | 0:27e1de20d3cb | 25 | } |