This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to Change to Privilege mode and get back to previous mode?

Other Parts Discussed in Thread: TMS570LC4357, HALCOGEN

Hi TI,

I am using TMS570LC4357 with HalCoGen Generated free-RTOS.

In this, I configured one 10ms Task and 1ms Task. Inside the 10ms Task at some instance, I want to switch the CPU to Privileged mode.

I can do this using either "prvRaisePrivilege()" function or else asm( " CPS #0x1F").

But my problem is that I want to bring back my CPU to the Previous mode (whatever it is).

i.e: Before I do a change to Privilege mode, if CPU is in User Mode, then I have to bring back it to user mode after I did all my operations in Privileged mode.

In this case I know how to bring CPU to the mode whatever I want.

But how to know what is the Current mode, so that I can bring back it to the same mode after I make my changes.


Thanks in advance,

Regards,

Karthikeyan.K

  • (1) To change from a privileged mode to user mode, you can use the CPS instruction.
    (2) To change from user mode to a privileged mode, you need to generate a software interrupt and change the mode in the ISR.
    (3) To know the current mode, read the CPSR register.

    Please refer to Cortex-R5 TRM for more details.

    Thanks and regards,

    Zhaohong