我使用STM32_USB-FS-Device_Lib_V3.2.\Project\Device_Firmware_Upgrade\EWARMv5\DFU例程,进行IAP实验,IAP下载成功了,但下载进去的程序没有运行。
if (DFU_Button_Read() != 0x00)
{ /* Test if user code is programmed starting from address 0x8004000 */
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();
}
} /* Otherwise enters DFU mode to allow user to program his application */
/* Enter DFU mode */
DeviceState = STATE_dfuERROR;
DeviceStatus[0] = STATUS_ERRFIRMWARE;
DeviceStatus[4] = DeviceState;
Set_System();
Set_USBClock();
USB_Init();
/* Main loop */
while (1)
{
}
查代码发现Jump_To_Application();好像没有起作用。前一句将(*(__IO uint32_t*) ApplicationAddress载入了MSP。
单步调试发现,程序在Jump_To_Application();运行了几步,继续向下,一直运行到了while(1).
不知是怎么回事?盼高手解答。 |