STM32F0 IAP (使用stm32CubeMX)

BootLoader:

main里调用函数跳转到APP地址0x8003000

typedef  void (*pFunction)(void);

#define ApplicationAddress    0x8003000

void UserAppStart(void)
{
	  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();
    }
}

APP:

main 函数添加

#define APPLICATION_ADDRESS     ((uint32_t)0x08003000)
#if   (defined ( __CC_ARM ))
  __IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));
#elif (defined (__ICCARM__))
#pragma location = 0x20000000
  __no_init __IO uint32_t VectorTable[48];
#elif defined   (  __GNUC__  )
  __IO uint32_t VectorTable[48] __attribute__((section(".RAMVectorTable")));
#elif defined ( __TASKING__ )
  __IO uint32_t VectorTable[48] __at(0x20000000);
#endif


  /* USER CODE BEGIN 1 */
	uint32_t i = 0;
  /* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/  
	
  /* Copy the vector table from the Flash (mapped at the base of the application
     load address 0x08003000) to the base address of the SRAM at 0x20000000. */
        
  for(i = 0; i < 48; i++)
  {
    VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
  }
	// Enable the SYSCFG peripheral clock
  __HAL_RCC_SYSCFG_CLK_ENABLE();
  // Remap SRAM at 0x00000000 
  __HAL_SYSCFG_REMAPMEMORY_SRAM();


在Keil下设置IROM1:start 0x8003000 IRAM1:Start 0x200000C0


stm32f0 没有中断偏移寄存器,所以将中断向量表读取到RAM中,然后重映射到RAM地址.



参考:

http://bbs.21ic.com/icview-571430-1-1.html (5L&10L)

http://bbs.21ic.com/icview-822770-1






  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值