Hi,
function nvicSetSystemHandlerPriority uses handler (e.g., HANDLER_SYSTICK = 11) directly with the CMSIS macros _SHP_IDX() and _BIT_SHIFT(). These macros expect the negative system exception number (e.g., SysTick_IRQn = -1), not the positive handler index. This results in an incorrect byte offset in the SCB->SHP array, leaving the intended handler priority unchanged and potentially corrupting another handler’s priority.
Suggested fix:
int32_t irqn = (int32_t)handler - 12;
SCB->__SHPR[_SHP_IDX(irqn)] = (SCB->__SHPR[_SHP_IDX(irqn)] & ~(0xFFU << _BIT_SHIFT(irqn))) |
(NVIC_PRIORITY_MASK(prio) << _BIT_SHIFT(irqn));
nvicSetSystemHandlerPriority writes to wrong SHP register on Cortex-M0+/M0/M23 Topic is solved
-
Daniil Emb
- Posts: 1
- Joined: Fri Jun 12, 2026 8:01 am
- Been thanked: 1 time
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: nvicSetSystemHandlerPriority writes to wrong SHP register on Cortex-M0+/M0/M23
Hi,
I think there was a ticket about this on sourceforge, we moved to github recently, I will create an unified issue there, thanks for reporting.
https://sourceforge.net/p/chibios/bugs/1308/
Giovanni
I think there was a ticket about this on sourceforge, we moved to github recently, I will create an unified issue there, thanks for reporting.
https://sourceforge.net/p/chibios/bugs/1308/
Giovanni
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times