Hello -
We are developing on a nRF52840 device, SDK v17.0.2 and FreeRTOS. Following the flow in the provided by the vPortSuppressTicksAndSleep() function, we've implemented a function to wake-up from RTC or any interrupt in System ON sleep mode. Our function also powers down most of the RAM sections before sleeping. After wake-up the function powers RAM back on and resets the device. That all seems to work well. We use the following loop while sleeping to wait for any event:
do {
__WFE();
} while (0 == (NVIC->ISPR[0] | NVIC->ISPR[1]));
The problem is that if we call our RTC wake-up function soon after the device reboots, say within 200-400 ms of reboot, the sleep loop above exits early with ISPR[0] set to 1. If I understand the registers correctly, the value 1 corresponds to the POWER/CLOCK IRQn. Masking out this interrupt in the loop works around the problem:
do {
__WFE();
} while (0 == ((NVIC->ISPR[0] & (~(uint32_t)(1L << POWER_CLOCK_IRQn))) | NVIC->ISPR[1]));
Am I correct that the POWER/CLOCK interrupt is set pending, and if so, what would lead to this condition and how can we best avoid it?
Regards,
Brian