简体   繁体   English

Flash 更新后的 STM32F030 系统复位

[英]STM32F030 System Reset after Flash update

In STM32F030 controller I want to write certain variables on Flash memory.在 STM32F030 controller 中,我想在 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.因此,当检测到变量值发生变化时,我将擦除 flash 并再次写入。

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.只有当您想重新启动应用程序时,您才需要复位 MCU。

Updating variables in some flash sector does not require application restart.更新某些 flash 扇区中的变量不需要重新启动应用程序。 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.如果仅在启动时执行读取操作,则需要重置 MCU。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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