我想在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 |
从零开始操作STM8寄存器(风驰iCreate奉献)
【中文资料】初学STM8库函数的中文帮助软件
绝对经典的中文STM8学习手册,淘宝上学习板资料,友情大放送!
【原创教程】风驰iCreate独家开源STM8 27个例程和10多万字的pdf教程
STM8的LCD1602 4线驱动,为什么不工作
【精华资料】由零开始开发STM8
STM8S 的触摸库是如何在主程序中查询键的呢、
【精华资料】STM8的C语言编程1-14讲完整版
【精品教程】STM8系列单片机入门教程系列
STM8 第一次进中断不准【悬赏问答】
RE:关于修改STM8S的FLASH的问题
FLASH在使用的时候要注意:
1、擦除是针对整区FLASH,而不能进行莫个地址的擦除
2、写入的时候,地址必须是偶地址,否则会出现错误
3、同一个地址只能写入1次,如果再想写入,就需要擦除以后再写入了
RE:关于修改STM8S的FLASH的问题