Renesas M16C/6N Bedienungsanleitung Seite 14

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 27
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 13
QDK™
M16C/Neutrino-NC30
www.state-machine.com/m16c
3.3 ISRs in the Non-preemptive “Vanilla” Configuration
The NC30 compiler supports writing interrupts in C. In the “vanilla” port, the ISRs are identical as
in the simplest of all “superloop” (main+ISRs), and there is nothing QP-specific in the structure of
the ISRs.
(1)
#pragma INTERRUPT ta0_isr (vect = 21)
(2) void ta0_isr(void) { /* Timer A0 ISR */
(3)
QF_INT_UNLOCK()
; /* see NOTE01 */
(4) /* clear any level-sensitive interrupt sources, if necessary ... */
(5) QF_tick();
/* perform other work of the ISR, e.g., switch debouncing */
(6)
QF_INT_LOCK()
; /* see NOTE01 */
}
Listing 4 Time tick interrupt calling QF_tick() function to manage armed time events.
(1) The ISR in C is always compiler-specific, as the C standard does not define how to specify ISRs.
In the case of the NC30 compiler for M16C interrupt must be declared with the
#pragma INTER-
RUPT
. You also need to specify the interrupt vector number in the parentheses as shown.
(2) The ISR in C that follows the interrupt vector specification must have a
void (void)
signature.
(3) The macro
QF_INT_UNLOCK()
must be called before invoking any QF services.
NOTE: You should be careful not to introduce nesting of critical sections by leaving interrupts
disabled interrupts before calling any QF services, such as
QF_publish()
or
QF_tick()
. In every
ISR you write, you should use the pair of macros
QF_INT_UNLOCK()
at the beginning and
QF_INT_LOCK()
at the end of an ISR.
If you don’t wish an interrupt to be preempted by another interrupt, you can always prioritize
that interrupt to a higher level.
(4) The level-sensitive interrupt sources should be cleared right at the beginning of the ISR. Be-
cause the M16C CPU prioritizes interrupts in hardware, it really does not matter at which point
during the ISR processing the interrupt source is cleared. Even though the interrupts are
unlocked at line (3), the CPU will not allow the same interrupt preempt itself.
(5) The time-tick ISR must invoke
QF_tick(),
and can also perform other things, if necessary. The
function
QF_tick()
cannot be reentered, that is, it necessarily must run to completion and re-
turn before it can be called again. This requirement is automatically fulfilled, because the M16C
hardware performs interrupt prioritization and will not allow the same interrupt to preempt cur-
rently running interrupt.
(6) The macro
QF_INT_UNLOCK()
must be called before returning from the interrupt.
Copyright © Quantum Leaps, LLC. All Rights Reserved.
12 of 25
Seitenansicht 13
1 2 ... 9 10 11 12 13 14 15 16 17 18 19 ... 26 27

Kommentare zu diesen Handbüchern

Keine Kommentare