HWI Module
2-150
Interrupt routines can be written completely in assembly, completely in C,
or in a mix of assembly and C. In order to support interrupt routines
written completely in C, an HWI dispatcher is provided that performs the
requisite prolog and epilog for an interrupt routine.
Note: RTS Functions Callable from TSK Threads Only
Many runtime support (RTS) functions use lock and unlock functions to
prevent reentrancy. However, DSP/BIOS SWI and HWI threads cannot
call LCK_pend and LCK_post. As a result, RTS functions that call
LCK_pend or LCK_post
must not be called in the context of a SWI or
HWI thread
. For a list or RTS functions that should not be called from
a SWI or an HWI function, see “LCK_pend” on page 2-180.
The C++ "new" operator calls malloc, which in turn calls LCK_pend. As a
result, the "new" operator cannot be used in the context of a SWI or HWI
thread.
HWI Dispatcher vs. HWI_enter/exit
The HWI dispatcher is the preferred method for handling an interrupt.
When an HWI object does not use the dispatcher, the HWI_enter
assembly macro must be called prior to any DSP/BIOS API calls that
affect other DSP/BIOS objects, such as posting a SWI or a semaphore,
and the HWI_exit assembly macro must be called at the very end of the
function’s code.
When an HWI object is configured to use the dispatcher, the dispatcher
handles the HWI_enter prolog and HWI_exit epilog, and the HWI function
can be completely written in C. It would, in fact, cause a system crash for
the dispatcher to call a function that contains the HWI_enter/HWI_exit
macro pair. Using the dispatcher allows you to save code space by
including only one instance of the HWI_enter/HWI_exit code.
Note:
CLK functions should not call HWI_enter and HWI_exit as these are
called internally by DSP/BIOS when it runs CLK_F_isr. Additionally,
CLK functions should
not
use the
interrupt
keyword or the
INTERRUPT pragma in C functions.