Watchdog is a very necessary module for embedded system. Someone said that embedded system operates without watchdog enabled just like the car without air bag. You should always enabled watchdog as possible as you can.

  The PIC32MZ Watchdog Timer (WDT), when enabled, operates from the internal Low-Power RC (LPRC) Oscillator clock source which is 32.768 KHz. The WDT can be used to detect system software malfunctions by resetting the device if the WDT is not cleared periodically in software. The WDT can be configured in Windowed mode or non-Windowed mode. Various WDT time-out periods can be selected using the WDT postscaler. The WDT can also be used to wake the device from Sleep or Idle mode.

  At the moment, I implement the primary function of the WDT is to reset the processor in the event of a software malfunction. I enable WDT with Non-Windowed mode, and the WDT will increment until it overflows or "times out". A WDT time-out will force a device Reset, except during Sleep or Idle modes. To prevent a WDT time-out Reset, my application always periodically clear the WDT by writing a key word 0x5743 to the WDTCLEKEY (WDTCON<31:16>) through a single 16-bit write (for some other devices, or by setting the WDTCLR (WDTCON<0>).

  The WDT is enabled or disabled by the device configuration bits or controlled through software by writing to the WDTCON register. In my application I just set the device configuration bits like below.

#pragma config WDTPS = PS32 // Watchdog Timer Postscaler (1:32)
#pragma config WDTSPGM = STOP // Watchdog Timer Stop During Flash Programming (WDT stops during Flash programming)
#pragma config WINDIS = NORMAL // Watchdog Timer Window Mode (Watchdog Timer is in non-Window mode)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Disabled)
#pragma config FWDTWINSZ = WINSZ_25 // Watchdog Timer Window Size (Window size is 25%)

  The setting as above, the postscaler of Watchdog Timer is 32. It determines the period of Watchdog Timer overflow is 32ms. The FWDTEN Configuration bit is clear, so I need enable Watchdog Timer by software, and I also need a function to clear Watchdog and call this function periodically in the main loop. Below is my implementation of them.

  

void Wdt_Init(void)
{
WDTCONSET = 0x8000;
} void Wdt_Refresh(void)
{
unsigned short *pWdtClear = (unsigned short *)0xBF800800 + ;
*pWdtClear = 0x5743;
}

PIC32MZ tutorial -- Watchdog Timer的更多相关文章

  1. PIC32MZ tutorial -- 32-bit Timer

    The microcontroller is PIC32MZ2048ECH144 on the PIC32MZ EC Starter Kit. This microcontroller has fou ...

  2. PIC32MZ tutorial -- Core Timer

    Core Timer is a very popular feature of PIC32 since it is a piece of the MIPS M4K core itself and is ...

  3. PIC32MZ tutorial -- OC Interrupt

    In my previous blog "PIC32MZ tutorial -- Output Compare", I shows how to apply Output Comp ...

  4. PIC32MZ tutorial -- External Interrupt

    In my older blog "PIC32MZ tutorial -- Key Debounce", I shows how to acheive key debounce w ...

  5. PIC32MZ tutorial -- Output Compare

    Output Compare is a powerful feature of embedded world. The PIC32 Output Compare module compares the ...

  6. PIC32MZ tutorial -- Hello World

    Today I implement "Hello World" on PIC32MZ EC starter kit. The application of "Hello ...

  7. PIC32MZ tutorial -- Timer Interrupt

    An interrupt is an internal or external event that requires quick attention from the controller. The ...

  8. PIC32MZ tutorial -- Input Capture

    Today I accomplish a simple application for PIC32MZ EC Starter Kit. This application uses Input Capt ...

  9. PIC32MZ tutorial -- Change Notification

    In my last post I implement "Key Debounce" with port polling, port polling is not very eff ...

随机推荐

  1. php大力力 [046节] 兄弟连高洛峰 PHP教程 2015年[最新最新最新最新最新]

    兄弟连高洛峰老师新版PHP视频教程列表[每日更新] http://bbs.lampbrother.net/read-htm-tid-160506.html HTML部分1.[2015]兄弟连高洛峰 H ...

  2. RabbitMQ/JAVA 客户端测试(补:利用线程)

    上次进行了简单的连接测试.这次主要进行一下小小的补充.利用线程将生产者消费者代码合到一个文件中. 我是将Recv.java(消费者)文件放在一个线程里添加到Send.java(生产者)中. 代码如下: ...

  3. Python 入门指南

    Release: 3.4 Date: March 29, 2014 Python 是一门简单易学且功能强大的编程语言. 它拥有高效的高级数据结构,并且能够用简单而又高效的方式进行面向对象编程. Pyt ...

  4. android切换屏幕时的生命周期

    老版本总结: 1.不设置Activity的android:configChanges时 切屏会重新调用生命周期的方法,切横屏调用1次 切竖屏调用2次 2.设置Activity的android:conf ...

  5. Gym 100851K

    Problem King's Inspection 题目大意 给一张n个点m条边的无向图,问是否存在一条欧拉回路. n<=10^5, 0<=m<=n+20. 解题分析 注意到数据范围 ...

  6. cdh5.7权限测试示例

    转载请注明出处:http://www.cnblogs.com/xiaodf/ 本文旨在展示CDH基于Kerberos身份认证和基于Sentry的权限控制功能的测试示例. 1. 准备测试数据 cat / ...

  7. 解决 Redis Cluster 扩容故障

    双11啦,为了给商品详细redis进行扩容,扩容动作就放在了今天晚上进行,很不巧,今天晚上是个多事之秋: 做了次数据恢复,做了次集群迁移,在迁移的时候还踩了个坑! 集群中有个节点挂掉了,并且报错信息如 ...

  8. mongodb,redis,hbase 三者都是nosql数据库,他们的最大区别和不同定位是什么?

      不严谨地讲,Redis定位在"快",HBase定位于"大",mongodb定位在"灵活". NoSQL的优点正好就是SQL的软肋,而其弱 ...

  9. 有一个无效 SelectedValue,因为它不在项目列表中。

    在项目中出现绑定下拉框报错的问题 1:可能是先赋值,再绑定数据的问题 检查代码,是否有在数据绑定钱进行了赋值.

  10. CSS——几个最新解决方案

    一.重置默认样式 normalize.css ①不像其他CSSreset,它保存了一些有用的默认样式. ②规范了大量样式,纠正了一下bug与表现形式. ③有详细的注释解释代码的作用. 二.清除浮动 / ...