Timers, Declaring timers – Echelon Neuron C User Manual
Page 37

Neuron C Programmer’s Guide
25
void f()
{ /* body */ }
g (a,b)
int a;
int b;
{ /* body */ }
Although Neuron C can create prototypes, it does
not
employ the ANSI C
Miranda prototype rule. According to the Miranda prototype rule, if a function
call does not already have a prototype, a prototype is automatically created for it.
In Neuron C, a function prototype is automatically created only when the
function is defined.
Timers
Two types of software timer objects are available to a Neuron C application:
millisecond timers and second timers. The millisecond timers provide a timer
duration of 1 to 64,000 milliseconds (or .001 to 64 seconds). The second timers
provide a timer duration of 1 to 65,535 seconds. For more accurate timing of
durations of 64 seconds or less, use the millisecond timer. These timers are
separate from the two hardware timer/counters in the Neuron core (see also
Input Clock Frequency and Timer Accuracy
on page 36).
For Series 5000 chips, a high-resolution hardware timer is also available. You
can program an interrupt handler to asynchronously handle interrupts that occur
based on this hardware timer; see
on page 153 for more information.
Declaring Timers
A maximum of 15 timer objects (total of both types) can be defined within a single
program. A timer object is declared using one of the following:
mtimer [repeating]
timer-name
[=
initial-value
];
stimer [repeating]
timer-name
[=
initial-value
];
mtimer
Indicates a millisecond timer.
stimer
Indicates a second timer.
repeating An option for the timer to restart itself automatically upon expiration.
With this option, accurate timing intervals can be maintained even if
the application cannot respond immediately to an expiration event.
timer-name
A user-supplied name for the timer. Assigning a value to
this name starts the timer for the specified length of time (the
specified time is in seconds for an stimer and milliseconds for an
mtimer). A timer that is running or has expired can be started over
by assigning a new value to this name. The timer object can be
evaluated while the timer is running, and it indicates the time
remaining. Setting the timer to 0 turns the timer off. No timer
expiration event occurs for a timer that has been turned off (see the
description of the timer_expires event described in the
Neuron C
Reference Guide
).