Interrupts and TI-RTOS Scheduling
TI-RTOS Thread Types
We already described two types of threads: Hwi and Idle. Using these two threads is very similar
to what we described throughout this chapter.
TI-RTOS Thread Types – More Design Options
Priority
Hwi
Hardware Interrupts
Hardware event triggers Hwi to run
BIOS handles context save/restore, nesting
Hwi triggers follow-up processing
Priorities set in silicon
Swi
Software Interrupts
Software posts Swi to run
Performs Hwi ‘follow-up’ activity (process data)
Up to 32 priority levels (16 on C28x)
Often favored by traditional h/w interrupt users
Task
Tasks
Usually enabled to run by posting a ‘semaphore’
(a task signaling mechanism) (similar to Posix)
Designed to run concurrently – pauses when
waiting for data (semaphore)
Favored by folks experienced in high-level OS’s
Idle
Background
Runs as an infinite while(1) loop
Users can assign multiple functions to Idle
Single priority level
TI-RTOS provides two additional thread types: Software Interrupts (Swi) and Tasks (Task). As
you can see above, these thread types fall between Hwi and Idle in terms of priority.
Each of these threads can be used to extend your system’s processing organization.
What do we mean by this?
You might remember that we HIGHLY recommended that you DO NOT nest interrupts. But what
happens if you want to run an algorithm based on some interrupt event? For example, you want
to run a filter whenever you receive a value from an A/D converter or from the serial port.
Without
an RTOS, you would need to organize your main while{} loop to handle all of these
interrupt, follow-up tasks. This is not a problem for one or two events; but for lots of events, this
can become very complicated – especially when they all run at different rates. This way of
scheduling your processing is called a SuperLoop.
With an RTOS, we can post follow-up activity to a Swi or Task. A Swi acts just like a software
triggered interrupt service routine. Tasks, on the other hand, run all the time (have you heard the term
multi-tasking before?
) and utilize Semaphores to signal when to run or when to block (i.e. pause).
In other words, Swi’s and Task’s provide two different ways to schedule follow-up processing
code. They let us keep our hardware interrupts (Hwi’s) very short and simple – for example, all
we need to do is read our ADC and then post an associated Swi to run.
If all of this sounds complicated, it really isn’t. While outside the scope of this course, the TI-
RTOS course will have you up-and-running in no time. Once you experience the effective
organization provided by an RTOS, you may never build another system without one.
MSP430 Workshop - Interrupts 5 - 33