User`s manual

Copyright © Quantum Leaps, LLC. All Rights Reserved.
QDK™
Renesas RX with HEW
state-machine.com/rx
4.3.2 Saving and Restoring the Accumulator in the ISRs
The interrupt functions generated by the RX compiler with
#pragma vector
do not preserve the RX
accumulator register, unless the compiler option
-save_acc
is activated. This can be achieved in the
HEW IDE by selecting the menu Build | RX Standard Toolchain, the CPU tab, Details... button (see
Figure 11).
NOTE: When using the Vanilla kernel, you need to save and restore the accumulator register if the
ISR body can clobber it somehow, for example by performing one of the MAC instructions or a
floating-point instruction.
4.3.3 Specifying the Stacks (stacksct.h header file)
As described before, the QP framework uses exclusively the Supervisor stack and does not use the User
Stack at all. In the Renesas compiler the sizes of the stacks and heap are specified by means of
#pragma
stacksize
directives, which traditionally are placed in the
stacksct.h
header file. The
#pragma
stacksize si
specifies the Supervisor.
Listing 7: Specifying stack size int stacksct.h
#pragma stacksize si=256
4.3.4 Idle loop customization in the Vanilla port
As described in Chapter 7 of [PSiCC2], when no events are available, the non-preemptive Vanilla
scheduler invokes the platform-specific callback function
QF_onIdle()
, which you can use to save CPU
power, or perform any other idle processing (such as Q-SPY software trace output).
NOTE: The idle callback
QF_onIdle()
must be invoked with interrupts disabled, because the idle
condition can be changed by any interrupt that posts events to event queues.
QF_onIdle()
must
internally unlock interrupts, ideally atomically with putting the CPU to the power-saving mode (see
also Chapter 7 in [PSiCC2]).
Listing 8: Idle callback QF_onIdle() for the Vanilla kernel in bsp.c
(1) void QF::onIdle(void) { // entered with interrupts DISABLED
(2) BSP_LED_IDLE_ON(); // toggle the User LED on and then off, see NOTE02
(3) BSP_LED_IDLE_OFF();
(4) #ifdef Q_SPY
. . .
(5) #elif defined NDEBUG
(6) __wait_for_interrupt();
(7) #else
(8) QF_INT_ENABLE();
#endif
}
(1) This routine is always entered with interrupts disabled to avoid a race condition with interrupts that
could post one or more events to active objects and thus invalidate the idle condition.
20 of 32