Watchdog question

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi!

Im using the ATTiny861 and I would like to use the watchdogtimer.
Its the first time I use it but I've checked it up and I know how to enable:
wdt_enable(WDTO_8S);
and reset:
wdt_reset();

Now to the problem. 8s is max but I want to be able to set it to 10, 15 or 20s.
I was thinking of using ISR() and a globel uint8_t to keep track of how many times the watchdog had reached 5s.
And when the settings (10s, 15s, 20s) have been reached then I want to reboot my system. Any suggestion on how I could do this. Or if you have a better solution pls post a code and some text to explaine. Would really like to learn. :)

Best regards
BBB

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You don't necessarily need a timer to have a long period to be able to do something every 10/15/20s. Say you just run a "normal" timer 0/1/2 so it has an overflow interrupt every 25ms. Then to have something occur every 15 seconds you just have the interrupt increment a counter until it reaches 40 * 15 = 600, then do (or at least trigger) the 15 second work and reset the counter. (40 = 1/0.025)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wanted to use the watchdog because after the XXseconds the µController should reset. This because I want the varibles to be rebooted and I've made a "sleep state" which the µController starts in. The sleep state is waiting for an approach-signal and after that the µController starts it's main purpose.
So by the using the watchdog and reseting the sowftware will work lika setting the µController back in stand-by mode when nothing have happend.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there any function like reset() or reboot() that one could call upon to reset the µController?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Is there any function like reset() or reboot() that one could call upon to reset the µController?

Well that's where the watchdog DOES come in useful - just enable it with the shortest possible timeout then tight loop. The other way is to drive the _RESET pin by another PORT pin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Quote:

Is there any function like reset() or reboot() that one could call upon to reset the µController?

Well that's where the watchdog DOES come in useful - just enable it with the shortest possible timeout then tight loop. The other way is to drive the _RESET pin by another PORT pin.

Hehe, I have already solved the problem like that.
Thanks any way for at quick and good answer.