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?

PeterJ
17.3k37 gold badges58 silver badges91 bronze badges
asked Feb 27, 2013 at 8:04
\$\endgroup\$
12
  • \$\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\$ Commented Feb 27, 2013 at 8:06
  • \$\begingroup\$ Do you really need the system reset or could you just re-start the program from the top? \$\endgroup\$ Commented Feb 27, 2013 at 9:06
  • \$\begingroup\$ For timers - here is a good tutorial: avrfreaks.net/… \$\endgroup\$ Commented Feb 27, 2013 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\$ Commented Feb 27, 2013 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\$ Commented Feb 28, 2013 at 9:11

2 Answers 2

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!

answered Mar 1, 2013 at 6:16
\$\endgroup\$
1
  • 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\$ Commented Mar 5, 2013 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.

Voltage Spike
93.1k53 gold badges93 silver badges243 bronze badges
answered Jul 29, 2017 at 13:21
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.