STM32 软件 复位 NVIC_SystemReset

软件开发过程中会遇到各种问题,有时改别人写的程序更是困难重重,有必要可以使用软件复位帮助解决些问题。

系统复位函数 NVIC_SystemReset();

void SoftReset(void)
{
__set_FAULTMASK(1);      // 关闭所有中端
NVIC_SystemReset();// 复位
}
//在官方软件库的 core_cm3.h 文件里 直接提供了 系统复位的函数 
  
static __INLINE void NVIC_SystemReset(void)
{
  SCB->AIRCR  = ((0x5FA << SCB_AIRCR_VECTKEY_Pos)      | 
                           (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | 
                           SCB_AIRCR_SYSRESETREQ_Msk);                   /* Keep priority group unchanged */
  __DSB();                                                                                       /* Ensure completion of memory access */              
  while(1);                                                                                        /* wait until reset */
}

猜你喜欢

转载自blog.csdn.net/gd1984812/article/details/106300889