From 0eb66a429fddc63b42fe602d0fc74c16eef23d6e Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Tue, 21 Jul 2020 11:23:49 +0200 Subject: [PATCH] cortexm_common: Clear PendSV request after idle sleep The PendSV interrupt is used to request a scheduling operation. An interrupt during the idle sleep can re-request the PendSV interrupt, while the PendSV is still busy scheduling the next thread. This clears the request after sleep to prevent triggering an extra PendSV interrupt after the current PendSV handler finished. --- cpu/cortexm_common/thread_arch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpu/cortexm_common/thread_arch.c b/cpu/cortexm_common/thread_arch.c index ebc13ac609..0b4352b658 100644 --- a/cpu/cortexm_common/thread_arch.c +++ b/cpu/cortexm_common/thread_arch.c @@ -474,4 +474,5 @@ void sched_arch_idle(void) #endif irq_restore(state); NVIC_SetPriority(PendSV_IRQn, CPU_CORTEXM_PENDSV_IRQ_PRIO); + SCB->ICSR = SCB_ICSR_PENDSVCLR_Msk; }