Skip to content

Commit bd1ad99

Browse files
committed
Fix sleep function for NRF52.
An active IRQ from the FPU can prevent the micro to go to sleep, even if this IRQ is not enabled and not implemented. As a workaround, the FPU IRQ is cleared before enterring sleep.
1 parent d1a71eb commit bd1ad99

File tree

1 file changed

+7
-0
lines changed
  • targets/TARGET_NORDIC/TARGET_NRF5

1 file changed

+7
-0
lines changed

targets/TARGET_NORDIC/TARGET_NRF5/sleep.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ void sleep(void)
3131
// the processor from disabled interrupts.
3232
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
3333

34+
#ifdef NRF52
35+
/* Clear exceptions and PendingIRQ from the FPU unit */
36+
__set_FPSCR(__get_FPSCR() & ~(FPU_EXCEPTION_MASK));
37+
(void) __get_FPSCR();
38+
NVIC_ClearPendingIRQ(FPU_IRQn);
39+
#endif
40+
3441
// If the SoftDevice is enabled, its API must be used to go to sleep.
3542
if (softdevice_handler_isEnabled()) {
3643
sd_power_mode_set(NRF_POWER_MODE_LOWPWR);

0 commit comments

Comments
 (0)