1
\$\begingroup\$

I want to add a piece of code for watchdog timer within my source code so that the board resets automatically when programs hangs. I am using Mediatek Linkit One board.

\$\endgroup\$
0
\$\begingroup\$

You can create a function that "Feeds the dog" in an appropriate place in your program. When the dog isn't fed, the watchdog timer will elapse and reset the program. Look at the microcontroller documentation to see how this is implemented. Generally the Watch Dog timer will need to be configured correctly (with appropriate pre-scaler values), enabled, and then cleared periodically before the timer expires. The API References from mediatek labs doesn't look like it gives you access to this lower level functionalitybut the SOC Processor technical brief for the ARMyEJ-S does include a Watchdog timer (p.8) which is the only mention. If you can't find an answer to this in the documentation then I would contact them and ask for it directly and put some pressure on their developers (as it has already been requested in their forum.)

\$\endgroup\$
  • \$\begingroup\$ Yes sir as you rightly said the API References from Mediatek labs doesn't give the access to this lower level functionality and there is no description in ARM7EJ-S technical brief of how to make use of the watchdog. This makes things difficult now if the board must be used in real time applications. Yes it would be great if you contact them and ask for it directly. Thank you. \$\endgroup\$ – Sai Gautham Feb 8 '16 at 13:55
2
\$\begingroup\$

I have no idea what a Mediatek Linkit One board is (and you didn't provide a link), but, in general, you can't. If your program hangs how will the watchdog code be executed?

Watchdogs usually have to be implemented in hardware - either internally by a section of the CPU that runs independently of the user program or, if that can't be done, an external watchdog is employed. Your program would reset the external watchdog periodically by sending a pulse. If the external watchdog doesn't see a transition within a certain time then a reset is generated.

\$\endgroup\$
  • 3
    \$\begingroup\$ If the hardware supports a timer interrupt (for supporting preemptive multitasking), an OS-level software watchdog time would be possible. (Since the OS can disable timer interrupts, such would not have quite as much coverage as a hardware watchdog.) It might be possible to have a user-level process that is guaranteed (according to the OS's scheduler implementation) to run with a minimum frequency and such could be used to provide watchdog functionality. The timeout in POSIX select() would provide a means for a user-level watchdog. \$\endgroup\$ – Paul A. Clayton Feb 6 '16 at 15:04

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.