[STM32F0] STM32F0中断向量表的重定向

[复制链接]
 楼主| st316 发表于 2015-10-22 18:12 | 显示全部楼层 |阅读模式
F1系列的可以实现中断向量表的重新映射,请问F0系列的可以吗?

在M0的编程手册里,没有看到像M3那样的System control block->Vector table offset register?

谢谢!
 楼主| st316 发表于 2015-10-22 19:00 | 显示全部楼层
噢,在Reference manual里找到答案了。

Physical remap

Once the boot mode is selected, the application software can modify the memory accessible in the code area. This modification is performed by programming the MEM_MODE bits in the SYSCFG configuration register 1 (SYSCFG_CFGR1). Unlike Cortex® M3 and M4, the M0 CPU does not support the vector table relocation. For application code which is located in a different address than 0x0800 0000, some additional code must be added in order to be able to serve the application interrupts.

A solution will be to relocate by software the vector table to the internal SRAM:
• Copy the vector table from the Flash (mapped at the base of the application load address) to the base address of the SRAM at 0x2000 0000.
• Remap SRAM at address 0x0000 0000, using SYSCFG configuration register 1.
• Then once an interrupt occurs, the Cortex®-M0 processor will fetch the interrupt handler start address from the relocated vector table in SRAM, then it will jump to execute the interrupt handler located in the Flash.

This operation should be done at the initialization phase of the application. Please refer to AN4065 and attached IAP code from www.st.com for more details.
玛尼玛尼哄 发表于 2015-10-22 20:00 | 显示全部楼层
总是有人想当高手,去研究这些深奥的事情。
捉虫天师 发表于 2015-10-22 21:07 | 显示全部楼层
重定向到底是个什么概念,中断向量不是在头文件定下来了,是不是自己修改些。
huangcunxiake 发表于 2015-10-22 22:40 | 显示全部楼层
Then once an interrupt occurs, the Cortex®-M0 processor will fetch the interrupt handler start address from the relocated vector table in SRAM, then it will jump to execute the interrupt handler located in the Flash.
yiyigirl2014 发表于 2015-10-23 09:06 | 显示全部楼层
Copy the vector table from the Flash (mapped at the base of the application load address) to the base address of the SRAM at 0x2000 0000.
复制向量表从闪存到基地址……?
这个如何理解
 楼主| st316 发表于 2015-10-23 10:25 | 显示全部楼层
捉虫天师 发表于 2015-10-22 21:07
重定向到底是个什么概念,中断向量不是在头文件定下来了,是不是自己修改些。 ...

复位后,CPU会从地址0x00000000处取SP的值,然后从地址0x00000004处取出PC的初始值——这个值就是复位向量。
接下来,地址0x00000008里存放的则是NMI中断向量,
...
地址0x0000003C里面存放的是SysTick的中断向量(即SysTick中断服务程序的入口地址),
...
2015-10-23_10-19-55.png

如果你的FLASH中只有一个“应用程序”就不必重定向中断向量表了。
如果你的FLASH中同时有两部分代码,通常是一个“Bootloader"和一个“应用程序”,那在你的”应用程序“中,就得重定向中断向量表了,不然在发生中断后,CPU仍然会去地址0开始的位置取中断向量,这样就不对了,因为地址现在地址0处的中断向量表,是"Bootloader"的而不是你的”应用程序“的中断向量表。所以,在FLASH中同时有一个“Bootloader"和一个“应用程序”的情况下,就必须得在”应用程序“中重定向中断向量表,让它指向正确的位置。
 楼主| st316 发表于 2015-10-23 11:18 | 显示全部楼层
yiyigirl2014 发表于 2015-10-23 09:06
Copy the vector table from the Flash (mapped at the base of the application load address) to the bas ...

意思应该是:先将”应用程序“的中断向量表拷贝至SRAM中,然后在配置SYSCFG寄存器的最低两位,将SRMA映射至地址0,这样,在发生中断后,CPU从地址0取中断向量,这样实际上就是从SRAM中取的中断向量,而SRAM中的中断向量表又是之前从”应用程序“的中断向量表拷贝过来的,所以,最终其实是取的”应用程序“的中断向量表。
309030106 发表于 2015-10-23 13:42 | 显示全部楼层
中断向量表重定向干什么呢
yiyigirl2014 发表于 2015-10-23 21:04 | 显示全部楼层
好复杂,还是用默认的中断方式最好了,搞的复杂的,难以理解。
尤彼卡 发表于 2015-10-23 22:34 | 显示全部楼层
感谢分享,貌似是高手们玩的
gejigeji521 发表于 2015-10-24 21:29 来自手机 | 显示全部楼层
这真是高手们玩的东西。太棒了
gmm2015 发表于 2015-10-26 15:14 | 显示全部楼层
做“在应用可升级”有用
捉虫天师 发表于 2015-10-27 09:14 | 显示全部楼层
地址0x0000003C里面存放的是SysTick的中断向量(即SysTick中断服务程序的入口地址),这么看Systick应该是个硬件设备了。
zcl143 发表于 2016-4-22 18:42 | 显示全部楼层
今天试了,可以搞
zcl143 发表于 2016-4-22 18:43 | 显示全部楼层
多谢楼主分享我也找到了这个文档
您需要登录后才可以回帖 登录 | 注册

本版积分规则

21

主题

167

帖子

3

粉丝
快速回复 在线客服 返回列表 返回顶部

21

主题

167

帖子

3

粉丝
快速回复 在线客服 返回列表 返回顶部