Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Watchdog ATmega128

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
bibibo

Bascom Member



Joined: 30 Nov 2009
Posts: 168

slovakia.gif
PostPosted: Sat Apr 26, 2014 1:24 pm    Post subject: Watchdog ATmega128 Reply with quote

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
View user's profile
Arera

Bascom Member



Joined: 23 Sep 2007
Posts: 375
Location: Wuppertal, Germany

germany.gif
PostPosted: Sat Apr 26, 2014 1:50 pm    Post subject: Reply with quote

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
View user's profile
...mohammad

Bascom Member



Joined: 04 May 2014
Posts: 17

iran.gif
PostPosted: Sat May 10, 2014 6:44 pm    Post subject: Re: Watchdog ATmega128 Reply with quote

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
View user's profile
Arera

Bascom Member



Joined: 23 Sep 2007
Posts: 375
Location: Wuppertal, Germany

germany.gif
PostPosted: Sun May 11, 2014 9:18 am    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum