Quantcast
Channel: ARM Connected Community: Message List
Viewing all articles
Browse latest Browse all 8551

Re: I want to know priority of Cortex-M3 processor

$
0
0

Hi Kyujin,

 

In your code you set the priority group setting to 2, so bit [7:3] is group priority / pre-empt priority, and bit [2:0] is sub priority.

Next the question is how many bits are implemented in the priority level registers. This is device specific, for example, with STM32F4 you have got 4 bits, so only bit [7:4] are implemented.

For minimum you have have 3 bits, where bit[7:5] are implemented.

 

When you execute NVIC_EncodePriority, the function take account of both priority group setting and implemented priority bit width. So if you are running this on a STM32F4, the function know that only bit [7:4] are available, and all of this is for group priority / pre-empt priority, so it set encoded SysTick priority value to 2 (no subpriority bits).

 

Assumed you have 6 bits of priority level, then your table for NVIC_EncodePriority is correct (but I changed the labels and table layout slightly to make it clearer):

  priority = NVIC_EncodePriority(priorityGroup, group priority, sub-priority)

 

PriorityGroup configgroup priority (preempt priority)sub-priorityReturned encoded "priority" variable
2000
2011
2102
2113
2204

 

Now if run the same code on a device with few priority level bits, e.g. STM32F4, there will be no sub-priority if you set PriorityGroup to 2, so you end up with:

 

 

PriorityGroup configgroup priority (preempt priority)sub-priorityReturned encoded "priority" variable
2000
2010
2101
2111
2202

 

I hope this helps. It might be easier to understand this if you have actual hardware to run a test, and use single stepping or printf to examine the results for each step.

I am on a business trip next 10 days so won't be able to do anymore reply at this stage.

 

regards,

Joseph


Viewing all articles
Browse latest Browse all 8551

Trending Articles