问题
开发bootloader中,在跳转到应用程序时,重设中断向量表
static __asm void asmJump(unsigned int addr){
/* goto applicant */
LDR SP,[R0]
ADD R0,#0x4
LDR R1,[R0]
BX R1
}
static void stm32l431GotoApplicant(unsigned int addr){
/* set vector register */
SCB->VTOR = addr;
asmJump(addr);
}
跳到应用程序之后,无法进入任何中断
如果把重设中断向量表的语句放在应用程序中来做
int main(void){
// xxx
SCB->VTOR = xxxxaddr;
// xxx
return 0;
}
运行正常
原因
在system_stm32l4xx.c中的SystemInit函数中对中断向量表重新设置
/* Configure the Vector Table location add offset address ------------------*/
#ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif
所以合适的做法是修改system_stm32l4xx.c中的宏VECT_TAB_OFFSET的值,达到重设中断向量表的目的。