当系统运行受到外部干扰或者系统错误,程序有时会出现跑飞,导致整个系统瘫痪。他会设置一段时间,当超出这段 时间,从程序中跳出进入中断处理程序。WatchDog本质上是一种定时器,那么普通定时器拥有的特性它也应该具备,是的当它计时超时时也会引起事件的发生,只是这个事件除了可以是系统中断外,他也可以是一个系统重启信号(Reset Signal)。可以这么说,能发送系统重启信号的定时器我们就叫它WatchDog。看门狗定时器中断是我们不希望看到的,因此我们要想方设法避免它发生。主要的方法就是在中断发生前,重新对看门狗定时器的寄存器进行赋值,使它的定时器重新开始记时,这种方法俗称喂狗。

S3C6410看门狗定时器的功能:

作为常规时钟,并且可以产生中断

作为看门狗定时器使用,当时钟计数器减为零时,它将产生一个复位信号。

The S3C6410XRISC microprocessor watchdog timer is used to resume the controller operation wheneverit is disturbed by malfunctions such as noise and system errors. The watchdogtimer generates the reset signal.

FEATURES

The WatchdogTimer includes the following features:

? Normal interval timer mode with interruptrequest.

? Internal reset signal is activated when thetimer count value reaches 0 (time-out).

? Level-triggered Interrupt mechanism.

看门狗模块包括一个8位预分频器,一个分频器,一个16bit计数器。它的8位预分频器把PCLK分频后,再被分频得到4种频率,16分频,32分频,64分频,128分频。WatchDog可以选择工作于哪种频率下。S3C2440用3个寄存器对WatchDog进行操作:

看门狗定时器控制寄存器(WTCON)

看门狗定时器数据寄存器(WTDAT)

看门狗定时器计数寄存器(WTCNT)

Figure 34-1shows the functional block diagram of the watchdog timer. The watchdog timeruses only PCLK as its source clock. The PCLK frequency is prescaled to generatethe corresponding watchdog timer clock, and the resulting frequency is dividedagain.

The prescalervalue and the frequency division factor are specified in the watchdog timercontrol (WTCON)register. Valid prescaler values range from 0 to 28-1. Thefrequency division factor can be selected as 16, 32, 64,or 128.

Use thefollowing equation to calculate the watchdog timer clock frequency and theduration of each timer clock cycle:

t_watchdog = 1/( PCLK / (Prescaler value + 1) / Division_factor )

注意:

1、Once the watchdog timer is enabled, the value ofwatchdog timer data (WTDAT) register cannot be automatically reloaded into thetimer counter (WTCNT). For this reason, an initial value must be written to thewatchdog timer count (WTCNT) register, before the watchdog timer starts.

2、When the S3C6410 is in debug mode using EmbeddedICE, the watchdog timer must not operate.The watchdog timer can determinewhether or not it is currently in the debug mode from the CPU coresignal(DBGACK signal). Once the DBGACK signal is asserted, the reset output ofthe watchdog timer is not activated as the watchdog timer is expired.

看门狗寄存器映射:

1、WATCHDOG TIMER CONTROL(WTCON) REGISTER

WTCON允许用户使能看门狗定时器,从不同四个源选择时钟,使能中断,使能看门狗定时器输出。S3C6410看门狗定时器用于系统故障后复位。如果不希望复位,则使能定时器无效。

The WTCONregister allows the user to enable/disable the watchdog timer, select the clocksignal from 4 different sources, enable/disable interrupts, and enable/disablethe watchdog timer output.

The Watchdogtimer is used to resume the S3C6410 restart on mal-function after its power on.At this time,disable the interrupt generation and enable the Watchdog timeroutput for reset signal.

If controllerrestart is not desired and if the user wants to use the normal timer only,which is provided by the Watchdog timer, enable the interrupt generation anddisable the Watchdog timer output for reset signal.

注意:Initial state of ‘Reset enable/disable’ is 1(reset enable). If user do notdisable this bit, S3C6410 will be rebooted in about 5.63sec (In the case ofPCLK is 12MHz). So at boot loader, this bit should be disabled before undercontrol of Operating System, or Firmware.

2、WATCHDOG TIMER DATA (WTDAT) REGISTER

WTDAT用于确定超时期限。WTDAT的内容在最初的定时器操作时不能自动加载到定时器计数其中。但使用0x8000将驱使第一次超时,在这种情况下,WTDAT的值将自动载入WTCNT。

The WTDATregister is used to specify the time-out duration. The content of WTDAT cannotbe automatically loaded into the timer counter at initial watchdog timeroperation. However, using 0x8000 (initial value of WTCNT)will drive the firsttime-out. Then, the value of WTDAT will be automatically reloaded into WTCNT.

3、WATCHDOG TIMER COUNT(WTCNT) REGISTER

The WTCNT register contains the current count values for the watchdogtimer during normal operation.

注意:The content of the WTDAT register cannot be automatically loaded into thetimer count register when the watchdog timer is enabled initially, so the WTCNTregister must be set to an initial value before enabling it.

定义寄存器:

//watchdog

#define WTCON    (*(volatile unsigned *)(0x7E004000))

#define WTDAT    (*(volatile unsigned *)(0x7E004004))

#define WTCNT    (*(volatile unsigned *)(0x7E004008))

初始化函数:

voidinit_watchdog()

{

WTDAT = 0xff;

WTCNT = 0x8000;

WTCON = 0XC021;//Prescaler value为6,16分频

}

在mian函数中调用:

init_watchdog();

while(1);

注意:程序通过友善提供的superboot下载到内存并运行,约2秒后系统复位,PCLK=133M

程序下载:

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

下载在Linux公社的1号FTP服务器里,下载地址:

用户名:www.linuxidc.com

密码:www.muu.cc

在 2012年LinuxIDC.com\3月\深入理解ARM体系架构(S3C6410)-S3C6410看门狗源码实例

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

arm-linux 看门狗,S3C6410看门狗源码实例相关推荐

  1. Linux源码实例,linux下常用二层抓包源码实例

    #include #include #include #include #include /* the L2 protocols */ /* 其中socket_type可以是SOCK_DGRAM,SO ...

  2. 流浪猫流浪狗H5完整运营源码下载/可封装APP

    简介: 流浪猫流浪狗H5完整运营源码下载/可封装APP 适合做猫狗宠物类的发信息发布. 当然其他信息发布也是可以的. 刚刚开发出炉的!亲测可用 网盘下载地址: http://kekewangLuo.n ...

  3. 最新流浪猫流浪狗H5完整运营源码下载/可封装APP

    简介: 最新流浪猫流浪狗H5完整运营源码下载/可封装APP 适合做猫狗宠物类的发信息发布. 当然其他信息发布也是可以的. 刚刚开发出炉的!亲测可用 源码下载地址https://www.skpan.cn ...

  4. JAVA毕业设计流浪狗领养系统计算机源码+lw文档+系统+调试部署+数据库

    JAVA毕业设计流浪狗领养系统计算机源码+lw文档+系统+调试部署+数据库 JAVA毕业设计流浪狗领养系统计算机源码+lw文档+系统+调试部署+数据库 本源码技术栈: 项目架构:B/S架构 开发语言: ...

  5. yt88加密狗不识别_YT88 是天域一个很不错的加密狗工具,可以源码 ,还 外壳 ,带DLK开发包。 Windows Develop 256万源代码下载- www.pudn.com...

    文件名称: YT88下载  收藏√  [ 5  4  3  2  1 ] 开发工具: Windows_Unix 文件大小: 12909 KB 上传时间: 2016-05-01 下载次数: 0 提 供 ...

  6. 详解linux下auto工具制作Makefile源码包(制作篇)

    2019独角兽企业重金招聘Python工程师标准>>> 详解linux下auto工具制作Makefile源码包(制作篇) 水木杨 一.     概述 为了更好的制作configure ...

  7. (转)Linux设备驱动之HID驱动 源码分析

    //Linux设备驱动之HID驱动 源码分析 http://blog.chinaunix.net/uid-20543183-id-1930836.html HID是Human Interface De ...

  8. linux epoll 开发指南-【ffrpc源码解析】

    linux epoll 开发指南-[ffrpc源码解析] 摘要 关于epoll的问题很早就像写文章讲讲自己的看法,但是由于ffrpc一直没有完工,所以也就拖下来了.Epoll主要在服务器编程中使用,本 ...

  9. linux下 如何调试php,linux下使用gdb对php源码调试

    title: linux下使用gdb对php源码调试 date: 2018-02-11 17:59:08 tags: --- linux下使用gdb进行php调试 调试了一些php的漏洞,记录一下大概 ...

  10. Linux内存管理 brk(),mmap()系统调用源码分析2:brk()的内存释放流程

    Linux brk(),mmap()系统调用源码分析 brk()的内存释放流程 荣涛 2021年4月30日 内核版本:linux-5.10.13 注释版代码:https://github.com/Rt ...

最新文章

  1. 启动R环境并执行R脚本
  2. 智能机器人服务广州春运
  3. Eclipse中新建SpringBoot项目并输出HelloWorld
  4. What is Proguard?
  5. 每个Java开发人员都应该阅读的10本书
  6. 前端学习(2044)vue之电商管理系统电商系统之优化configwebpack和chainwebpack
  7. 读取模式错误,计算引擎操作复杂……面对Hadoop这些问题该如何应对?
  8. Android之使用Intent跳转到一个网页
  9. 深入分析Kubelet Bootstrap Checkpoint
  10. PHP九宫格翻牌抽奖,PHP 九宫格抽奖代码
  11. Atitit.javascript 实现类的方式原理大总结
  12. 怎样给家庭组计算机授权,steam如何设置家庭共享?steam设置家庭共享方法
  13. 折腾小米盒子1s记录
  14. IAR 8.50.9破解后,遇到IarIdePm Encoutered an improper argument错误记录
  15. python中utf-8和gbk编码格式_python中unicode、utf8、gbk等编码问题
  16. Git bash和 Git GUI设置中文
  17. 《FMEA潜在失效模式及效应分析实务》课程大纲--台湾李文棕老师
  18. react 中 ref 管理列表
  19. opencv图像处理学习(六十八)——肤色检测
  20. BIM、GIS、CIM等技术共同助力数字孪生城市的建设

热门文章

  1. 3G爱立信告警信息提取
  2. 状态栏RAT信号图标显示
  3. Android 腾讯 云通信 用户头像更新
  4. 教你如何用Three.js创造一个三维太阳系
  5. 灵活有效的激励手段-鲶鱼效应
  6. Mac无法连接wifi和手机热点 解决方法
  7. 使用Java编写一个简单的Web的监控系统cpu利用率,cpu温度,总内存大小
  8. 宁盾堡垒机双因素认证方案
  9. 【错误记录】Google Play 上架报错 ( 此版本不符合 Google Play 关于提供 64 位版本应用的要求。| 如果提供 x86 架构动态库则必须提供 x86_64 架构的动态库 )
  10. 一键设置 DeviceAdmin/ProfileOwner/DeviceOwner 应用