我有一个 KL17,我正在尝试编写一个引导加载程序以允许 OTA 更新。我无法跳转到用户应用程序,这就是我正在尝试的。
void JumpToUserApplication(uint32_t userSP, uint32_t userStartup)
{
printf("MSP BEFORE: %x \n", __get_MSP());
printf("PSP BEFORE: %x \n", __get_PSP());
SCB->VTOR = userSP; // SET UP INTERUPT VECTOR TABLE FOR APP
// set up stack pointer
__set_MSP(userSP);
__set_PSP(userStartup);
void (*user_app)(void) = userStartup;
user_app();
printf("BAD MSP AFTER: %x \n", __get_MSP());
printf("BAD PSP AFTER: %x \n", __get_PSP());
}
我这样称呼它:
JumpToUserApplication(PROGRAM_ADDRESS, (PROGRAM_ADDRESS+0x4));
我希望它跳转到应用程序,但是实际上发生的是引导加载程序实际上重新启动,就好像它回到引导加载程序重置...
WELCOME TO THE BOOTLOADER!
MSP BEFORE: 20005fc0
PSP BEFORE: 20006000
WELCOME TO THE BOOTLOADER!
MSP BEFORE: 20005fc0
PSP BEFORE: 20006000
... and so on.
任何输入表示赞赏,谢谢!