打印
[STM32F0]

STM32F0中断向量表的重定向

[复制链接]
5264|15
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
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 | 只看该作者
重定向到底是个什么概念,中断向量不是在头文件定下来了,是不是自己修改些。

使用特权

评论回复
5
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.

使用特权

评论回复
6
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.
复制向量表从闪存到基地址……?
这个如何理解

使用特权

评论回复
7
st316|  楼主 | 2015-10-23 10:25 | 只看该作者
捉虫天师 发表于 2015-10-22 21:07
重定向到底是个什么概念,中断向量不是在头文件定下来了,是不是自己修改些。 ...

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


如果你的FLASH中只有一个“应用程序”就不必重定向中断向量表了。
如果你的FLASH中同时有两部分代码,通常是一个“Bootloader"和一个“应用程序”,那在你的”应用程序“中,就得重定向中断向量表了,不然在发生中断后,CPU仍然会去地址0开始的位置取中断向量,这样就不对了,因为地址现在地址0处的中断向量表,是"Bootloader"的而不是你的”应用程序“的中断向量表。所以,在FLASH中同时有一个“Bootloader"和一个“应用程序”的情况下,就必须得在”应用程序“中重定向中断向量表,让它指向正确的位置。

使用特权

评论回复
8
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中的中断向量表又是之前从”应用程序“的中断向量表拷贝过来的,所以,最终其实是取的”应用程序“的中断向量表。

使用特权

评论回复
9
309030106| | 2015-10-23 13:42 | 只看该作者
中断向量表重定向干什么呢

使用特权

评论回复
10
yiyigirl2014| | 2015-10-23 21:04 | 只看该作者
好复杂,还是用默认的中断方式最好了,搞的复杂的,难以理解。

使用特权

评论回复
11
尤彼卡| | 2015-10-23 22:34 | 只看该作者
感谢分享,貌似是高手们玩的

使用特权

评论回复
12
gejigeji521| | 2015-10-24 21:29 | 只看该作者
这真是高手们玩的东西。太棒了

使用特权

评论回复
13
gmm2015| | 2015-10-26 15:14 | 只看该作者
做“在应用可升级”有用

使用特权

评论回复
14
捉虫天师| | 2015-10-27 09:14 | 只看该作者
地址0x0000003C里面存放的是SysTick的中断向量(即SysTick中断服务程序的入口地址),这么看Systick应该是个硬件设备了。

使用特权

评论回复
15
zcl143| | 2016-4-22 18:42 | 只看该作者
今天试了,可以搞

使用特权

评论回复
16
zcl143| | 2016-4-22 18:43 | 只看该作者
多谢楼主分享我也找到了这个文档

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

21

主题

167

帖子

3

粉丝