没有合适的资源?快使用搜索试试~ 我知道了~
AN4894 How to use EEPROM emulation on STM32 MCUs
需积分: 5 0 下载量 45 浏览量
2024-03-26
21:38:01
上传
评论
收藏 1.17MB PDF 举报
温馨提示
试读
31页
EEPROM(电可擦可编程只读存储器)用于可更新应用程序数据的非易失性存储,或在复杂系统中发生电源故障时保留少量数据。为了降低成本,只要使用特定的软件算法,就可以用片上闪存代替外部EEPROM。 本应用说明描述了通过模拟替代独立EEPROM的软件解决方案(X-CUBE-EPROM)。 内容是英文。
资源推荐
资源详情
资源评论
Introduction
EEPROMs (electrically erasable programmable read only memories) are used for nonvolatile storage of updatable application
data, or to retain small amounts of data in the event of power failure in complex systems. To reduce cost, an external EEPROM
can be replaced by on-chip flash memory, provided that a specific software algorithm is used.
This application note describes the software solution (X-CUBE-EEPROM) for substituting a standalone EEPROM by emulating
the EEPROM mechanism using the on-chip flash memory available on the STM32 series products listed in Table 1. XCUBE-
EEPROM also provides a firmware package including examples showing how to exploit this EEPROM emulation driver (see
Section 5: API and application examples).
For STM32WB series products only, an example that maintains a Bluetooth® Low-Energy connection and communication while
performing EEPROM operations is provided.
For STM32H5 series products, an example using the high-cycle data area for the EEPROM operations is provided.
The emulation method uses at least two flash memory pages, between which the EEPROM emulation code swaps data as they
become filled. This is transparent to the user. The EEPROM emulation driver supplied with this application note has the
following features:
• Lightweight implementation and reduced footprint.
• Simple API consisting of a few functions to format, initialize, read and write data, and clean up flash memory pages.
• At least two flash memory pages to be used for internal data management.
• Clean-up simplified for the user (background page erase).
• Wear-leveling algorithm to increase emulated EEPROM cycling capability.
• Robust against asynchronous resets and power failures.
• Optional protection implementation for flash memory sharing between cores in multicore STM32 devices (for example
STM32WB series).
• Maintenance of cache coherency.
The EEPROM size to be emulated is flexible and only limited by the flash memory size allocated to that purpose.
Table 1. Application products
Type Series
Microcontrollers
STM32C0 series, STM32G0 series, STM32G4 series, STM32H5 series, STM32L4 series, STM32L4+ series,
STM32L5 series, STM32U0 series, STM32U5 series, STM32WB series, STM32WL series
How to use EEPROM emulation on STM32 MCUs
AN4894
Application note
AN4894 - Rev 9 - March 2024
For further information contact your local STMicroelectronics sales office.
www.st.com
1 General information
This document scopes STM32 microcontrollers that are based on an Arm
®
core.
Note: Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
Reference documents
EEPROM emulation solutions and application notes are available for other STM32 series as listed below.
[1] Application note STM32F0 series EEPROM emulation in STM32F0xx microcontrollers (AN4061)
[2] Application note STM32F1 series EEPROM emulation in STM32F10x microcontrollers (AN2594)
[3] Application note STM32F2 series EEPROM emulation in STM32F2xx microcontrollers (AN3390)
[4] Application note STM32F3 series EEPROM emulation in STM32F30x/STM32F31x STM32F37x/STM32F38x
microcontrollers (AN4056)
[5] Application note STM32F4 series EEPROM emulation in STM32F40x/STM32F41x microcontrollers (AN3969)
[6] Application note Building wireless applications with STM32WB series microcontrollers (AN5289)
[7]
Reference manual STM32H563/H573 and STM32H562 Arm
®
-based 32-bit MCUs (RM0481)
AN4894
General information
AN4894 - Rev 9
page 2/31
2 Main differences between external and emulated EEPROM
EEPROM is a key component of many embedded applications that require nonvolatile storage of data updated
with byte, half-word, or word granularity during runtime. However, microcontrollers used in these systems are very
often based on embedded flash memory. To eliminate components, save PCB space and reduce system costs,
the STM32 flash memory may be used instead of the external EEPROM to store not only code, but also data.
Special software management is required to store data in embedded flash memory. The EEPROM emulation
software scheme depends on many factors, including the required EEPROM reliability, the architecture of the
flash memory used, and the final product requirements, among other parameters.
The main differences between embedded flash memory and external serial EEPROM are the same for any
microcontroller that uses flash memory technology (they are not specific to STM32 series microcontrollers).
One difference is that EEPROMs do not require an erase operation to free up space before data can be written
again. Other major differences are summarized in Table 2.
Table 2. Differences between external and emulated EEPROM
Feature
External EEPROM
(for example, M24C64: I
2
C serial access
EEPROM)
Emulated EEPROM using on-chip flash memory
Write time
• Random byte write in 4 ms. Word program
time = 16 ms
• Page (32 bytes) write 4 ms. Consecutive
words program time = 500 μs
Word program time: from 90 μs to 838 ms
(1)
Erase time N/A
2 Kbytes page-erase time: for instance, 22 ms
(2)
Memory size From a few Kbytes to 2048 Kbytes
Only limited by the size of flash memory allowed for
EEPROM emulation.
Read access
• Serial: 100 μs
• Random word: 92 μs
• Page: 22.5 μs per byte
Parallel: the access time is from 6 μs to 592 μs
(1)
.
Endurance
• 4 million cycles at 25°C
• 1.2 million cycles at 85°C
• 600 kilocycles at 125°C
10 kcycles per page at 105°C(2). Using multiple on‑chip
flash memory pages is equivalent to increasing the number
of write cycles. See Section 4.4: Cycling capability:
EEPROM endurance improvement.
Retention
(2)
• 50 years at 125°C
• 100 years at 25°C
• 7 years at 125°C
• 15 years at 105°C
• 30 years at 85°C
1. For further details, refer to Section 5.3: EEPROM emulation timing.
2. Example data for the STM32L4 series. Refer to the datasheet of your STM32 product.
2.1
Difference in write access time
Flash memories have a shorter write access time allowing critical parameters to be stored faster in the emulated
EEPROM than in an external EEPROM in most cases. However, due to the data transfer mechanism, the
emulated EEPROM write access time sometimes becomes significantly higher.
2.2
Programming and erase operations
Unlike flash memories, EEPROMs do not require an erase operation to free up space before writing to a
programmed address. This is a major difference between a standalone EEPROM and an emulated EEPROM
using embedded flash memory.
AN4894
Main differences between external and emulated EEPROM
AN4894 - Rev 9
page 3/31
• Emulated EEPROM using embedded flash memory
The erase process management is fully handled by the EEPROM emulation software, but the erase
operation is left to application software management. This allows a reduction of the worst case write time,
and also flash page erase operations when the application execution time becomes less critical.
Moreover, as the flash memory programming and erase operations are quite long, power failures and other
spurious events that might interrupt the erase process (such as resets) have been considered when
designing the flash memory management software. The EEPROM emulation software has been designed
to be robust against power failures and fully asynchronous resets.
• Standalone external EEPROM
Once started by the CPU, the writing of a word cannot be interrupted by a CPU reset. Only a supply failure
may interrupt the write process, so power supply monitoring and properly sized decoupling capacitors are
necessary to secure the complete writing process inside a standalone EEPROM.
AN4894
Main differences between external and emulated EEPROM
AN4894 - Rev 9
page 4/31
3 Implementing EEPROM emulation
3.1 Principle
EEPROM emulation can be performed in various ways, considering the flash memory characteristics and final
product requirements. The approach detailed below requires two sets of flash memory pages allocated to
nonvolatile data.
The first set of pages is initially erased and used to store new data and flash memory programming operations are
done sequentially in increasing order of flash memory addresses. Once the first set of pages is full of data, it
needs to be garbage-collected.
The second set of pages collects only the valid data from the first set of pages and the remaining area can be
used to store new data. Once the transfer of valid data to the second set of pages is completed, the first set of
pages can be erased.
Each set of pages can be made up of one or several flash memory pages. For most STM32 series covered by
this document, a header field that occupies the first four 64-bit words (32 bytes) of each page indicates its status,
the exception being the STM32U5 series, where the header occupies the first four 128-bit words (64 bytes).
Each page has five possible states:
• ERASED: the page is empty (initial state).
• RECEIVE: the page used during data transfer to receive data from other full pages.
• ACTIVE: the page is used to store new data.
• VALID: the page is full. This state does not change until all valid data is completely transferred to the
receiving page.
• ERASING: valid data in this page has been transferred. The page is ready to be erased.
Figure 1 shows the page status evolution in the case where each set of pages is made of two pages.
Figure 1. Page status evolution
DT45025V2
Page 0
Init
Write number of variable
elements per page + 1 element
Write 2 * number of variable
elements per page + 1 element
Page 1 Page2 Page 3
ACTIVE ERASED ERASED
VALID ACTIVE ERASED
VALID VALID RECEIVE ERASED
ERASED
Page Transfer Completed with
less than 1 page of valid data
ERASING ERASING ACTIVE ERASED
Page Transfer Completed with
more than 1 page of valid data
ERASING ERASING VALID ACTIVE
OR
Page Erase Completed with
less than one page of valid data
ERASED ERASED ACTIVE ERASED
ERASED ERASED VALID ACTIVE
OR
ERASED
Second set of Flash pagesFirst set of Flash pages
Page Erase Completed with
more than one page of valid data
3.2
Page status valid transitions
The information provided in this paragraph is only useful for users intending to modify the EEPROM emulation
driver. It is not useful for a simple utilization of the driver.
AN4894
Implementing EEPROM emulation
AN4894 - Rev 9
page 5/31
剩余30页未读,继续阅读
资源评论
atonlink
- 粉丝: 100
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Kepware.KEPServerEX.v4.264.401.Incl.Keygen-SSG
- 行人重识别-通过顺序决策实现跨域行人重识别算法-附项目源码-优质项目实战.zip
- HTML、CSS制作家乡介绍网页.zip
- 361050291.apk
- 华硕B250 PLUS支持6789代BIOS
- 基于javaScript开发的图书管理系统+数据库+源码+项目展示+开发文档(毕业设计&课程设计&项目开发)
- HTML+CSS制作的个人博客网页 2.zip
- 华硕B250M-PIXIU支持6789代BIOS
- c# winfrom 音量控制 静音
- 【OpenHarmony】 ArkTS 语法基础 ② ( ArkTS 自定义组件 )
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功