Hardware Interrupts
Thread Scheduling
4-19
4.2.4
Context and Interrupt Management Within Interrupts
When a hardware interrupt preempts the function that is currently executing,
the HWI function must save and restore any registers it uses or modifies.
DSP/BIOS provides the HWI_enter assembly macro to save registers and the
HWI_exit assembly macro to restore registers. Using these macros gives the
function that was preempted the same context when it resumes running. In
addition to the register context saving/restoring functionality, the
HWI_enter/HWI_exit macros perform the following system level operations:
❏
ensure the SWI and TSK schedulers are called at the appropriate times
❏
disable/restore individual interrupts while the ISR executes
The HWI_enter assembly macro must be called prior to any DSP/BIOS API
calls that could post or affect a software interrupt or semaphore. The
HWI_exit assembly macro must be called at the very end of the function’s
code.
In order to support interrupt routines written completely in C, DSP/BIOS
provides an HWI dispatcher that performs these enter and exit macros for an
interrupt routine. An HWI can handle context saving and interrupt disabling
using this HWI dispatcher or by explicitly calling HWI_enter and HWI_exit.
The HWI configuration properties allow you to choose whether the HWI
dispatcher is used for individual HWI objects. The HWI dispatcher is the
preferred method for handling interrupts.
The HWI dispatcher, in effect, calls the configured HWI function from within
an HWI_enter/HWI_exit macro pair. This allows the HWI function to be written
completely in C. It would, in fact, cause a system crash were the dispatcher
to call a function that contains the HWI_enter/HWI_exit macro pair. Using the
dispatcher therefore allows for only one instance of the HWI_enter and
HWI_exit code.
Note:
The
interrupt
keyword or INTERRUPT pragma must
not
be used when
HWI objects are used in conjunction with C functions.The
HWI_enter/HWI_exit macros and the HWI dispatcher contain this
functionality, and the use of the C modifier can cause program failure.
Summary of Contents for TMS320 Series
Page 1: ...TMS320 DSP BIOS v5 40 User s Guide Literature Number SPRU423G April 2009 ...
Page 16: ...xvi ...
Page 152: ...Tasks 4 48 Figure 4 12 Trace from Example 4 7 ...
Page 168: ...Semaphores 4 64 Figure 4 14 Trace Results from Example 4 11 ...
Page 202: ...5 20 ...
Page 287: ...Index 9 Index Void 1 11 W words data memory 3 15 of code 1 5 wrapper function 2 29 ...
Page 288: ...Index 10 Index ...