stm32l476 how i can write 32bit data to internal flash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-17 7:08 AM
Hi!!
I worked before them on this crystal stm32f0, stm32f1 series. Recording to the internal flash memory was not a difficult process, which made it fun to work. Why did you make it so complicated, why record 64-bit data?
The question and not only the question, but also it is desirable to show how I now write to flash memory as on that crystalstm32f0
, that is 32-bit data and do not use the library HAL?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-17 7:30 AM
Always write 64-bit entities. Either with single 32 bit data and 32 bit set e.g.to 0xffffffff or with 2 words concatenated as a double word.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-17 7:59 AM
Probably because it makes the hardware design simpler and more efficient for the 99.999% use case at the expense of making the writing 0.001% case a tad more complicated?
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
‎2017-11-17 9:56 PM
Please can you show me code sample write to internal flash not use library HAL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-18 2:18 AM
Tell us what you do not understand from the pseudo code in the L4 reference manual!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-18 4:32 PM
On the 'L47x flash uses ECC, computed across a 64 bit doubleword. That's why you have to write in 64-bit sizes. From what I understand the ECC is calculated at write time, over the entire 64-bit data word, so partial writes aren't supported. Of course you can always read the contents, add in a partial modification and then write again, but that's not how internal flash is intended to be used. You'd be better off with an external EEPROM or a different family with internal EEPROM.
In the code fragment it shows how I first turn on PG to program, write 2 x 32-bit words, wait for the completion interrupt (FreeRTOS xSemaphoreTake in example) or poll for irq flag, and finally clear the PG bit to end the operation. You have to make sure the flash is first erased.
FLASH->
CR
|= FLASH_CR_PG;
// start slow programming operation
*(
uint32_t
*) wrtptr = *bufptr;
// first word to program
wrtptr++;
// next page address
bufptr++;
// next data word
*(
uint32_t
*) wrtptr = *bufptr;
// second word to program, start operation
wrtptr++;
// next page address
bufptr++;
// next data word
oserr = xSemaphoreTake( ifmFlag, Iob->
Var
->
Timeout
);
// wait for operation to complete
if
(oserr == pdTRUE)
fstat = FLASH_GetStatus(Iob->
Var
->
Fstat
);
// results of write
else
fstat =
FLASH_TIMEOUT;
// write timed out
FLASH->
CR
&= (~FLASH_CR_PG);
// clear program operation
Jack Peacock
