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?
Thank you! your guide
your comment is helpful for me.
If you don't mide, I want to you to look at my code.
for instance
I'll control priority level like below
uint32_t priorityGroup; /* Variables to store priority group and priority */
uint32_t priority;
NVIC_SetPriorityGrouping(2);
priorityGroup = NVIC_GetPriorityGrouping();
priority = NVIC_EncodePriority(priorityGroup, 0, 0); // preempt priority group , subpriority NVIC_SetPriority(TIMER0_IRQn, priority); priority = NVIC_EncodePriority(priorityGroup, 2, 0); NVIC_SetPriority(SysTick_IRQn, priority);
priority level
I think that TIMER0_IRQn's priority level is become 0 and SysTick_IRQn's priority level is become 4.
With kind regards, yours
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)
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:
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
your comment as above is very useful for me.
so. I understood very much about priorities.
thank you~