Interrupts, Function prototypes – Echelon Neuron C User Manual
Page 36

24
Focusing on a Single Device
when clause selected evaluates to FALSE, its task is ignored and the scheduler
resumes with the first priority when
clause. See Figure 14 on page 147.
The scheduling algorithm described above can be modified through use of the
scheduler_reset pragma, discussed in Chapter 7,
, on page
Important: Excessive use of priority when clauses might starve execution of
nonpriority when clauses. If a priority when clause is true the majority of the
time, it monopolizes processor time. Priority when clauses should be designed to
be true only rarely, or the remaining tasks must be tolerant of not being executed
frequently and responsively.
Interrupts
Neuron C supports application-specific asynchronous interrupts from various
interrupt sources, and provides a semaphore for synchronization in a
multiprocessing environment.
Each interrupt statement consists of an interrupt clause, followed by an
interrupt task. Unlike when statements, which can include more than one when
clause, interrupt statements support only a single interrupt clause.
The interrupt clause defines the interrupt source and the conditions that trigger
the interrupt. The interrupt task contains code that runs as a result of the
interrupt.
Example:
interrupt(IO_3, clockedge(-)) {
...
}
Interrupt clauses support interrupt requests from signal conditions on I/O pins,
from timer or counter I/O objects, or from the high-resolution system timer.
A simple __lock{ } construct implements synchronization through a hardware
semaphore.
See
on page 153 for more information.
Function Prototypes
Neuron C requires the use of function prototypes if a function is to be called
before it is defined. Examples of valid prototypes include the following:
void f(void);
int g(int a, int b);
The following are not considered prototypes because they do not have argument
lists. They are merely forward declarations:
void f();
g(); // defaults to 'int' return value
If you define a function before you call it, Neuron C automatically creates an
internal prototype for you. Only one prototype is created for a given function.
The following examples are technically not prototypes, but Neuron C creates
function prototypes for them: