getMilliseconds Function

Top  Previous  Next

Gets the value of millisecond counter.

Syntax

System.Clock.getMilliseconds()

Return Value

A positive integer count of milliseconds.

Remarks

The milliseconds count is from a free-running counter, not synchronized with the time-of-day clock (DateTime.now function). It rolls over back to zero approximately every 25 days. It counts in 2ms increments.

 

The count rate is affected by the adjustment property.

Examples

// Wait for PortB bit 0, time out after 40ms

var start, dif, input;

start = System.Clock.getMilliseconds();

do

{

 // Mask out sign bit after subtracting

 dif = (System.Clock.getMilliseconds() - start) & 0x7FFFFFFF;

 input = Cell.PortB.pins & 0x01;

} while (input == 0 && dif < 40);

See Also

now Function