Understanding of STM32 flash memory

Publisher:DelightfulSmileLatest update time:2018-06-05 Source: eefocusKeywords:stm32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The flash memory module of STM32f1xxx consists of three parts: main memory, information block and flash memory interface register.

The sizes of the various parts vary from model to model, as can be seen in the data sheet.


The main memory block of small capacity products is 1-32KB, 1KB per page, and the system memory is 2KB.

The main memory block of medium-capacity products is 64-128KB, with 1KB per page and 2KB system memory.

The main storage block of large-capacity products is more than 256KB, with 2KB per page. The system memory is 2KB.


Main memory: This part is used to store code and data constants (such as const type data). For large capacity products, it is divided into 256 pages, each page is 2K bytes. Note that small and medium capacity products have only 1K bytes per page. From the above figure, it can be seen that the starting address of the main memory is 0X08000000. When B0 and B1 are connected to GND, the code starts running from 0X08000000.

Information block: This part is divided into 2 small parts. The startup program code is used to store ST's own startup program for serial port download code. When B0 is connected to V3.3 and B1 is connected to GND, this part of the code is running. User selection bytes are generally used to configure write protection, read protection and other functions.

Flash memory interface register: This part is used to control flash memory reading and writing, etc., and is the control mechanism of the entire flash memory module.


When the internal flash simulates the eeprom, you can operate the main memory space, the program code occupies a part, and leave a part for storing the information you want to store. However, the read and write operations of the simulated eeprom still need to follow the operation method of the flash. In addition, you also need to pay attention to the process precautions of the stm32 flash memory operation


 FLASH_Unlock(); //Unlock

 FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_PGERR|FLASH_FLAG_WRPRTERR);//Clear flag

 FLASH_ErasePage(0x8002000);//Erase

 while(count < 5)
 {
  FLASH_ProgramHalfWord((0x8002000 +count*2),data[count]); //flash is stored as one byte, 16-bit data must be added to the address by 2

  count++;
 
 }

 FLASH_Lock(); //Lock


Keywords:stm32 Reference address:Understanding of STM32 flash memory

Previous article:STM32 memory address map
Next article:Difference between bootloader in stm32 system memory and bootloader in flash

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号