<dl id="b4zrn"><label id="b4zrn"></label></dl><thead id="b4zrn"></thead>

    <blockquote id="b4zrn"></blockquote>

      <strike id="b4zrn"></strike>
        1. <div id="b4zrn"><label id="b4zrn"></label></div>
          您好,歡迎訪問上海意泓電子科技有限責(zé)任公司網(wǎng)站!
          4新聞資訊
          您的位置: 首頁 ->  新聞資訊 -> 單片機(jī)

          ?STM32F030 WWDG使用結(jié)論

          文章出處:單片機(jī) 責(zé)任編輯:上海意泓電子科技有限責(zé)任公司 發(fā)表時(shí)間:
          2020
          11-10

          使用STM32F030的WWDG,發(fā)現(xiàn)其在STOP下面跟STM8S的休眠模式的情況一樣,不會(huì)對MCU進(jìn)行復(fù)位.

          貼上看門狗代碼:

          /*************************************************************************************** 

          **************************************************************************************** 

          * FILE      : wdog_drv.c 

          * Description   :  

          *              

          * Copyright (c) 2015 by LAN. All Rights Reserved. 

          *  

          * History: 

          * Version       Name            Date            Description 

             0.1      藍(lán)曙光 2015/01/28  Initial Version 

              

          **************************************************************************************** 

          ****************************************************************************************/  

            

          #include "wdog_drv.h"  

            

          #define WWDG_Prescaler_8                    ((uint32_t)0x00000180)  

          #define CFR_WDGTB_MASK                      ((uint32_t)0xFFFFFE7F)  

          #define RCC_APB1ENR_WWDGEN                  ((uint32_t)0x00000800)        /*!< Window Watchdog clock enable */  

            

          /*================================================================== 

          * Function  : Wdog_Init 

          * Description   : 看門狗初始化 

          * Input Para    :  

          * Output Para   :  

          * Return Value:  

          ==================================================================*/  

          void Wdog_Init(void)  

          {  

              Wdog_Start();  

              WWDG->CFR |= 0x7F;   //窗口看門狗的上窗口,窗口值必須在0x3F以上,但必須小于計(jì)數(shù)值小于0x7F  

            

              WWDG->CR = 0x7F; //看門狗計(jì)數(shù)值  

            

              Wdog_Feed(0);  

          }  

            

            

            

          /*================================================================== 

          * Function  : Wdog_Start 

          * Description   : 啟動(dòng)開門狗 

          * Input Para    :  

          * Output Para   :  

          * Return Value:  

          ==================================================================*/  

          void Wdog_Start(void)  

          {  

              RCC->APB1ENR |= RCC_APB1ENR_WWDGEN;  

              //設(shè)置分頻時(shí)鐘  

              WWDG->CFR = (WWDG->CFR & CFR_WDGTB_MASK) | WWDG_Prescaler_8;  

            

              WWDG->CR |= 0x80; //使能窗口看門狗   

          }  

            

          /*================================================================== 

          * Function  : Wdog_SetReload 

          * Description   : 重新設(shè)置頻率 

          * Input Para    :  

          * Output Para   :  

          * Return Value:  

          ==================================================================*/  

          void Wdog_SetReload(u8 uTime)  

          {  

            

          }  

            

          /*================================================================== 

          * Function  : Wdog_Feed 

          * Description   : 喂狗 

          * Input Para    :  

          * Output Para   :  

          * Return Value:  

          ==================================================================*/  

          void    Wdog_Feed(u8 uTime)  

          {  

               if ((WWDG->CR & 0x7F) < WWDG->CFR)//小于窗口值才能喂狗    

              {  

                  WWDG->CR |= 0x7F;    //重新喂狗    

               }  

          }  

            

            

            

          /*================================================================== 

          * Function  : Wdog_ResetChip 

          * Description   : 復(fù)位芯片 

          * Input Para    :  

          * Output Para   :  

          * Return Value:  

          ==================================================================*/  

          void Wdog_ResetChip(void)  

          {  

              while ((WWDG->CR & 0x7F) >= WWDG->CFR)  

              {//等待進(jìn)入到喂狗窗口  

              }  

              WWDG->CR &= 0x40;    //喂最小復(fù)位  

              while(1);  


          上海意泓電子科技有限責(zé)任公司 版權(quán)所有 未經(jīng)授權(quán)禁止復(fù)制或鏡像

          CopyRight 2020-2025 m.frontgate.com.cn All rights reserved   滬ICP備2021005866號

          久艹视频在线观看这里只有精品,国语自产拍在线视频普通话94,久久婷婷综合缴情亚洲狠狠,亚洲不卡永远在线精品无码
          <dl id="b4zrn"><label id="b4zrn"></label></dl><thead id="b4zrn"></thead>

            <blockquote id="b4zrn"></blockquote>

              <strike id="b4zrn"></strike>
                1. <div id="b4zrn"><label id="b4zrn"></label></div>