私はstil32f4ボードのフラッシュメモリにkeil uvisionを使用して他のプログラムをフラッシュする標準コードを使用しています。私は私のボードに両方のコードを持っている必要があります。しかし、プログラムカウンターをある場所から別の場所に移して、必要に応じて両方のプログラムを実行するにはどうしたらいいですか?
以下は私が使用しているコードですが、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にマッピングして、ブート/フラッシュローダを容易にします。 – ThingyWotsit
http://stackoverflow.com/questions/26891432/jump-to-bootloader-in-stm32-through-appliction-ie-using-boot-0-and-boot-1-pinsの可能な複製 –