简体   繁体   中英

STM32F030 System Reset after Flash update

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();
    }

You need to reset the MCU only when you want to application program to restart.

Updating variables in some flash sector does not require application restart. However, make sure your application gets aware of this update so it reads the new values. If the read operation if performed only on startup, the you need to reset your MCU.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM