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

How to determine where function was called from

From my code I need to figure out has my function been called from the ISR or just regular application code. I do know that application is running is the User Thread mode and ISR is in privileged handler mode. Could you anyone please provide me with the sources of C-function(s) or inline assembly which will let me efficiently solve this issue.

Thanks.

Parents
  • It is possible to perform read/write operations directly to the MSP and PSP provided that you are in privileged level, you can
    access MSP and PSP using the MRS and MSR instructions:
    MRS R0, MSP ; Read Main Stack Pointer to R0
    MSR MSP, R0 ; Write R0 to Main Stack Pointer
    MRS R0, PSP ; Read Process Stack Pointer to R0
    MSR PSP, R0 ; Write R0 to Process Stack Pointer

    And I'm not!!! Actually not always to be exact.

Reply
  • It is possible to perform read/write operations directly to the MSP and PSP provided that you are in privileged level, you can
    access MSP and PSP using the MRS and MSR instructions:
    MRS R0, MSP ; Read Main Stack Pointer to R0
    MSR MSP, R0 ; Write R0 to Main Stack Pointer
    MRS R0, PSP ; Read Process Stack Pointer to R0
    MSR PSP, R0 ; Write R0 to Process Stack Pointer

    And I'm not!!! Actually not always to be exact.

Children
No data