FreeRTOS Kernel V10.0.0
MCU: nRF52840 SDK 17.1.0
Our device is fully functional, and we are currently performing various tests. During long-term testing, we found that the device occasionally resets, though very rarely — about once every two weeks. We recently confirmed that these resets are due to a Hardfault INVPC.
Upon investigation, we found that `configKERNEL_INTERRUPT_PRIORITY` was not set to the lowest value (0x7 or higher), but instead was configured to the same value (0x6) as other interrupts.
When we increased `configKERNEL_INTERRUPT_PRIORITY` to 5, a Hardfault INVPC occurred immediately, and the PC and LR values matched those of the original Hardfault observed in our device.
To verify whether the issue was caused by overlapping kernel and other interrupts, we artificially triggered a PendSV by adding `SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk;` inside the GPIO interrupt handler. However, no Hardfault INVPC occurred during this test.
We are nearing the product launch and would like to resolve this issue.
Q1: Can a Hardfault INVPC occur if an interrupt with the same priority as `configKERNEL_INTERRUPT_PRIORITY` is triggered?
Q2: How can we intentionally cause a Hardfault INVPC by using an interrupt with the same priority as `configKERNEL_INTERRUPT_PRIORITY`? What should the code look like?
Additional Hardfault Information:
CFSR: 0x00040000
PC: `prvProcessTimerOrBlockTask()` -> `portYIELD_WITHIN_API()`
LR: End of `xTaskResumeAll()`
MSP: 0x2003fef8
PSP: 0x20032348 (same as `p_stackaddress`)
Thank you in advance for your help.