User Tools

Site Tools

한국어

moacon:wdton:index

wdtOn

void wdtOn(u8 timeout)

timeout : A number corresponding to a specified timeout (0 ~ 6)

Enables the watchdog timer with a specified timeout, timeout. The following table maps timeout to a corresponding time span.

timeout TIme Span
0 about 0.4 seconds
1 about 0.8 seconds
2 about 1.6 seconds
3 about 3.2 seconds
4 about 6.5 seconds
5 about 13 seconds
6 about 26 seconds

In the following program the watchdog timer is set to approximately 6.5 seconds. The first for-loop will be able to count to 10 because the watchdog timer is being cleared after each iteration. The second for-loop, however, will not be able to finish counting because the watchdog timer will reset the CPU after 6.5 seconds.

#include "moacon500.h"
void cmain(void)
{
 printf("Start Program\r\n");
 wdtOn(4);                        //Set watchdog timer to 6.5 seconds
 int i = 0;
 
 for(i=1; i<=10; i++)             //Count to 10
 {
   printf("%d\r\n", i);           //Print count to debug console
   delay(1000);                   //Wait for 1 second
   wdtClear();                    //Clear the watchdog timer
 }
 for(i=1; i<=10; i++)             //Try to Count to 10
 {
   printf("%d\r\n", i);           //Print count to debug console
   delay(1000); //Wait for 1 second
 }
}

go MOACON home

moacon/wdton/index.txt · Last modified: 2016/04/14 11:07 (external edit)