Controlling interrupts, Ge 159 – Echelon Neuron C User Manual
Page 171

Neuron C Programmer’s Guide
159
...
}
interrupt(repeating, “3456.789Hz”) {
...
}
interrupt(repeating, ”625E3”) { // 625 kHz
...
}
You do not need to specify the frequency as one of the 256 allowed values within
the range 2,441.406 Hz to 625,000 Hz. Instead, the Neuron C compiler accepts
any correctly formatted value within the range, and uses the following formula to
calculate an encoded rate value
Z
:
1
)
10
*
6
.
1
(
*
1
6
−
=
−
F
Z
where
F
is the specified frequency value.
The compiler then rounds the calculated value
Z
to the nearest integer
Z’
. The
Z’
value defines the encoded step within the frequency range 2,441.406 Hz to
625,000 Hz, and has a value in the range [0 .. 255]. The compiler uses the
Z’
value to register the system timer interrupt with the system firmware:
)]
'
,
255
min(
,
0
max[
Z
n
=
The compiler issues a warning message if the resulting frequency
f(n)
varies by
more than 1% from the desired frequency F, according to the following formula:
)
10
*
6
.
1
(
*
)
1
(
1
)
(
6
−
+
=
x
x
f
The warning message (NCC#578) contains the exact error (in percent) and the
resulting interrupt frequency. To eliminate the warning message, or to define
the system timer frequency with high precision, use the formula for
Z
to specify a
different frequency value.
Controlling Interrupts
By default, all application-defined interrupts are disabled, thus allowing the
device to complete its initialization or reset processing before being interrupted.
When the device is ready to receive interrupts, typically towards the end of the
when(reset) task, the application calls the following function:
void interrupt_control(unsigned
irqSelect
);
The
irqSelect
argument specifies the type of interrupts to enable. You can use
the following predefined symbols to specify the interrupt type:
#define INTERRUPT_IO 0x03
#define INTERRUPT_TC 0x0C
#define INTERRUPT_REPEATING 0x10
A value of zero (0x00) disables all interrupts. A value of -1 (0xFF) enables all
interrupt tasks defined for the application.