Hi. I am developing small RTOS and I need to switch to thread mode from handler mode to do something, and this has to be done in thread mode.
I am testing RTOS on Cortex-M3 and M7 for a moment. I know that in hardware is set to exit handler mode if "magic value" is loaded to PC and the execution is transferred back to the point it was interrupted. But before that I need to do something and it has to be done in Thread mode.
Is any way to switch from Handler mode to Thread mode by writing to the registers? Or any other options?
I looked in documentation and it is not obvious to me if this is possible.
Thank you.
Alex
Hi Robert.
Thanks for your reply.
I was too short when I was talking about "Magic value".
But my threads are short lived and started as tasks with some priority and die, and can be restarted. The same stack is used. Only one stack is used. These tasks are started by Interrupts. Any ideas on that, how to exit handler mode?
Thank you
OK. I think you are short again.
What does Short lived mean to you?
What does die mean to you?
Do you need to save any state information between starting and restarting a task?
Maybe what you could use is a priority queue that is processed by the PendSV interrupt?
Thanks for your replay. I think I need to use PendSV. I don't see other way.