STM32F10x MCU Flash write operation causes interrupt unresponsive problem

I encountered a problem yesterday. When writing data to the Flash of the STM32F103 MCU, the serial port interrupt receiving data will be lost, but the serial port receiving interrupt priority I set is the highest, and there is no place to turn off the global interrupt for a long time ( Except that the global interrupt is turned off when part of the kernel code of the operating system is executed, but it does not take a long time and will not cause loss of serial port data). Under normal circumstances, when no data is written to the Flash, all serial port data can be received normally, and there is no data packet loss phenomenon, but when a write operation (writing a page of 256 words of data) will result in serial port data. lost, resulting in a received frame error.
At first I guessed that the system will block all interrupts when erasing and writing Flash, but there is no reference document to find such instructions. Later, I checked the official document PM0042 "STM32F10xxx Flash Programming Manual.en". There is a very important passage in Page11:
During a write operation to the Flash memory, any attempt to read the Flash memory will
stall the bus. The read operation will proceed correctly once the write operation has
completed. This means that code or data fetches cannot be made while a write/erase
operation is ongoing.
For write and erase operations on the Flash memory (write/erase), the internal RC oscillator
(HSI) must be ON.
The Flash memory can be programmed and erased using in-circuit programming and in-
application programming.

Chinese translation of the first paragraph: During the flash write operation, any attempt to read the flash will lock the bus, and the read flash operation will continue after the flash write operation is completed, which means that the flash cannot be accessed during writing. Code and data in Flash.

This paragraph is confusing, that is, when writing data to the Flash, it cannot read any data saved in the flash, including codes and constants, so if the serial port is interrupted when writing the flash data, the system will The interrupt service code cannot be executed. Failure to execute interrupt service code for a long time can result in data loss (writing a page of data takes too long).

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325648126&siteId=291194637