Hello,
I need to force an OS context switch immediately after some IRQ is handled (power failure detection) - I cannot allow any other task to run after the IRQ except the highest priority task that is waiting for a signal. But I cannot allow the task that was interrupted to finish its time slice, thus I'm trying to induce a SWI by this code
VICSoftInt = (1<<4) ; // the constant used to address the proper hardware time is placed in "RTX_cofig.c"
However, I see that the IRQ is repeatably triggered (even if the matching register is reset!), and the SWI function is never executed (at least, in a test program that is running on the simulator). This is clearly something in the architecture (ARM7) I'm not aware of, but I did not find anything in the documentation prohibiting this. Can you enlighten me...?
It seems that this entire effort will not be necessary - RTX will indeed force a context switch using the very same method as I posted above.
Per,
Thanks for your reply. I will have a look at RTX's sources to see if the behavior is as you decribed (I assumed the same when I wrote the code - I am trying to find an explanation for a weird failure - but that's another story...). Maybe I missed a statement about this behavior in the RTX manual. Thanks for your reply.
Doesn't it work with a normal isr_xx() call to force a task switch?
As soon as your ISR ends, the RTX will then do a timer tick interrupt, allowing it to switch to a high-prio task that doesn't give any CPU time to any other tasks.
An alternative - if this is the end of the game for you - is to use the ISR to turn off interrupts (in case you allow nested interrupts) and then do what you need to do before the power is lost.
I do have one more question: Do I need to save LR while going through this? It seems to be requires when handling a SWI inside a SWI...?
It seems that if I define a SWI function, build a resolve table and call the function, the processor will switch from IRQ to SVC mode. Problem solved!
View all questions in Keil forum