This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Are any other ways to exit Handler mode to Thread mode on Cortex M processors?

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

Parents
  • Loading the "Magic Value" into the PC does not transfer back to the point that it was interrupted.  

    What it does is use the appropriate stack pointer to restore the context from and continues running from there.

    This may seem like it is the same thing as you said, and in many cases it is, but IF you change the stack pointer or change values on the stack, it can (and is) quite different.

    To change to a different thread, this is exactly what you would do.  You would change the Stack pointer that will be used to restore the context from when you leave the Handler_Mode.  

Reply
  • Loading the "Magic Value" into the PC does not transfer back to the point that it was interrupted.  

    What it does is use the appropriate stack pointer to restore the context from and continues running from there.

    This may seem like it is the same thing as you said, and in many cases it is, but IF you change the stack pointer or change values on the stack, it can (and is) quite different.

    To change to a different thread, this is exactly what you would do.  You would change the Stack pointer that will be used to restore the context from when you leave the Handler_Mode.  

Children