Hi JeorgeB,
The device is running in Supervisor (privileged) mode out of reset. It is controlled by nPRIV bit in CONTROL register (it is core register, see ARM documentation for more details).
If you need to switch to User mode, just set the nPRIV bit in CONTROL register
// switch to User (unprivileged) mode
__asm__("mov r0, #0x01");
__asm__("msr control, r0"); // nPRIV = 1
And to switch it back, you need to do it in SVC handler
// make a supervisor call (SVC) to transfer control to privileged software
__asm__("svc #0x00");
void SVC_Handler(void){
// switch to Supervisor (privileged) mode
__asm__("mov r0, #0x00");
__asm__("msr control, r0"); // nPRIV = 0
}
Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------