Bypass mode, The post_events( ) function – Echelon Neuron C User Manual

Page 161

Advertising
background image

Neuron C Programmer’s Guide

149

become TRUE. It is thus important that these when

clauses be evaluated in

their given order after a network variable update. Using scheduler_reset, the
nv_update_occurs event for nviSwitch1 is always checked first whenever a new

network variable update is at the head of the queue.
Updates to nviSwitch3 or nviSwitch4 trigger only the third event.

Bypass Mode

All scheduling of Neuron C programs, as described above, is event-driven and

handled by the scheduler. Within a program, however, you can choose when to

return control to the scheduler. The term

bypass mode

refers to a method of

programming in which one when clause always evaluates to TRUE and never

returns. In this case, a single task must handle all event processing.

You should use bypass mode rarely, and only in cases where you need a different

scheduling algorithm than that provided by the Neuron firmware scheduler.

While in bypass mode, your program is responsible for all event processing. You
define critical sections through the post_events( ) function (see the following

section), and then check for predefined events in if, while, and for expressions.
If your application runs on a Series 5000 device, consider using interrupts for
specific kinds of events, so that you do not need to use bypass mode for the

scheduler. See

Interrupts

on page 153 for more information.

The post_events( ) Function

Use the post_events( ) function to define a boundary of a critical section at which
network variable updates are sent and incoming network variable updates are

processed.
Note: The post_events( ) function is automatically called at the top of the
scheduling loop.
When the post_events( ) function is called, a number of things happen:

• Any outgoing network variable updates are sent. In the case of

synchronous network variables, all the updates are sent. For

nonsynchronous network variables, as many updates are sent as
application output buffers are available. Any unsent updates are sent the

next time post_events( ) is called.

• Incoming network variable update events are received.
• New incoming messages are examined.
• Timers are examined to see if they have expired.
• The watchdog timer is reset (to keep it from timing out). See the

following section about the watchdog timer.

You can use the post_events( ) function to improve network performance by

calling it immediately after modifying network variables. Call the post_events( )
function to signal the network processor to start execution of the formatting of

the outgoing packet before the when task completes, thus increasing parallel

processing and utilizing the Neuron Chip and Smart Transceiver multi-processor
architecture to its fullest.

Advertising