你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

查看: 5820|回复: 2

关于修改STM8S的FLASH的问题

[复制链接]

5

主题

14

回帖

0

蝴蝶豆

新手上路

最后登录
1970-1-1
发表于 2011-11-11 10:59:24 | 显示全部楼层 |阅读模式
我想在MCU初始化的时候修改FLASH的Option bytes字节,改变它的映射地址,看了下资料,没有弄明白,选用ICP的两种方式好像都需要连接SWIM编程器,通过SWIM编程器控制复位,但是我想把程序烧写进去,让软件自己修改FLASH,不知道该怎么弄,求高手解答。
methods
The in-circuit programming (ICP) method is used to update the content of Flash program
memory and data EEPROM.
The programming interface for STM8 devices is the SWIM (Single Wire Interface Module). It
is used to communicate with an external programming device connected via a cable.
See STM8 SWIM communication protocol and debug module user manual (UM0470) for
more details on the SWIM mode entry and SWIM protocol.
When using the SWIM protocol, two methods can be used:
First method
The first method consists of writing directly into the Flash registers and memory locations
through the write memory command of the SWIM protocol. To make sure that the CPU is
not accessing the memory during block Flash programming, the core must be stalled by
setting the STALL bit in the DM_CSR2 debug module register.
The following sequence is required:
1. Apply a RESET
2. Activate the SWIM by sending the entry sequence on the SWIM pin
3. Activate the SWIM_CSR register by writing 1 to the DM bit in SWIM_CSR
4. Disable interrupts by setting the SAFE_MASK bit in SWIM_CSR
5. Release RESET
6. Verify the DeviceID by reading it using ROTF command
7. Send the SWIM SRST command
8. Unlock the memory by writing the MASS keys
9. Program the Flash program memory using the SWIM WOTF command
Second method
The second method uses the same sequence of operations as the first method except that
the ICP driver firmware must be downloaded in RAM before being launched:
1. Apply a RESET
2. Activate the SWIM by sending the entry sequence on the SWIM pin
3. Activate the SWIM_CSR register by writing 1 to the DM bit in SWIM_CSR
4. Disable interrupts by setting the SAFE_MASK bit in SWIM_CSR
5. Release RESET
6. Verify the DeviceID by reading it using ROTF command
7. Send the SWIM SRST command
8. Unlock the memory by writing the MASS keys
9. Download the ICP driver firmware into the device RAM using the SWIM WOTF
command
10. Execute the ICP driver:
a) Modify the CPU registers (new PC, X, Y, CC...) using the WOTF commands
b) Set the FLASH bit in the DM_CSR2 register
c) Clear the STALL bit in the DM_CSR2 register
回复

使用道具 举报

134

主题

4489

回帖

239

蝴蝶豆

版主

最后登录
2020-12-9
发表于 2011-11-11 15:17:38 | 显示全部楼层

RE:关于修改STM8S的FLASH的问题

你是说对FLASH进行擦写吗?
FLASH在使用的时候要注意:
1、擦除是针对整区FLASH,而不能进行莫个地址的擦除
2、写入的时候,地址必须是偶地址,否则会出现错误
3、同一个地址只能写入1次,如果再想写入,就需要擦除以后再写入了
回复 支持 反对

使用道具 举报

5

主题

14

回帖

0

蝴蝶豆

新手上路

最后登录
1970-1-1
 楼主| 发表于 2011-11-11 20:18:41 | 显示全部楼层

RE:关于修改STM8S的FLASH的问题

我想修改EEPROM中的Option bytes字节,Option bytes用于配置硬件特性和存储器保护状态。我想修改MCU的硬件特性,默认的AFR0不是定时器2的输出通道1,我要把该通道配置为定时器2的通道1,但我不知道该怎样在软件中修改。文档上面说“选项字节可以在ICP/SWIM模式中或IAP模式中修改。”从上面的英文字面看修改时好像都需要连接SWIM,不知道改怎么弄不需要SWIM连接,直接一次烧写完运行软件就修改选项字节,这样有利于生产。
回复 支持 反对

使用道具 举报

关于 意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
13245底部标题123相同标题
12底部标题123相同标题
33333底部标题123相同序号
3435底部标题-无链接
关注我们
st-img 微信公众号
st-img 手机版