zoukankan      html  css  js  c++  java
  • STM32 进行软件复位的方法

    platform:stm32f103xx
    include:core_cm3.h

    /**
      rief   System Reset
      details Initiates a system reset request to reset the MCU.
     */
    __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();
      }
    }
    
    /**
      rief   Set Fault Mask
      details Assigns the given value to the Fault Mask register.
      param [in]    faultMask  Fault Mask value to set
     */
    __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
    {
      register uint32_t __regFaultMask       __ASM("faultmask");
      __regFaultMask = (faultMask & (uint32_t)1U);
    }
    

    直接调用soft_reset即可,亲测有效。

    void soft_reset(void)
    {
    	// 关闭所有中断
        __set_FAULTMASK(1); 
        // 复位
        NVIC_SystemReset(); 
    }
    
  • 相关阅读:
    初级Linux学习指南
    2016/09/29 SQL中的join
    2016/09/27 Hadoop Yarn
    2016/06/27 HDFS概述
    2016/09/26 电能和电功率
    【转】2016/09/22 MapReduce初级案例
    2016/09/22 mapreduce
    2016/09/21 java关键字static
    2016/09/21 Java关键字final
    2016/09/21 java split用法
  • 原文地址:https://www.cnblogs.com/unclemac/p/12783365.html
Copyright © 2011-2022 走看看