Code example - how to write 2 bytes to permanent memory.
Hello,
Is there code example for writing 2 bytes to the permanent memory at runtime, so it will stay there after power off?
For any STM32 or better STM32WB55.
Hello,
Is there code example for writing 2 bytes to the permanent memory at runtime, so it will stay there after power off?
For any STM32 or better STM32WB55.
Small Piece? If using HAL it's likely to pull in a metric shed-ton of other clutter, but at a register level can be done relatively concisely if necessary.
Expectations of Address alignment compatible with the flash array / write-lines
/* Unlock the Flash to enable the flash control register access *************/
HAL_FLASH_Unlock();
/* Clear OPTVERR bit set on virgin samples */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
...
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, DATA_64) == HAL_OK)
...
/* Lock the Flash to disable the flash control register access (recommended
to protect the FLASH memory against possible unwanted operation) *********/
HAL_FLASH_Lock();
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.