Hi all,
I am working on the K64 and added a PIT timer and system tick to the project.
I set the SysTick to trigger every 1ms with priority 0, and the PIT timer with priority 1. And the PriorityGroup is set to 0.
However, I found the SysTick ISR could not preempt the PIT ISR, the SysTick counter doesn't change in the PIT ISR.
I thought the SysTick ISR should be able to preempt other ISRs like timer, uart...
Is my understanding run? Or did I miss anything? Any suggestion for let SysTick ISR to preempt other ISR?
Thanks!
Solved! Go to Solution.
Hi
If SysTick interrupt priority is 0 and PIT is 1 the SysTick wll be able to interrupt the PIT interrupt service routine (unless the PIT interrupt service routine's code actively disables this by, for example, disabling global interrupts).
If it is not operating as expected verify that you are really setting the priorities as expected:
- that you set the priority value in the correct register byte (corresponding to the vector in question) [if you set it in the wrong register by mistake it will have level priority 0 - the default one]
- make sure you set the value for priority 1 with (1 << 3) and not with 1, since it will otherwise not be valid (and stay at 0)
Regards
Mark
Complete Kinetis solutions for faster/more efficient professional needs, training and support: http://www.utasker.com/kinetis.html
i.MX RT project compatibility: http://www.utasker.com/iMX.html
Including FreeRTOS integration for all Kinetis parts
Kinetis K64:
- http://www.utasker.com/kinetis/FRDM-K64F.html
- http://www.utasker.com/kinetis/TWR-K64F120M.html
- http://www.utasker.com/kinetis/TEENSY_3.5.html
- http://www.utasker.com/kinetis/Hexiwear-K64F.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html
Open Source version at https://github.com/uTasker/uTasker-Kinetis
https://community.nxp.com/thread/512558
https://community.nxp.com/thread/352862
https://community.nxp.com/thread/498809
Hi Mark,
Thanks for your information, I re-check the SHP register for the SysTick Interrupt Priority setting, and I found the value is set to 15, which is set by the API "SysTick_Config()".
So the SysTick priority value would be set to 15 if the SysTick_Config().
After call an extra NVIC_SetPriority(SysTick_IRQn, 0), then the SysTick can preempt the PIT ISR.
Besides, I have further questions:
1. I want to make sure that for SysTeck, the SHP3 register got 8 bits for setting up the interrupt priority.
Does it only provides the first MSB 4 bits (Bit7, 6, 5, 4) for setting up the priority, just like IPR register in NVIC?
2. Does the priority setting in the SHP1, SHP2 & SHP3 also follow the settings of the PRIGROUP setting in the AIRCR? So the priority value of SysTick would also be separated into GroupPriority and SubPriority, just like external interrupt setting in the NVIC IPR register?
Hi 昶煒 梁,
Answering your first question, if you check in the SDK from the NVIC in the function to set the priority it checks first if its negative or positive and write in the corresponding register the high 4 bits (7, 6, 5 y 4).
__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
}
else
{
SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
}
}
About the second question, could you explain in more detail about it.
Best Regards,
Alexis Andalon
Hi
If SysTick interrupt priority is 0 and PIT is 1 the SysTick wll be able to interrupt the PIT interrupt service routine (unless the PIT interrupt service routine's code actively disables this by, for example, disabling global interrupts).
If it is not operating as expected verify that you are really setting the priorities as expected:
- that you set the priority value in the correct register byte (corresponding to the vector in question) [if you set it in the wrong register by mistake it will have level priority 0 - the default one]
- make sure you set the value for priority 1 with (1 << 3) and not with 1, since it will otherwise not be valid (and stay at 0)
Regards
Mark
Complete Kinetis solutions for faster/more efficient professional needs, training and support: http://www.utasker.com/kinetis.html
i.MX RT project compatibility: http://www.utasker.com/iMX.html
Including FreeRTOS integration for all Kinetis parts
Kinetis K64:
- http://www.utasker.com/kinetis/FRDM-K64F.html
- http://www.utasker.com/kinetis/TWR-K64F120M.html
- http://www.utasker.com/kinetis/TEENSY_3.5.html
- http://www.utasker.com/kinetis/Hexiwear-K64F.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html
Open Source version at https://github.com/uTasker/uTasker-Kinetis
https://community.nxp.com/thread/512558
https://community.nxp.com/thread/352862
https://community.nxp.com/thread/498809