
QDK™
M16C/Neutrino-NC30
www.state-machine.com/m16c
(5) The flags register is set to zero, which accomplishes two things at the same time. First, the in-
terrupts are locked again (the I flag is cleared). Second, the current interrupt priority level (IPL)
of the M16C processor is forced to zero, which corresponds to the task-level priority. Setting
the IPL to zero enables all interrupts and is effectively the End-Of-Interrupt instruction for the
M16C architecture.
(6) The QK interrupt nesting up-down counter
QK_intNest_
is decremented to the level before en-
tering the ISR.
(7) Only if the interrupt nesting drops to zero (ISR nested on task-level code)…
(8) The QK scheduler is called to perform the asynchronous preemptions.
(9) The QK configuration is specified simply by including the
”qk.h”
QK interface.
4.2 ISRs in the Preemptive Configuration with QK
As all preemptive kernels, QK must be notified about interrupt entry and exit. You achieve this by
means of the QK macros
QK_ISR_ENTRY()
and
QK_ISR_EXIT()
, as shown in Listing 7.
#pragma INTERRUPT ta0_isr (vect = 21) /* system clock tick ISR */
void ta0_isr(void) {
QK_ISR_ENTRY()
; /* inform QK about entering in ISR */
QF_tick(); /* process all armed time events */
/* perform other ISR work . . . */
QK_ISR_EXIT()
; /* inform QK about exiting in ISR */
}
Listing 7 Time tick interrupt calling QF_tick() function to manage armed time events
and QK ISR entry/exit macros.
4.3 Idle Loop Customization in the QK Port
As described in Chapter 10 of [PSiCC2], the QK idle loop executes only when there are no events to
process. The QK kernel allows you to customize the idle loop processing by means of the callback
QK_onIdle()
, which is invoked by every pass through the QK idle loop. You can define the platform-
specific callback function
QK_onIdle()
to save CPU power, or perform any other “idle” processing
(such as Quantum Spy software trace output).
NOTE: The idle callback
QK_onIdle()
is invoked with interrupts unlocked (which is in contrast to
QF_onIdle()
that is invoked with interrupts locked, see Section ).
The following
Listing 8 shows an example implementation of
QK_onIdle()
for the M16C.
void QK_onIdle(void) {
#ifdef Q_SPY
/* perform QS trace output via M16C UART */
#elif (defined NDEBUG) /* low-power mode interferes with debugging */
/* stop all peripheral clocks that you can in your applicaiton ... */
_asm("WAIT")
; /* execute before entering any pending interrupt */
#endif
}
Listing 8 QK_onIdle() callback for M16C.
Copyright © Quantum Leaps, LLC. All Rights Reserved.
15 of 25
Comentarios a estos manuales