王蓓芹
2020-04-07
感觉你这个问题是系统架构问题哦,你要知道,MCU在擦除FLASH的过程中是不同同时取指的,原文如下:An ongoing Flash memory operation will not block the CPU as long as the CPU does notaccess the Flash memory.On the contrary, during a program/erase operation to the Flash memory, any attempt to readthe Flash memory will stall the bus. The read operation will proceed correctly once theprogram/erase operation has completed. This means that code or data fetches cannot bemade while a program/erase operation is ongoing.For program and erase operations on the Flash memory (write/erase), the internal RCoscillator (HSI) must be ON.看出啥意思了吗?在你擦除FLASH的过程中代码是没有办法执行的,因为AHB总线已经被FLASH操作占据了,当然也就没法喂狗了,中断也不能响应,这样一来IWDG复位就很正常了。建议:擦除时一个扇区一个扇区的来,中间间隔喂狗,调整好喂狗时间间隔,算好时间,数据手册有擦除一个扇区所需要的时间参数,自己计算好吧。