View previous topic :: View next topic |
Author |
Message |
bibibo
Joined: 30 Nov 2009 Posts: 168

|
Posted: Sat Apr 26, 2014 1:24 pm Post subject: Watchdog ATmega128 |
|
|
Hello,
ATmega128 has maximum watchdog timer 2048. I would need at least twice more.
Could you help me or give me an idea how to ?
(BASCOM-AVR version : 2.0.7.7 ) |
|
Back to top |
|
 |
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany

|
Posted: Sat Apr 26, 2014 1:50 pm Post subject: |
|
|
The WD is reset once in a full cycle of the main routine. A well structured main routine runs fast and often. If your main routine takes more than 2048ms, than your prog is really big or you could try to avoid waiting and hesitating in the main loop!?
Find points that take long time and lets see how to change that.
Often seen: main roitine waits for uart-input.... |
|
Back to top |
|
 |
...mohammad
Joined: 04 May 2014 Posts: 17

|
Posted: Sat May 10, 2014 6:44 pm Post subject: Re: Watchdog ATmega128 |
|
|
bibibo wrote: | Hello,
ATmega128 has maximum watchdog timer 2048. I would need at least twice more.
Could you help me or give me an idea how to ?
(BASCOM-AVR version : 2.0.7.7 ) |
Hi
You may Interrupted More than 1500 ms are several Divide
That is, if you have interrupts
4 seconds so you can practice
reset watchdog
wait 1
reset watchdog
wait 1
reset watchdog
wait 1
reset watchdog
wait 1
I've been working with this method
And never had a problem
Good luck |
|
Back to top |
|
 |
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany

|
Posted: Sun May 11, 2014 9:18 am Post subject: |
|
|
mohammads suggestion is a good example of how NOT to do it.
He waits a lot in the main routine and resets the WD at every corner.
The idea of a WD is to check if the routine runs as it is supposed to. So if everthings runs ok, the watchDOG will never bite. That's why you will PROBABLY not face any problems, when the WD is reset several times in the prog.
I'll try to explain:
DIM n as byte
n = 0
do
reset watchdog
Print "step 1"
wait 1
label_one:
reset watchdog
Print "step 2"
wait 1
reset watchdog
Print "step 3"
if n <> 0 then goto label_one
wait 1
reset watchdog
Print "step 4"
wait 1
loop
As n is never set other than "0", there is no problem. But now a faulty condition occures: For any reason only Murphy knows, n is set to "87" out of a sudden! This coud be EMI, or an input sets n to 87 unexpectedly or whatever you might not expect.
What happens next? The IF.. line loops to label_one, "4" is never printed again, and the WD sleeps!
The more often you reset the WD, the more likely it is he can not do his work.
In mohammads example, it is easier to use "stop watchdog", it has the same effect. |
|
Back to top |
|
 |
|