Saving Information in Flash-Memory without Erasing Cycle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-29 9:56 AM
Hello,
I want to realize a startup-counter in a STM32L0xxx MCU.
This means a counter which counts how often the MCU is doing a power fail and restart for the whole life.
I want to save the actual counter-value in the flash memory.
But I don't want to kill the flash-memory-cells with more than 10k write an erase-cycles.
To solve this I want to save the counter-value without erasing-cycles:
Is it possible to write to a flash-cell more than one time without an erase cycle if I only want to *set* the bits? I know it is not possible to clear a bit.
A flash page has a capacity of 128Bytes. If I use every single bit for a counter-step, I can save 128x8=1024 counter-steps without an erase-cycle.
I've tested this, but I get some strange effects.
Is there a reason for this effects?
Maybe multi-level-flash-cells or ECC-correction?
Best regards
Andreas Fecht
- Labels:
-
Flash
-
STM32L0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-29 10:04 AM
What kind of strange effect?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-29 10:30 AM
The following happens:
At an erased page all bits are cleared to 0.
My CPU (STM32L051) supports only a 32-Bit Flash HAL writing method (FLASH_TYPEPROGRAM_WORD).
For example:
Start at a flash adress with value 0x00000000
first set to 0x000000FF -> works
second set to 0x0000FFFF -> works
third set to 0x00FFFFFF -> works
at the next step I want to set it to 0xFFFFFFFF
and I get 0xBFFFFFFF back
Best regards
Andreas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-29 11:13 AM
Journal a write of words over a whole sector, pick the largest one, and increment that putting it in the next cell. Erase when you fill the whole sector, writing the old count at the front.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-29 11:15 AM
Not multi-level, but the flash lines are quite wide and 32-bits have additional bits of ECC/Hamming, which is why changing the word breaks things.
I don't see them mention it, but I'd assume at least 4-bits, so 32-bit stored as 36-bit. Sure you could extract specifics from an FAE.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-29 2:25 PM
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-29 3:01 PM
Thank You,
I think this helps me for my next Project.
I'm searching also for such a counter if a MCU has no internal EEPROM
Best regards
Andreas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-29 3:38 PM
> I'm searching also for such a counter if a MCU has no internal EEPROM
If you're talking about a different mcu, then you have to read the relevant chapters in that mcu's datasheet and reference manual. There's no universal answer to FLASH-related questions.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-31 9:01 PM
"Is it possible to write to a flash-cell more than one time without an erase cycle if I only want to *set* the bits? I know it is not possible to clear a bit."
Isn't it the other way around? Usually erasing sets all bits? And you program the zeroes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-01 12:46 AM
This depends on the CPU-type.
This L0-series set all erased bits to 0.
I also use A L4-Type which set all erased Bits to 1.
Best regards
Andreas
