【发布时间】:2017-03-28 18:10:16
【问题描述】:
我正在使用标准代码使用 keil uvision 将其他程序闪存到我的 stm32f4 板的闪存中。我需要在我的板上有两个代码。但是我怎样才能将我的程序计数器从一个位置转移到另一个位置,以便在需要时执行这两个程序。
下面是我正在使用的一段代码,但 PC 没有跳转。我认为跳转到应用程序有问题
#include "usbh_core.h"
#include "usbh_usr.h"
#include "usbh_msc_core.h"
#include "flash_if.h"
USB_OTG_CORE_HANDLE USB_OTG_Core;
USBH_HOST USB_Host;
pFunction Jump_To_Application;
uint32_t JumpAddress;
int main(void)
{
BSP_Init();
FLASH_If_FlashUnlock();
if (STM_EVAL_PBGetState(BUTTON_USER) == Bit_RESET)
{
/* Check Vector Table: Test if user code is programmed starting from address
"APPLICATION_ADDRESS" */
if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
{
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
__set_PSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
Jump_To_Application();
}
}
/* Init Host Library */
USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_MSC_cb, &USR_Callbacks);
while (1)
{
/* Host Task handler */
USBH_Process(&USB_OTG_Core, &USB_Host);
}
}
#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t* file, uint32_t line)
{
/* Infinite loop */
while (1)
{}
}
#endif
【问题讨论】:
-
通常通过中断向量进行通信。许多控制器允许将临时向量表映射到 RAM 以方便启动/闪存加载程序。