Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Watchdog Timer

Status
Not open for further replies.

rabhishek91

New Member
Hi everyone.:)
Today i learnt about watchdog timer in my college and thought of trying it using ATmega32.

My objective is to set watchdog timer condition at 20 seconds (approx.) and light the LED.
Is it possible ? According to the datasheet(attached below) in the Watchdog Timer Prescaler select maximum time-out is 2.2 seconds.
Is it possible to generate timeout at 20 seconds ?

Can i make use some variable to keep track of its time out and then decide ?
Ex- If the variable equal to 10 (i.e 10 time outs ) then light an LED.

Also WDT oscillation cycles are nothing but WDT operating frequency right ?

I am sorry to post lot of questions.Please help. :confused:
Thanks in advance.:)
 

Attachments

  • Watchdog Timer.jpg
    Watchdog Timer.jpg
    95.8 KB · Views: 417
Most people would not use a watch dog timer to time your led. There are other timers.

The watchdog timer resets the processor. In doing so the program starts from the very beginning and all initialized variables will be reinitialized.
 
Most people would not use a watch dog timer to time your led. There are other timers.

The watchdog timer resets the processor. In doing so the program starts from the very beginning and all initialized variables will be reinitialized.

Thanks for your reply sir.
I didn't knew that Watchdog timer resets processor.

So is it impossible to serve my objective using Watchdog timers ?
 
Thanks for your reply sir.
I didn't knew that Watchdog timer resets processor.

So is it impossible to serve my objective using Watchdog timers ?

Not impossible but you have to play some games.
Method 1
You could slow the processor to 1/10 the speed and the 2 seconds become 20. Then you could turn the LED on at the start of the program, then off, then wait for the WDT to expire.

Method 2
Use a counter variable but do not initialize it in the normal way.
If the counter is not between 0 and 10 you set it to 0.
If it is < 10 you add 1 to it.
if it is equal to 10 you blink the led and set it to 0.
Note that this could be off by a count or two but you can figure that out easy enough.
 
Not impossible but you have to play some games.
Method 1
You could slow the processor to 1/10 the speed and the 2 seconds become 20. Then you could turn the LED on at the start of the program, then off, then wait for the WDT to expire.

Method 2
Use a counter variable but do not initialize it in the normal way.
If the counter is not between 0 and 10 you set it to 0.
If it is < 10 you add 1 to it.
if it is equal to 10 you blink the led and set it to 0.
Note that this could be off by a count or two but you can figure that out easy enough.

Sir how would one slow down the processor speed by 1/10th?
ATmega32 has inbuilt 1MHz watchdog timer . Is it dependent on CPU clock ?
 
Just don't use the watchdog timer to blink a LED.. It is not meant to do that. There are many better ways to do it. Like delay functions.. and "ordinary" timers.

Of course if you just want to learn how to use the WDT, then go for it and experiment. Nothing wrong with that.

Sir how would one slow down the processor speed by 1/10th?
ATmega32 has inbuilt 1MHz watchdog timer . Is it dependent on CPU clock ?

No, you can't slow down the watchdog oscillator. You can use the WDT interrupt to count the events when the WDT expires.

Here is a nice tutorial. It is for Atmega328, but most of the stuff is valid for ATmega32 too.
http://www.embedds.com/using-watchdog-timer-in-your-projects/
 
Last edited:
Sir how would one slow down the processor speed by 1/10th?
ATmega32 has inbuilt 1MHz watchdog timer . Is it dependent on CPU clock ?
As I have said and misterT has said using the WDT is not a good way to do this.

My assumption is that the WDT is derived from the processor clock. CHeck the datasheet to verify.
 
My assumption is that the WDT is derived from the processor clock. CHeck the datasheet to verify.

It has a separate, dedicated, 1Mhz oscillator. The frequency of it can't be changed.
 
As I have said and misterT has said using the WDT is not a good way to do this.

My assumption is that the WDT is derived from the processor clock. CHeck the datasheet to verify.

Yes sir. Your right i'll not use Watchdog timer.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top