Martin,
Regarding CPUSwitchToPrivilegedMode(). Actually the code for this API is correct and it is working correctly.
The debugger typically relies on svc_handler for its operations. And we also rely on this handler for switching back to privilege mode. So during debug process the debugger takes control and the expected behavior is not seen. you can confirm this by 2 methods,
- Run the code standalone (with out debugger connected)
- Before executing CPUSwitchToPrivilegedMode() from CCS, do free run (menu -> run -> free run). In this case CCS wont use svc_handler and you can see the expected mode change. I confirmed this by free run for below code. and when the control hits while(1), the system is in svc mode.
CPUSwitchToUserMode();
CPUSwitchToPrivilegedMode();
while(1);
regards
baskaran