SWI Module
Application Program Interface
2-425
The SWI_disable and SWI_enable operations allow you to post several
SWIs and enable them all for execution at the same time. The SWI
priorities then determine which SWI runs first.
All SWIs run to completion; you cannot suspend a SWI while it waits for
something (for example, a device) to be ready. So, you can use the
mailbox to tell the SWI when all the devices and other conditions it relies
on are ready. Within a SWI processing function, a call to SWI_getmbox
returns the value of the mailbox when the SWI started running. Note that
the mailbox is automatically reset to its original value when a SWI runs;
however, SWI_getmbox will return the saved mailbox value from when
the SWI started execution.
Software interrupts can have up to 15 priority levels. The highest level is
SWI_MAXPRI (14). The lowest is SWI_MINPRI (0). The priority level of
0 is reserved for the KNL_swi object, which runs the task (TSK)
scheduler.
A SWI preempts any currently running SWI with a lower priority. If two
SWIs with the same priority level have been posted, the SWI that was
posted first runs first. HWIs in turn preempt any currently running SWI,
allowing the target to respond quickly to hardware peripherals.
Interrupt threads (including HWIs and SWIs) are all executed using the
same stack. A context switch is performed when a new thread is added
to the top of the stack. The SWI module automatically saves the
processor’s registers before running a higher-priority SWI that preempts
a lower-priority SWI. After the higher-priority SWI finishes running, the
registers are restored and the lower-priority SWI can run if no other
higher-priority SWI has been posted. (A separate task stack is used by
each task thread.)
See the
Code Composer Studio
online tutorial for more information on
how to post SWIs and scheduling issues for the Software Interrupt
manager.
Treat mailbox
as bitmask
Treat mailbox
as counter
Always post
Post if
becomes 0
SWI_or
SWI_andn
SWI_dec
SWI_inc
Does not modify
mailbox
SWI_post