Hello,
I am facing an issue with the interrupt priority configuration on the S32K312. I have set the registers to have 2 groups and 2 subpriorities. However, I am observing unexpected behavior:
An interrupt with group priority 0 and subpriority 1 sometimes executes before another interrupt with group priority 0 and subpriority 0. If I change the subpriority from 1 to 2 in the first interrupt, everything works correctly, but I do not understand why this happens.
Specifically, the problematic interrupt is a SAOC (ADC Channel 9) that competes with an MC (Counter Channel 23) which handles the counter bus. The MC is configured to generate an interrupt on "Internal Counter Match End" when the register reaches 65535, setting the flag in 0 ticks.
Additionally, I have observed that the SAOC detects the issue when the match occurs very close to the overflow, and it might be waiting while the SAIC (Channel 0), which has group priority 0 and subpriority 0, is being serviced. This SAIC seems to work correctly.
// Example simplification
__NVIC_SetPriorityGrouping(5u);
// SAOC priority 0, subpriotity 0 CH9
// SAIC priority 0, subpriotity 0 CH0
// MC priority 0, subpriotity 1 CH23 EMIOS MODE FOR MC 0b0010010
prio = NVIC_EncodePriority(5, priority, subpriority);
__NVIC_SetPriority(irq, prio);
__NVIC_EnableIRQ(irq);
Could someone help me understand why this behavior occurs and how to fix it?
Thank you in advance.
#S32K312