Recently changed pages
Jobs Jobs
Debugging Debugging
mbed NXP LPC1768 mbed NXP LPC1768
Homepage Homepage
Compiler Tour Compiler Tour
Media Media
Serial Serial
From the mbed microcontroller Handbook.

Timer

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

Hello World!

Simple timer example

#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

API summary

TimerA general purpose timer
Functions
startStart the timer
stopStop the timer
resetReset the timer to 0.
readGet the time passed in seconds
read_msGet the time passed in mili-seconds
read_usGet the time passed in micro-seconds
class Timer : public Base
A general purpose timer
void start()
Start the timer
void stop()
Stop the timer
void reset()
Reset the timer to 0.
float read()
Get the time passed in seconds
int read_ms()
Get the time passed in mili-seconds
int read_us()
Get the time passed in micro-seconds



calendar Page history
Last modified 21 Jul 2010, by user avatar Dan Ros   tag No tags | 0 replies     Share: Digg Tweet This

Please login to post comments.