2021-06-18 07:14 AM
I need a to read and write a simple 16 bit user configuration value that's stored in non-volatile memory. The STM32L0xx is famously short on memory and as such bringing the entire HAL in is out of the question. It swells up the code space well beyond 8k!
Is there a simple way to save and read a value from flash (virtual eeprom)? Maybe a couple of assembly instructions? I can't find an example of this anywhere. It sure would be nice if there was just a simple __no_init pragma that handled the unlock, write, lock... without a lot of HAL or wear leveling complexities.
2021-06-18 08:05 AM
The L0 has a portion of FLASH which is EEPROM-like. There are examples of usage in Appendix A of RM.
jW
2021-06-18 02:37 PM
You can just use the HAL functions you want and it won't increase code size that much. Most of the space is due to complicated clock initialization functions.
Barring that or using EEPROM, using register level access to read/write flash is quite achievable by following the RM. It has details steps. Going to take quite a bit more than a "couple of assembly instructions" though.
There is no FLASH wear leveling done in HAL.
2021-06-18 02:55 PM
The STM32L011 has 512-byte of "True-EEPROM" at least that's what the marketing/pr tosh says.. Using it here for calibration/configuration data
I don't think the assembler would be too complicated