当前位置:首页 > 单片机 > 单片机
[导读]  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 a

  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 WST 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 + 1;

*pWdtClear = 0x5743;

}


本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

Microchip公司的PIC32MZ EF系列是高达250MHz的集成浮点单元(FPU),具有广泛的外设和包括局域网(CAN)的极好的连接选择,工作电压2.1V到 3.6V,DSP增强核具有四

关键字: Microchip pic32mz 处理器

使用的是STM32F407的板子,程序参考的是STM32F4xx固件库的DAC_SignalsGeneration文件夹下的程序。官方例程分别使用了DAC的禁止生成波(DAC_WaveGeneration_None)的E...

关键字: dac dma STM32 timer 输出正弦波

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

关键字: interrupt pic32mz timer tutorial

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

关键字: pic32mz tutorial change notification

型号:Watchdog,8XC552关键字:Watchdog,87C552单片机,监视定时器简介:介绍了以Philips公司的8XC552单片机为主控芯片开发的智能配电监测仪硬件电路的组成和系统工作原理

关键字: Philips watchdog 嵌入式开发

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

关键字: interrupt pic32mz tutorial external

本文将介绍看门狗驱动的实现。目标平台:TQ2440CPU:s3c2440内核版本:2.6.301. 看门狗概述 看门狗其实就是一个定时器,当该定时器溢出前必须对看门狗进行"喂狗“,如果不这样做,定时器溢出后则将...

关键字: s3c2440 watchdog 看门狗

#include #include #include #define uchar unsigned char#define uint unsigned int#define SET_LEDPORT...

关键字: watchdog 测试 程序

经过千辛万苦,今天终于完工PIC32MZ EC Starter Kit的ethernet bootloader项目。我将整个项目, 命名为PhnBootloader。它分为两个部分。第一个部分是PC 端的host程序Ph...

关键字: bootloader ethernet pic32mz udp协议
关闭
关闭