Problem saving data in flash memory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-18 12:11 AM
Hello, guys!
I have problem saving data in STM32L0's flash memory.
If I save the data twice in the same location it works fine.
If I save the data once CRC check fails - data writing goes wrong?!
I have attached my code.
Sorry for the "magic" numbers in the code!
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-18 12:58 AM
You are saying:
> eeAddr=DATA_EEPROM_BASE; //Second write to the same location!!!
But your original eeAddr in the top is something different:
> uint32_t eeAddr= (DATA_EEPROM_BASE+ADDR_SEN_SETT);
So that is not the same location is it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-18 1:19 AM
ADDR_SEN_SETT is 0x00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-18 1:25 AM
Try to check what does HAL_FLASHEx_DATAEEPROM_Program function return. Maybe there is an error and you are ignoring it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-18 1:27 AM
Ok!I will check it now!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-18 1:38 AM
Only for the first byte HAL_FLASHEx_DATAEEPROM_Program returns -> HAL_ERROR?!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-18 1:39 AM
For the rest of the bytes HAL_OK is returned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-18 1:43 AM
Well that's it, this is how debugging works. Now try to debug step-by-step into the first call of HAL_FLASHEx_DATAEEPROM_Program function to see what exactly causes it to return HAL_ERROR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-18 2:06 AM
Seems first try to write always returns HAL_ERROR and I have to ignore this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-02-19 12:50 PM
> Seems first try to write always returns HAL_ERROR and I have to ignore this.
Oh please don't just ignore the error. Find out why you get the error and fix that issue. Unless of course you have already used your debugger to step through the call to HAL_FLASHEx_DATAEEPROM_Program() that is returning the error and you proven that the error can be ignored. Then document in your code why you are ignoring the return from that function call. Your future self or some other poor soul who has to maintain that code will thank you.
