Need some help with Arduino port

05 Jan 2010

Hi,

Does anyone know if there is a function like millis() (on the arduino) for the mbed. The function is like below.

Parameters

None

 

Returns

Number of milliseconds since the program started (unsigned long)

Thanks

Mike.

05 Jan 2010

wait_ms() is milliseconds, wait_us() is microseconds.

 

Hope that helps.

05 Jan 2010

Not really but thanks anyway!

wait_ms() & wait_us() just dwell or pause dont they? The Millis() function on the arduino returns how long the chips program has been run in milliseconds.

This is how they discribe the function.

millis()

Description

Returns the number of milliseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 50 days.

www.arduino.cc/en/Reference/Millis

Cheers.

Mike.

05 Jan 2010

Woops sorry replyed to quickly!

05 Jan 2010 . Edited: 05 Jan 2010

1) short period of time :

May be you can use timer (look in the handbook page) :

t.start(); as first instruction of main()

Timer t;

int main() {
    t.start();
 
    // your code here
 
    printf("mbed started %d milliseconds ago\n", t.read_ms());

2) Longer period of time :

look for rtc_time in mbed lib in the compiler

05 Jan 2010

Perfect.

Thanks!