最近做个项目,采用了STM32的IAP升级,采用的是官方的超级终端版本的程序,IAP程序可以使用,下载了很多例程都可以正常运行,但是下载我自己的用户程序进去,不能正常运行,运行到IAP后进入HardFault_Handler;
IAP程序:
int main(void)
{
/* Flash unlock */
FLASH_Unlock();
/* Initialize Key Button mounted on STM3210X-EVAL board */
STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO);
/* Test if Key push-button on STM3210X-EVAL Board is pressed */
if (STM_EVAL_PBGetState(BUTTON_KEY) == 0x00)
{
/* If Key is pressed */
/* Execute the IAP driver in order to re-program the Flash */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDOn(LED1);
IAP_Init();
SerialPutString("
======================================================================");
SerialPutString("
= (C) COPYRIGHT 2010 STMicroelectronics =");
SerialPutString("
= =");
SerialPutString("
= In-Application Programming Application (Version 3.2.0) =");
SerialPutString("
= =");
SerialPutString("
= By MCD Application Team =");
SerialPutString("
======================================================================");
SerialPutString("
");
Main_Menu ();
/* Keep the user application running */
}
else
{
/* Test if user code is programmed starting from address "ApplicationAddress" */
if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)
{
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) ApplicationAddress);
Jump_To_Application();
}
}
while (1)
{}
}
其中#define ApplicationAddress 0x8002000
APP程序
int main(void)
{
SCB->VTOR = FLASH_BASE | 0x02000;
。。。。。。
另外Target中IROM1设置为0x8002000
其他没有特别设置,但是下载了几个例程都可以使用超级终端下载并正常运行,而我自己的用户程序可以下载,一运行就到HardFault_Handler里面,请高手们指引个查找问题的方向,谢谢。
此帖出自
小平头技术问答
一周热门 更多>