<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          STM32窗口看門(mén)狗程序

          作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏


          軟件例程:

          //---------------------------wdg.c-----------------------

          #include "wdg.h"
          #include "led.h"

          u8 wwdg_cnt=0x7f; //窗口看門(mén)狗計(jì)數(shù)器初值

          void wwdg_init(u8 tr,u8 wr,u8 fprer)
          {
          RCC->APB1ENR|=1<<11; //使能WWDG時(shí)鐘
          wwdg_cnt=tr&wwdg_cnt; // 初始化計(jì)數(shù)器值
          WWDG->CFR|=fprer<<7; //設(shè)置頻率時(shí)基
          WWDG->CFR|=1<<9; //使能串口看門(mén)狗中斷
          WWDG->CFR&=0xff80; //窗口值清零
          WWDG->CFR|=wr; //設(shè)定窗口值
          WWDG->CR|=(wwdg_cnt|1<<7); // 啟動(dòng)看門(mén)狗設(shè)置7位計(jì)數(shù)器初值
          MY_NVIC_Init(2,3,WWDG_IRQChannel,2);

          }

          void wwdg_feed(u8 cnt)
          {
          WWDG->CR|=(cnt&0x7f); //喂狗值

          }


          void WWDG_IRQHandler(void)
          {
          u8 tr,wr;
          wr=WWDG->CFR&0x7f;
          tr=WWDG->CR&0x7f;
          if(tr
          WWDG->SR&=0x00; //清楚提前喚醒標(biāo)志位
          LED1=!LED1;
          }


          //------------------------wdg.h---------------------
          #ifndef _wdg_h
          #define _wdg_h

          #include "sys.h"

          void wwdg_init(u8 tr,u8 wr,u8 fprer);
          void wwdg_feed(u8 cnt);

          #endif
          //------------------led.c----------------------
          #include "led.h"

          void led_init(void)
          {
          RCC->APB2ENR|=1<<2;
          RCC->APB2ENR|=1<<5;
          GPIOA->CRH&=0xfffffff0;
          GPIOA->CRH|=0x00000003;
          GPIOD->CRL&=0xfffff0ff;
          GPIOD->CRL|=0x00000300;
          GPIOA->ODR|=1<<8;
          GPIOD->ODR|=1<<2;

          }
          //---------------------led.h------------------
          #ifndef _led_h
          #define _led_h

          #include "sys.h"

          #define LED0 PAout(8)
          #define LED1 PDout(2)

          void led_init(void);

          #endif

          ///-----------------------主函數(shù)------------test.c---------------
          #include

          #include "sys.h"
          #include "delay.h"
          #include "usart.h"
          #include "led.h"
          #include "wdg.h"

          int main(void)
          {
          Stm32_Clock_Init(9);
          delay_init(72);
          uart_init(72,9600);
          led_init();
          wwdg_init(0x7f,0x5f,3);
          LED0=0;
          delay_ms(1800);
          while(1)
          {
          LED0=1;

          }

          }


          上一頁(yè) 1 2 下一頁(yè)

          關(guān)鍵詞: STM32窗口看門(mén)

          評(píng)論


          技術(shù)專(zhuān)區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();