MQX handles HW interrupts and exceptions with interrupt
service routines (ISR). Please note the sentence ‘exceptions are handled by ISR’.
In due course I would discuss my experience with some very interesting problem involving
exception ISR.
What an ISR? What goes inside an ISR?
ISR is not a task. It’s a small piece of code which is
executed whenever an interrupt occurs. The main functionally of ISR may include
a)
Servicing a device
b)
Clearing an error condition
c)
Singling a task
MQX allows to pass a parameter to the ISR handler whenever
application is installing an ISR. This parameter is a pointer. Please note that
this pointer should not be at task stack, as it can be called even before task is
created.
People keep on saying ISR should be precise. Well, that
makes lots of sense as during ISR other interrupts may be disabled. And you
definitely not want to miss the interrupts. Are you asking for example?
Hmm, let’s say whenever aeroplane’s engine is getting too
hot, cooling procedure should be initiated immediately. Now, this is how it would work, a sensor would
trigger an HW interrupt, and ISR would ask you application to run the Cooling
Task. But wait, you application is handling a pervioius ISR which has disabled other
interrupts. And you are playing ‘print Hello word’ a zillion time game there in
ISR(just kidding!). So you would miss the interrupt.( And lets hope you are not flying
on the plane )
Back to serious stuff.
What is Kernel ISR?
MQX provides a kernel ISR(_init_kernel_isr()) which is written
in assembly language. The kernel ISR runs before any other ISR. And it
a)
saves the context of the
active task.
b)
switches to the interrupt
stack .
c)
calls the appropriate ISR .
d)
after the ISR has returned,
restores the context of the highest-priority ready task
When MQX starts it installs kernel ISR to all interrupts.
Initializing interrupt handling/Installing interrupts and Default ISR
When MQX starts, it initializes its ISR vector table which
has entry for all interrupts. Each entry consists of a)
pointer to ISR b)data to pass as parameter c)
Default exception handler.
Initially ISR for each entry is ‘_int_default_isr()’.
All of this is performed by a MQX kernel function called
_int_init(), which loops for all interrupts and does what I mentioned above.
continued in next post. Click here
Good article on ARM exception handling
http://www.csie.nctu.edu.tw/~wjtsai/EmbeddedSystemDesign/Ch3-1.pdf
Good article on ARM exception handling
http://www.csie.nctu.edu.tw/~wjtsai/EmbeddedSystemDesign/Ch3-1.pdf
No comments:
Post a Comment