0

I have an ATTiny85 controlling the power to a number of devices. When I first power on it will power the devices via a mosfet. Take the readings it needs to and then puts itself to sleep for 15 minutes then wake up and repeat.

My question is, because I am using the Watchdog timer to put it to sleep, I can't use the reset functionality of the watchdog (ie wdt_Reset). So is there anyway to detect a lock or hang if the ATTiny85 never wakes up for some reason or would I need additional hardware to check for this. If so what kind of circuit would I need.

Thanks

  • 1
    Do you mean: The sleeping part works fine, but you want to detect some other sort of hang and also use the watchdog timer to recover from that? – Nick Gammon Sep 27 '17 at 21:18
  • Thank you for your comment. Ideally I want to be able to recover from a hang if the chip is sleeping and if it hangs when it is running. – SpeedOfSpin Sep 28 '17 at 8:27
  • I don't see how it can "hang" if it is already sleeping. You could reconfigure the watchdog timer to reset the chip if it hangs prior to the part of the code which puts it to sleep. – Nick Gammon Sep 28 '17 at 21:17
1

So is there anyway to detect a lock or hang if the ATTiny85 never wakes up for some reason or would I need additional hardware to check for this. If so what kind of circuit would I need.

The whole point of the watchdog timer is to wake (or reset) the chip after a certain (short) time. You don't really need a second watchdog timer to wake the processor if the first one fails.

I made a temperature and humidity sensor which is battery powered, and which uses the watchdog timer to wake it and take readings (which sounds like what you are doing). It has been running for a number of years now (over four) and it has never "hung".

2

Not sure what you mean by "using the watchdog to put it to sleep". You can sleep with or without the watchdog enabled, and you can even use the watchdog to both wake you with an interrupt and also reset in case of a lockup. Check out section 8.5.2 in the datasheet...

If WDE is set, WDIE is automatically cleared by hardware when a time-out occurs. This is useful for keeping the Watchdog Reset security while using the interrupt. After the WDIE bit is cleared, the next time-out will generate a reset. To avoid the Watchdog Reset, WDIE must be set after each interrupt.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.