Arm Community
Site
Search
User
Site
Search
User
Support forums
Arm Development Studio forum
Cortex M3 - how to enter Privileged Mode?
Jump...
Cancel
Locked
Locked
Replies
3 replies
Subscribers
119 subscribers
Views
9490 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
How was your experience today?
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
Cortex M3 - how to enter Privileged Mode?
Sebastian Gaertner
over 12 years ago
Note: This was originally posted on 15th July 2009 at
http://forums.arm.com
Hi,
I try to get an implementation that disables all interrupts up to an specific level. I use the BASEPRI for this.
However the disabling doesnt work, all interrupts are passing through like before.
At the moment of entering the disabling function the CONTROL register is "0x00".
Now what means 0x00? The Cortex TRM says
CONTROL[0] = 0 is user mode and
CONTROL[0] = 1 is privileged mode.
And the book "The Definitive Guide to the Arm Cortex-M3" says it mixed up:
CONTROL[0] = 1 is user mode and
CONTROL[0] = 0 is privileged mode.
I expect the information in the TRM is the right... is it?
I wonder why my debugger is showing the CONTROL = 0x00 at reset of the device. Should not normally the device start in privileged mode?
Does anyone work with a Cortex M3 and can confirm that?
Sebastian Gaertner
over 12 years ago
Note: This was originally posted on 16th July 2009 at
http://forums.arm.com
Hi Joseph
thanks for the hints with the priorities, I understand better now. Seems my priority is still set to 0 - so I see still the interrupt.
Yes, here we have two different versions of the CONTROl[0] description. This is a part of the TRM I used:
Cortex™-M3 TRM Revision: r1p1:
Thread mode is privileged out of reset, but you can change it to user or unprivileged by
clearing
the CONTROL[0] bit using the MSR instruction.
Cancel
Vote up
0
Vote down
Cancel
guestposter guestposter
over 12 years ago
Note: This was originally posted on 15th July 2009 at
http://forums.arm.com
Hi Ssss,
CONTROL[0] = 0 is privileged mode
CONTROL[0] = 1 is user mode
Could you tell me which page in TRM you are referring to?
(and which revision of the TRM).
From page 2-3 of Cortex-M3 revision 2 TRM:
"Thread mode is privileged out of reset, but you can change it to user or unprivileged by
setting the CONTROL[0] bit using the MSR instruction."
That's why the CONTROL register is 0x00 out of reset (privileged).
Setting CONTROL[0] to 1 will change it to user mode.
To use BASEPRI, you need to set it to a non-zero value. For example,
if 16 priority levels are available, it will be 0x10, 0x20, ... 0xF0.
If you set it to 0x00, the BASEPRI masking function is disabled.
However, by default all interrupts are at priority level 0. So they are higher
priority than any BASEPRI value. As a result, no matter what value you
set BASEPRI to, the interrupts will still get through. Therefore, BASEPRI
can only mask a interrupt if the priority level of the interrupt is not set to 0.
To mask interrupts with priority level 0, you need to use PRIMASK.
The easiest way to set PRIMASK is using (in assembly)
CPSID i
or in C:
__disable_irq();
regards,
Joseph
Cancel
Vote up
0
Vote down
Cancel
guestposter guestposter
over 12 years ago
Note: This was originally posted on 16th July 2009 at
http://forums.arm.com
Thanks. I checked our support system and found that it is
a known documentation errata on the r1p1 TRM.
regards,
Joseph
Cancel
Vote up
0
Vote down
Cancel