首頁>Club>
7
回覆列表
  • 1 # 使用者834195712159

    程式碼示例:

    /*軟體復位*/

    void G_mcuReset(void)

    {

    printf("\r\n\r\n\r\n%s\r\n\r\n\r\n",__FUNCTION__);

    __set_FAULTMASK(1);

    HAL_NVIC_SystemReset();

    }

    其實HAL_NVIC_SystemReset是

    void HAL_NVIC_SystemReset(void)

    {

    NVIC_SystemReset();

    }

    其實NVIC_SystemReset是

    __STATIC_INLINE void NVIC_SystemReset(void)

    {

    __DSB(); /* Ensure all outstanding memory accesses included

    buffered write are completed before reset */

    SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |

    (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |

    SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */

    __DSB(); /* Ensure completion of memory access */

    for(;;) /* wait until reset */

    {

    __NOP();

    __STATIC_INLINE void NVIC_CoreReset(void)

    {

    __DSB(); /* Ensure all outstanding memory accesses included

    buffered write are completed before reset */

    SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |

    (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |

    SCB_AIRCR_VECTRESET_Msk ); /* Keep priority group unchanged */

    __DSB(); /* Ensure completion of memory access */

    for(;;) /* wait until reset */

    {

    __NOP();

    }

    }

    其實NVIC_CoreReset和NVIC_SystemReset基本一樣 我換了一個SCB_AIRCR_VECTRESET_Msk

    測試:

    void G_CoreReset(void)

    {

    printf("\r\n\r\n\r\n%s\r\n\r\n\r\n",__FUNCTION__);

    __set_FAULTMASK(1);

    HAL_NVIC_CoreReset();

    }

    void HAL_NVIC_CoreReset(void)

    {

    NVIC_CoreReset();

    }

  • 中秋節和大豐收的關聯?
  • “綜合管理部”英文縮寫是什麼?