watchdog的理解在lh7a404

我的cpu是lh7a404

watchdog主要有两个寄存器

Control register(CTL) 和 Reset register (RST)

 

如果重新上电, CTL initial value is 0. If we write data 0x01, 0x91, what will happen??

It will reboot at once. Because its counter is 0, when counter is 0, watchdog reboot.

如果为了避免重启,首先设置TOC, the maximum value is 1111, such as 0xf(0-f), its bit is from (4-7).

Then set RST register, 使得TOC时间不要太短, RST的唯一功能就是更新TOC

接着,使能 CTL第0位,

 

physAddr_write(WDT_BASE + WDT_CTL, 4, 0xf0) //设置最长的timeout

physAddr_write(WDT_BASE + WDT_RST, 4, WDT_RST_CONST); //reset counter

physAddr_write(WDT_BASE + WDT_CTL, 4, WDT_CTL_EN);  // enable watchdog, it start work.

 

如果这样做了,重新上电启动,没有问题,

 

在串口输入:reboot, 按Ctrl+C进入bootloader模式,过了一会儿,板子重启了。

为什么?

reboot, 没有断电,watchdog is still work, so when counter result is get 0. so it will reboot.

重启时,watchdog不再工作了,所以再按Ctrl+C,它也不会重启了。

所以需要更新bootloader的代码消除这个现象。我就不做了。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值