Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32 internal EEPROM (E2PROM) #3929

Open
Resonanz opened this issue Feb 28, 2025 · 0 comments
Open

STM32 internal EEPROM (E2PROM) #3929

Resonanz opened this issue Feb 28, 2025 · 0 comments

Comments

@Resonanz
Copy link

Resonanz commented Feb 28, 2025

Question: Does Embassy support unlocking / reading / writing to INTERNAL EEPROM memory in devices such as the STM32L0xx and STM32Lxx series?

These devices are described as having (for example):

Memories
– Up to 192-Kbyte Flash memory with ECC (2 banks with read-while-write capability)
– 20-Kbyte RAM
– 6 Kbytes of data EEPROM with ECC

or again:

The non-volatile memory is divided into three arrays:
– 128 or 192 Kbytes of embedded Flash program memory
– 6 Kbytes of data EEPROM
– Information block containing 32 user and factory options bytes plus Kbytes of system memory

Flash program and data EEPROM are divided into two banks. This allows writing in one
bank while running code or reading data from the other bank. (p.26)

30 year data retention and 100 k write cycles are also mentioned.

Reference: https://www.mouser.com/datasheet/2/389/stm32l082kb-1851150.pdf

The ST Reference Manual RM0367 describes in the code examples Appendix on pages 973-979 how to write to EEPROM (and FLASH ) using C. e.g.

A.3.1 Unlocking the data EEPROM and FLASH_PECR register code example
A.3.2 Locking data EEPROM and FLASH_PECR register code example
A.3.5 Write to data EEPROM code example
A.3.6 Erase to data EEPROM code example

and then for FLASH memory:

A.3.9 Program a single word to Flash program memory code example
A.3.10 Program half-page to Flash program memory code example
A.3.11 Erase a page in Flash program memory code example
A.3.12 Mass erase code example

The example code for writing a byte (or 2, or 4 bytes) is given below:

A.3.5 Write to data EEPROM code example

*(uint8_t *)(DATA_E2_ADDR+i) = DATA_BYTE;
*(uint16_t *)(DATA_E2_ADDR+j) = DATA_16B_WORD;
*(uint32_t *)(DATA_E2_ADDR) = DATA_32B_WORD;
DATA_E2_ADDR is an aligned address in the data EEPROM area.
i can be any integer.
j must be an even integer

Reference: https://www.st.com/resource/en/reference_manual/rm0367-ultralowpower-stm32l0x3-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant