2017-11-19 11:00 PM
I want to write 1byte variable to the internal flash memory.
It works well when I write 4bytes variable like this.
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, Address, vari4) == HAL_OK)
{ Address+=4; }but when I write 1 byte variable to the memory like this, it works only first time.
when I call HAL_FLASH_Program next time it doesn't work and goes to the Hardfault_handler
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Address, vari1) == HAL_OK)
{
Address+=1;
}
Is it impossible to Program single byte data to internal flash memory in stm32l031g6?
2017-11-20 01:57 AM
Read and understand the flash programming section of the reference manual.
In short : erased flash in L0 is set to 0, programming can only set it to '1'. If your second programming tries to set some bits from '1' to '0', things fail.
B.t.w. most other STM32 erase to '1'.
2017-11-20 12:52 PM
In most cases it is more complicated than that because ST uses additional bits for ECC, so you get a single shot at programming