The Timer interface is used to create, start, stop and read a timer for measuring small times (usually fractions of a second).
Any number of Timer objects can be created, and can be started and stopped independently
#include "mbed.h"
Timer t;
int main() {
t.start();
printf("Hello World!\n");
t.stop();
printf("The time taken was %f seconds\n", t.read());
}
API summary
| Timer | A general purpose timer |
| Functions | |
| start | Start the timer |
| stop | Stop the timer |
| reset | Reset the timer to 0. |
| read | Get the time passed in seconds |
| read_ms | Get the time passed in mili-seconds |
| read_us | Get the time passed in micro-seconds |
A general purpose timer
class Timer : public Base
Start the timer
void start()
Stop the timer
void stop()
Reset the timer to 0.
void reset()
Get the time passed in seconds
float read()
Get the time passed in mili-seconds
int read_ms()
Get the time passed in micro-seconds
int read_us()
Please login to post comments.