STM32F0xx IAP實現之中斷向量表重定義
具體實現程式碼如下: /*
* Function: void JumpToApp(void)
* Parameter: none
* Return: none
*/
static void JumpToApp(void)
{
ApplicationAddress = APP_FLASHADDR;
if (((*(uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)
{
/* Jump to user application */
m_JumpAddress = *(uint32_t*) (ApplicationAddress + 4); /*最開頭4個位元組存放MSP的初始值,從這之後的4個位元組存放 ResetHandler中斷向量*/
JumpToApplication = (FunVoidType) m_JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(uint32_t*) ApplicationAddress);
JumpToApplication();
}
} /*
* Function: void clock_init(void)
* Parameter: none
* Return: none
*/
int main(void)
{
memcpy((void*)0x20000000, (void*)APP_FLASHADDR, 0x100);
SYSCFG->CFGR1 |= 0x03;
JumpToApp();
while (1);
}