Hi,
The watchdog interrupt causes a reset. It's normally used to catch program
crashes.
Regards
Ian Dobson
Home of the Atmel based UDP mobile web cam http://www.planet-ian.com
All mails scanned with av-filter.pl (F-Prot / perl)
----- Original Message -----
From: Fanie Terblanche
To: Bascom
Sent: Thursday, May 18, 2006 5:22 PM
Subject: [bascom] ATMega8 Watchdog Question
Hi All,
I have a question about the WDT. If the program wakes up from the WDT it
restarts the program, and i just want to reset the WDT and go back to sleep
if it was not INT0 that woke me up.
Thanks in advance
Fanie.
This is the output i get
-------------------------------------
START
Before Sleep
WDT
START
Before Sleep
WDT
START
This is the test program used.
--------------------------------------
$regfile = "m8def.dat"
$crystal = 8000000
$baud = 9600
Config Int0 = Falling
On Int0 Measurepulse
Config Watchdog = 2048
'reset after 2048 mSec
Start Watchdog
'start the watchdog timer
Reset Watchdog
Enable Interrupts
Enable Int0
Print "START"
Do
Gosub Shutdownpower
' The following code will only be executed if INT0 woke me up
Reset Watchdog
Print "INT 0 woke me up !!!!"
Loop
Shutdownpower:
Print "Before Sleep"
__wdtr:
Print "Reset WDT"
Reset Watchdog
cbi MCUCSR,WDRF
'Clear the MCUCSR Flags
cbi MCUCSR,BORF
'Clear the MCUCSR Flags
cbi MCUCSR,EXTRF
'Clear the MCUCSR Flags
cbi MCUCSR,PORF
'Clear the MCUCSR Flags
Powerdown
'Goto Sleep
sbic MCUCSR,WDRF
'Check if the WDT woke us up
jmp __wdtr
Print "NOT WDT"
'NOT the WDT
cbi MCUCSR,WDRF
cbi MCUCSR,BORF
cbi MCUCSR,EXTRF
cbi MCUCSR,PORF
Print "After Sleep"
Return
Measurepulse:
Print "INT 0"
Reset Watchdog
Reti
START
Before Sleep
WDT
START
Before Sleep
WDT
START