Input/output – Echelon Neuron C User Manual

Page 39

Advertising
background image

Neuron C Programmer’s Guide

27

}

If your program has multiple timers, you must include a specific check for each

timer so that the expiration event is cleared, as shown below:

mtimer x;
mtimer y;
mtimer z;
when (timer_expires(x))
{
// task
}
when (timer_expires(y))
{
// task
}
when (timer_expires(z))
{
// task
}

An alternate style of checking for specific timers is shown below. This example

also demonstrates that an event expression is not restricted to use only in a when

clause.

when (timer_expires)
{
if (timer_expires(x))
...
else if (timer_expires(y))
...
else if (timer_expires(z))
...
}

Note: Be sure to check for specific timer events while using the unqualified

timer_expires event. Unlike all other predefined events, which are TRUE only
once per pending event, the unqualified timer_expires event remains TRUE as

long as

any

timer has expired.

Which style you choose to use for checking timer expiration depends on the
circumstances in your application. Use the first style of checking for specific

timers if you’re concerned about code space. Use the second style if you’re

concerned about speed of execution, performance, or response time.

For an example of a complete program that declares a timer and uses the

timer_expires event, see

Example 1: Thermostat Interface

on page 31.

Input/Output

Each Neuron Chip and each Smart Transceiver has a variety of built-in electrical
interface options for performing input and output (I/O) functions. Before

performing I/O, you must first declare the I/O objects that monitor and control

the 11 or 12 Neuron Chip or Smart Transceiver I/O pins, named IO_0, IO_1, ...,
IO_11.
To perform I/O, you normally use the built-in I/O functions: io_in( ), io_out( ),
io_set_direction( ), io_select( ), io_change_init( ), and io_set_clock( ). The

io_out_request( ) function is used to perform I/O with the parallel I/O object. I/O

Advertising