STM32 flash 記憶體分布介紹

來源:互聯網
上載者:User

標籤:and   上傳   timers   targe   product   start   info   ted   記憶體映射   

摘要:

    本文以STM32F103RBT6為例介紹了片上Flash(Embedded Flash)若干問題,包括Flash大小(記憶體映射)、塊大小、頁面大小、寄存器。這些知識,有利於寫Flash驅動。


一、怎麼看Flash大小

 

1.1 通過型號

    型號會印在MCU表面,可以通過觀察獲得,我的是STM32F103RBT6(以下分析基於這個型號),對照的STM32產品命名,可知STM32F103RBT6的Flash是128KB。

 

()

圖1 Ordering information scheme

 

1.2 通過資料手冊(記憶體映射)

    也可以通過資料手冊得到Flash大小,首先根據型號從官網下得對應的資料手冊Datasheet(點這裡,輸入MCU型號進行檢索。STM32F103RB相關的手冊都在這:http://www.st.com/internet/mcu/product/164487.jsp),開啟找到Memory map這張圖,2紅框所示(圖2紅框放大即為圖3),Flash在記憶體的映射地址0x0800 0000 ~ 0x0801 FFFF,即大小為128KB。通過該方法也可以瞭解到片上Flash的記憶體映射。

圖2 Memory map

 

圖3 Memory map中的SRAM和Flash

 

二、塊大小

    對於系統而言,Flash分為片上Flash(Embedded Flash)和外置Flash。通常說,Flash先分塊再分頁,擦除是按塊進行,這樣的說法應該只是對外置Flash而言,對於片上Flash即可以按頁擦除也可以整塊擦除,英文原文如下[2]:

 

  1. The Flash memory erase operation can be performed at page level or on the whole Flash area (mass-erase). The mass-erase does not affect the information blocks.

 

三、頁面大小

    按1.2的方法下得該MCU的參考手冊,STM32F103RBT6對應的參考手冊為RM0008 Reference manual,定位到Embedded Flash memory章節(也可以通過搜尋0x0800 0000來定位)。STM32有4種Flash module organization,分別是:low-density devices(32KB,1KB/page)、medium-density devices(128KB,1KB/page)、high-density devices(512KB,2KB/page)、connectivity line devices(256KB,2KB/page)、XL-density(devices(1M,2KB/page)。從上面分析可知,STM32F103RBT6的Flash是128KB,可見是medium-density devices,如所示:

圖4 Flash module organization (medium-density devices)

 

四、Flash相關寄存器

Flash寄存器在記憶體的映射如下[1]:

圖5 Memory map中的Flash Interface

Flash各寄存器具體地址如下[2]:

圖6 Flash memory interface registers of medium-density devices

具體到各寄存器功能,位含義,得參考[3],Flash寄存器映射如下:

圖7 Flash register map

五、Information block

Flash中Information block在記憶體映射如下[1]:

圖8 Memory map中的System memory

具體的Flash的Information block地址如下:

圖9 Information block of medium-density devices

 

    System memory包含一段引導程式(當系統從片上Flash啟動會用到),Flash出廠後就不能修改,不曉得我理解得對不對,貼出原文如下[3]:

 

  1. System memory is used to boot the device in System memory boot mode. The area is reserved for use by STMicroelectronics and contains the boot loader which is used to reprogram the Flash memory using the USART1 serial interface. It is programmed by ST when the device is manufactured, and protected against spurious write/erase operations. For further details please refer to AN2606.

 

 

    The option bytes are managed by an embedded Flash Program/Erase Controller (FPEC),詳情見[3]。

 

參考資料:

[1] DS5319: Medium-density performance line ARM-based 32-bit MCU with 64 or 128 KB Flash, USB, CAN, 7 timers, 2 ADCs, 9 communication interfaces(資料手冊) DS5319.pdf   

[2] RM0008: STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and STM32F107xx advanced ARM-based 32-bit MCUs(參考手冊)  註:檔案尺寸太大,上傳不了:-(

[3] PM0075:STM32F10xxx Flash memory microcontrollers(Flash編程手冊) PM0075.pdf 

STM32 flash 記憶體分布介紹

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.