zoukankan      html  css  js  c++  java
  • 单片机TM4C123学习(六):看门狗

    1.头文件和变量定义

    bool g_bFeedWatchdog = true;
    
    #include "driverlib/watchdog.h"

    2.初始化

        // Watchdog Init
        SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
        // Enable the watchdog interrupt.
        IntEnable(INT_WATCHDOG);
        // set the watchdog timer frequency
        WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet()/watchdog_freq);
        // watchdog timer reset enable
        WatchdogResetEnable(WATCHDOG0_BASE);
        // watchdog interrupt handler register
        WatchdogIntRegister(WATCHDOG0_BASE, WatchdogIntHandler);
        // enable watchdog timer
        WatchdogEnable(WATCHDOG0_BASE);

    3.中断句柄

    // watchdog interrupt 
    void WatchdogIntHandler(void)
    {
        // If the watchdog is not feeded timely, the watchdog timer flag will overflow, and then reset
        if(!g_bFeedWatchdog)  return;
        
        // clear the watchdog interrupt flag
        WatchdogIntClear(WATCHDOG0_BASE);
        
        // When the watchdog is running, the green led will twinkle
           if(GPIOPinRead(GREEN_LED_GPIO, GREEN_LED_PIN))    
        {
            GPIOPinWrite(GREEN_LED_GPIO, GREEN_LED_PIN, 0<<4);
        }
        else
        {
            GPIOPinWrite(GREEN_LED_GPIO, GREEN_LED_PIN, 1<<4);
        }
    }

    4.使用示例(main函数里面)

     if (Tempvalue>Temp_Threshold_high)
                 {
                     g_bFeedWatchdog = false;
                 }
                 else if(Tempvalue<Temp_Threshold_low)
                 {
                     g_bFeedWatchdog = false;
                 }
                 else
                 {
                     g_bFeedWatchdog = true;
                 }
  • 相关阅读:
    mysql 数据库【目录】
    Django 模板层
    Django文件下载(通过反向解析)
    Django 的路由系统
    Linux 搭建Django环境 + nginx + virtualenv虚拟环境
    layui 框架之秒传文件 (前端分段 MD5 型成秒传)
    Bootstrap 使用小点总结
    Django 之数据表操作
    前端之旅【目录】
    学习中遇到的小坑坑
  • 原文地址:https://www.cnblogs.com/pursuit1996/p/5070256.html
Copyright © 2011-2022 走看看