STM32软件重启失败

现象描述

stm32使用 NVIC_SystemReset()函数软件重启失败

解决方法

找到NVIC_SystemReset()的定义,继续跳转至 __NVIC_SystemReset函数,将其中的 SCB_AIRCR_SYSRESETREQ_Msk 修改为 SCB_AIRCR_VECTRESET_Msk 即可。

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

 

posted @ 2024-05-28 21:36  wfagly  阅读(587)  评论(0)    收藏  举报