1
\$\begingroup\$

I am working with an ATmega128 and need to reset the microcontroller after some 10 seconds has passed and the user has not interacted with microcontroller. As an example when the user has not pressed any key from a keypad for 10 seconds the controller should get reset.

A watchdog timer is available in the ATmega128 but I am able to get a maximum of 2 seconds delay before it resets. But I require 10 seconds.

Maybe I can do it using timers but I don't know how to proceed?

\$\endgroup\$
  • \$\begingroup\$ Even I tried with the Header file #include<avr/wdt.h> and used like: wdt_enable(WDTO_8S); wdt_reset(); But not got any response by these functions. I am working in Linux AVR-GCC. \$\endgroup\$ – Sanju Feb 27 '13 at 8:06
  • \$\begingroup\$ Do you really need the system reset or could you just re-start the program from the top? \$\endgroup\$ – John U Feb 27 '13 at 9:06
  • \$\begingroup\$ For timers - here is a good tutorial: avrfreaks.net/… \$\endgroup\$ – Christoph Feb 27 '13 at 9:12
  • \$\begingroup\$ @JohnU: Thanks for your reply and Actually in my project I am asking user for password, if he enters wrong password it will be in that loop only until he gives right password. So what i need is if user not gave any input to the controller it should start from at top of the program. \$\endgroup\$ – Sanju Feb 27 '13 at 11:37
  • 2
    \$\begingroup\$ Another idea: Start a timer before accepting inputs from User, Reset that timer everytime user enters something... If user is inactive for given time, Timer will overflow... Set flag in timer and if that flag is set, break out from your "Accept Input" Loop! \$\endgroup\$ – Swanand Feb 28 '13 at 9:11
2
\$\begingroup\$

Instead of using Watchdog timer for this purpose,

Start a timer before accepting inputs from User, Reset that timer everytime user enters something... If user is inactive for given time, Timer will overflow... Set flag in timer and if that flag is set, break out from your "Accept Input" Loop!

\$\endgroup\$
  • 1
    \$\begingroup\$ Also note that ten seconds is a long time, and it may not be possible to stretch the hardware timer peripheral that far, of if you can could lock up a valuable timer and not allow it to be used for anything else. Having the timer interrupt perodically, say 1 seconds or less, and decrementing some sort of countdown may be a more optimum way to go. \$\endgroup\$ – Chintalagiri Shashank Mar 5 '13 at 18:53
0
\$\begingroup\$

It is possible to achieve the same. Use the watchdog (i.e. internal or external). If its external you have to check its datasheet and response according to it. The internal watchdog must be set for 2 seconds then reset it in loop for more than 1 sec. it is favorable to use a timer for the same purpose. Just rest the watchdog after every second and reset the watchdog counter after 5 times.

\$\endgroup\$

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.