Accuracy of second timers, Delay functions, Time started here – Echelon Neuron C User Manual

Page 52

Advertising
background image

40

Focusing on a Single Device

Time started here.

H1

E1

L1

H2

E2

L2

E1

Timer expires in this range.

Second iteration of timer expires in this range.

Figure 5. Expected, Low, and High Duration of Timeout Events

Accuracy of Second Timers

The second timers rely on the one-second timer, which is based on the millisecond

timer mechanism described earlier. A one-second timer of duration

D

times out

in the range of

D

-1 to

D

seconds, where “second” is defined as 1001 milliseconds

using the millisecond timer duration formulas for

L

and

H

.

For example, at 625 kHz, each “second” is 991.23 milliseconds. Thus a 10-second
timer would time out in the range of 8.74 to 10.09 seconds.
For repeating one-second timers, the first timeout occurs in the range of

D

-1 to

D

seconds. Subsequent timeouts occur every

D

seconds. The fifth timeout of a

repeating 10-second timer would occur in the range of 48.39 to 49.74 seconds.

Delay Functions

Three functions allow an application to perform timing directly by suspending

execution for a given time. These functions provide a concise way to perform
timing in-line:

delay( )

msec_delay( )
scaled_delay( )

The delay( ) function produces a delay of fixed duration that is independent of
input clock speed. This function can be used with the wink feature and for I/O

debouncing. Its prototype is the following:

void delay (unsigned long

count

);

Advertising