Skip to content

Commit 29ad5bb

Browse files
committed
Fix ISR powerdown in mbed_application.c
Fix a calculation error in in powerdown_nvic preventing the last group of 32 interrupts from getting powered down. The ARMv7m reference manual states "the total number of interrupt lines is up to (32*(INTLINESNUM+1)).". Also rename isr_count to isr_groups_32 for clarity, since this is actually the number of 32 interrupt groups.
1 parent 316c875 commit 29ad5bb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

platform/mbed_application.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ void mbed_start_application(uintptr_t address)
4444

4545
static void powerdown_nvic()
4646
{
47-
int isr_count;
47+
int isr_groups_32;
4848
int i;
4949
int j;
5050

51-
isr_count = (SCnSCB->ICTR & SCnSCB_ICTR_INTLINESNUM_Msk) >> SCnSCB_ICTR_INTLINESNUM_Pos;
52-
for (i = 0; i < isr_count; i++) {
51+
isr_groups_32 = ((SCnSCB->ICTR & SCnSCB_ICTR_INTLINESNUM_Msk) >> SCnSCB_ICTR_INTLINESNUM_Pos) + 1;
52+
for (i = 0; i < isr_groups_32; i++) {
5353
NVIC->ICER[i] = 0xFFFFFFFF;
5454
NVIC->ICPR[i] = 0xFFFFFFFF;
5555
for (j = 0; j < 8; j++) {

0 commit comments

Comments
 (0)