Skip to content

Commit 3c14cb6

Browse files
committed
Fix mbed_start_application on Cortex-M23
1. M23 doesn't support ICTR and supports up to 240 external interrupts. 2. Fix reset of SHPR 3. Fix inline assembly compile error with ARMC6
1 parent 646f614 commit 3c14cb6

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

platform/mbed_application.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ static void powerdown_nvic()
4949
int j;
5050

5151
#if defined(__CORTEX_M23)
52-
isr_groups_32 = 16;
52+
// M23 doesn't support ICTR and supports up to 240 external interrupts.
53+
isr_groups_32 = 8;
5354
#else
5455
isr_groups_32 = ((SCnSCB->ICTR & SCnSCB_ICTR_INTLINESNUM_Msk) >> SCnSCB_ICTR_INTLINESNUM_Pos) + 1;
5556
#endif
@@ -76,13 +77,19 @@ static void powerdown_scb(uint32_t vtor)
7677
SCB->AIRCR = 0x05FA | 0x0000;
7778
SCB->SCR = 0x00000000;
7879
// SCB->CCR - Implementation defined value
80+
#if defined(__CORTEX_M23)
81+
for (i = 0; i < 2; i++) {
82+
SCB->SHPR[i] = 0x00;
83+
}
84+
#else
7985
for (i = 0; i < 12; i++) {
80-
#if defined(__CORTEX_M7) || defined(__CORTEX_M23)
86+
#if defined(__CORTEX_M7)
8187
SCB->SHPR[i] = 0x00;
8288
#else
8389
SCB->SHP[i] = 0x00;
8490
#endif
8591
}
92+
#endif
8693
SCB->SHCSR = 0x00000000;
8794
#if defined(__CORTEX_M23)
8895
#else
@@ -118,12 +125,8 @@ __asm static void start_new_application(void *sp, void *pc)
118125
void start_new_application(void *sp, void *pc)
119126
{
120127
__asm volatile (
121-
#if defined(__CORTEX_M23)
122-
"movw r2, #0 \n"
128+
"movw r2, #0 \n" // Fail to compile "mov r2, #0" with ARMC6. Replace with movw/movt.
123129
"movt r2, #0 \n"
124-
#else
125-
"mov r2, #0 \n"
126-
#endif
127130
"msr control, r2 \n" // Switch to main stack
128131
"mov sp, %0 \n"
129132
"msr primask, r2 \n" // Enable interrupts

0 commit comments

Comments
 (0)