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
上一篇:基于STM32从零写操作系统系列---使用官方固件库
下一篇:STM32+IAP方案 实现网络升级应用固件
推荐阅读最新更新时间:2024-11-08 10:26
设计资源 培训 开发板 精华推荐
- 基于GL3520的USB3.0集线器设计
- LM324EDR2G 多反馈带通滤波器运算放大器的典型应用
- OM13537: SA630D演示板
- Sp6699 升压白光 LED 转换器的典型应用
- 用于白光 LED 偏置的 MCP1253 低噪声、正调节电荷泵的典型应用
- MCP2562FD高速CAN灵活数据速率收发器的典型应用
- MPC555CME: MPC555评估板
- DC954A-A,LT6402-6 低失真、低噪声差分放大器/ADC 驱动器的演示板
- NCP1565TELECGEVB:高效隔离式 dc-dc 转换器,BRICK 电信评估板
- AM2G-2418DH30Z ±18V 2 瓦 DC-DC 转换器的典型应用