In STM32F030 controller I want to write certain variables on Flash memory. Also, in runtime, those variables may get changed. So, when change in value of variable is detected, I'm erasing flash and again write.
Question : Do I need to do System reset every time the update in variable detected ?
Below is my code.
void FlashWrite(void)
{
//Channel A
SlaveHolding_New[0] = SlaveHoldingReg[0];
if(SlaveHolding_Prev[0]!=SlaveHolding_New[0])
{
Flash_Erase();
Flash_WORD_Write(FLASH_ADD_CH1, SlaveHolding_New[0]);
Flash_WORD_Write(FLASH_ADD_CH2, SlaveHolding_New[1]);
Flash_WORD_Write(FLASH_ADD_CH3, SlaveHolding_New[2]);
Flash_WORD_Write(FLASH_ADD_CH4, SlaveHolding_New[3]);
SlaveHolding_Prev[0] = SlaveHolding_New[0];
//HAL_NVIC_SystemReset();
}