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

I want to know priority of Cortex-M3 processor

which interrrupt priority is higher?

systick vs IRQ(external timer)

because In my case externl timer is higher then systick.

I saw that during processing in systick ISR, but  suddenly pc jump to timer ISR

so  I experimented print out. systick print letter is broken. but timer print is out correctely

I think that systick priority is higher than external timer

why this situation is occured?

Parents
  • 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

Reply
  • 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

Children