Precautions for using FLASH inside STM32 microcontroller

table of Contents

1 Introduction

2. STM32 F1, F4, L1 series internal FLASH partition and size

1. STM32F1 series

2. STM32F4 series

3. STM32L1 series

3. STM32 F1, F4, L1 series internal FLASH programming time

1. STM32F1 series

2. STM32F4 series

3. STM32L1 series


1 Introduction

In addition to storing firmware, the internal FLASH of the microcontroller is often divided into multiple areas to store some parameters or to store the firmware to be updated for OTA upgrade. At this time, it will involve the programming and erasing of the internal FLASH of the microcontroller. STM32 is different. The internal FLASH characteristics and sector size of the series of single-chip microcomputers are not the same. If you do not pay attention to these details, then wait for the pit.

1. FLASH partition and sector size

FLASH erasing is erased by sector, so this is very important. You can view the page (sector) size of the chip by searching for the FLASH_PAGE_SIZE macro globally in the project. The modified macro is defined in stm32xxx_hal_flash.h

2. The state after FLASH is wiped

The FLASH of F1 and F4 series chips will be 0xFFFFFFFF after erasing, while the FLASH of L1 series chips will be 0x00000000 after erasing!!!!!

3. FLASH programming speed

The internal FLASH programming speed of L1 chip is 50 times slower than F1! ! ! So it is normal that it is slower than F1 when using the L1 chip to write data

2. STM32 F1, F4, L1 series internal FLASH partition and size

1. STM32F1 series

For the F1 series of chips, the FLASH main memory of the large-capacity products has a page size of 2K, as shown in [below], while the medium- and small-capacity products have a page size of only 1K.

2. STM32F4 series

Divided into 2 banks, each bank is divided into 12 sectors, the first 4 sectors are 16KB in size, the fifth sector is 64KB in size, and the remaining 7 sectors are 128K in size

3. STM32L1 series

 

3. STM32 F1, F4, L1 series internal FLASH programming time

For information, refer to the Electrical characteristics chapter of the corresponding chip's data sheet

1. STM32F1 series

It can be seen that the maximum erasure time of the FLASH page of the F1 series is 40ms, and the half-word write time is 52.2us. For example, it takes 26.8ms to write 1024 bytes of data by word , which is relatively fast.

2. STM32F4 series

It can be seen that the erasing time of different sectors in the F4 series is different. The word writing time is 16us. For example, it only takes 4ms to write 1024 bytes of data by word, which is very fast.

3. STM32L1 series

It can be seen that the erasing and programming time of the internal FLASH page of the L1 series are both 3.28ms. For example, it takes 840ms to write 1024 bytes of data by word, which is very slow ; but the erasing is

Faster

 

Guess you like

Origin blog.csdn.net/m0_37845735/article/details/108439644