搜索
bottom↓
回复: 4

请教bascom中的看门狗问题。

[复制链接]

出0入0汤圆

发表于 2005-6-27 16:25:43 | 显示全部楼层 |阅读模式
看门狗对于保持AVR的稳定有重要的作用。



最近,我在使用bascom制作一个小程序,需要用到看门狗。

可是我那本书里没有讲这个问题,而且bascom-avr的帮助文件里也没有。



在汇编里,好像是用 “wdr”实现的,,,



我想问一下,在bascom里,是用什么语句实现看门狗功能的。

包括使能和复位。



可否给一个简短的示例程序。



谢谢大家。

阿莫论坛20周年了!感谢大家的支持与爱护!!

一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。

出0入0汤圆

 楼主| 发表于 2005-6-28 10:41:02 | 显示全部楼层
没有人理,四处的翻了翻,结果找到了一个帮助文件,和前人的一个例子,我修改了一下,放在了下面。



呵呵。



已经明白了~!!



我猜看门狗 赋值的时候,范围只能16~2048,且为2的n次方。





The Watchdog Timer



The Watchdog Timer is clocked from a separate on-chip oscillator which runs at 1MHz. This is the typical value at VCC = 5V.



By controlling the Watchdog Timer pre-scaler, the Watchdog reset interval can be adjusted from 16K to 2,048K cycles (nominally 16 - 2048 ms). The RESET WATCHDOG  - instruction resets the Watchdog Timer.

Eight different clock cycle periods can be selected to determine the reset period.

If the reset period expires without another Watchdog reset, the AT90Sxxxx resets and executes from the reset vector.

==================================

$regfile = "8515def.dat"

$crystal = 8000000

Config Watchdog = 2048



Dim N1 As Long

Stop Watchdog



N1 = 0



Start Watchdog



Do

N1 = N1 + 1



Print N1

Waitms 2



Loop

Stop Watchdog

End

出0入0汤圆

 楼主| 发表于 2005-6-28 10:43:32 | 显示全部楼层
我试验了一下,只记到106 就溢出了,,,这样算来,最大才200多ms。

出0入0汤圆

 楼主| 发表于 2005-6-28 11:21:49 | 显示全部楼层
CONFIG WATCHDOG



Action

Configures the watchdog timer.





Syntax

CONFIG WATCHDOG  = time





Remarks



Time        The interval constant in mS the watchdog timer will count to before it will reset your program.



Possible settings :

16 , 32, 64 , 128 , 256 , 512 , 1024 and 2048.

When the WD is started, a reset will occur after the specified number of mS.

With 2048, a reset will occur after 2 seconds, so you need to reset the WD in your programs periodically with the RESET WATCHDOG statement.





See also

START WATCHDOG , STOP WATCHDOG , RESET WATCHDOG





Example

'-----------------------------------------------------

'                (c) 1999 MCS Electronics

' WATCHD.BAS demonstrates the watchdog timer

'-----------------------------------------------------

Config Watchdog = 2048                                        'reset after 2048 mSec

Start Watchdog                                                'start the watchdog timer

Dim I As Word

For I = 1 To 1000



  Print I                               'print value

  'Reset Watchdog

  'you will notice that the for next doesnt finish because of the reset

  'when you unmark the RESET WATCHDOG statement it will finish because the

  'wd-timer is reset before it reaches 2048 msec

Next

End

出0入0汤圆

发表于 2005-6-29 12:55:06 | 显示全部楼层
你选择了最好的方式:应该先看BASCOM-AVR的再线帮助。它的帮助已经非常好了,还有许多简单例程参考。
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-18 11:51

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表