Page 1 of 1

Watchdog timer

Posted: Mon Feb 01, 2010 9:54 am
by BillC
Hi, could somene please tell me the timer value in secs/mins used by the watchdog timer and do I need to set anything to start using it.

I tried to look in the support section but the http://support.netburner.com/ link wasnt working.

Thanks in advance, Bill

Re: Watchdog timer

Posted: Tue Feb 02, 2010 12:47 pm
by lgitlitz
The watchdog peripheral is enabled by default at reset on the
MCF5270/34/82 processors. There is an option in the boot monitor
settings to enable/disable the watchdog. The factory preset is to have
the watchdog disabled. The control register (wcr) is write-once so when
it is disabled by the boot monitor it can never be re-enabled in your
application.

If you wish to use the watchdog you need to enable the watchdog monitor
setting. You can access this setting by typing 'A' at boot, then type
'setup' to see the boot settings and then type 'W' for the watchdog
setting. You can also access these settings from your application by
writing to the configuration record. This is a good option if you have a large
production so you dont manually have to change our factory settings:

ConfigRecord new_rec;
memcpy( &new_rec, &gConfigRec, sizeof( new_rec ) );
if (new_rec.m_Flags == 0) // if watchdog disabled
{
new_rec.m_Flags = 1; // WD enable
UpdateConfigRecord( &new_rec );
ForceReboot();
}

When you set this option to be enabled, the boot monitor will not write
to the wcr register during boot. You can then write to the WCR register
once in your application and this setting will be locked in until reset. You
should write to this register once so that the watchdog can not be disabled
by stray code.

I suggest looking at the following example in the NNDK:
C:\Nburn\examples\AutoUpdateFeatures
This example shows a very basic watchdog service routine. It also shows
how to point the on-board flash writing function to use your watchdog
service routine. This will allow you to write flash, such as
auto-updates, without danger of the watchdog resetting the processor.

The amount of time until a watchdog overflow depends on the value written
to the WMR register. By default this register holds 0xFFFF which is the largest
overflow value. You can only write to this register once. The system clock is
divided by 4096 prescaler before decrementing count. For the 150MHz
processors you will get about 55uS per count or a max of about 3.6 seconds(default).

Re: Watchdog timer

Posted: Wed Feb 03, 2010 7:21 am
by BillC
Fantastic lgitlitz, thats exactly what I needed and very well explained.

Thanks, Bill

Re: Watchdog timer

Posted: Thu Mar 22, 2012 1:43 pm
by vsabino
Larry,

I think I'm mising something. If I do 4096/150MHz, I don't get 55uS.
To get 55us, I do 8192/150MHz, which is double the value you said.

Thanks,
Victor

Re: Watchdog timer

Posted: Thu Mar 22, 2012 7:48 pm
by roland.ames
for 5270 & 5234, the bus clock is half the system clock, it is the bus clock that is used by the watchdog module
system clock = 147456000Hz, 4096 / ( 147456000 / 2 ) = 56us

For 5282, the watchdog divides the system clock by 8192 instead of 4096,
syatem clock = 66355200Hz, 8192 / 66355200 = 123us

Re: Watchdog timer

Posted: Fri Mar 23, 2012 11:37 am
by vsabino
Thanks, Roland.

That means the resolution for the 5282 is 123uS; and the possible timeouts range from 123uS to 8.09Sec, correct?

Victor

Re: Watchdog timer

Posted: Sun Mar 25, 2012 8:11 pm
by roland.ames
Yes, that is correct, the 5282 has a 16bit counter

0xFFFF * ( 8192 / 66355200 ) = 8.09

BTW, all the information about how the watchdog works is in the 5282 processor user manual
The information about the clock used on various netburner modules can be found in the netburner data sheets, or search for the term "CPU_CLOCK" in the source files provided with the netburner.
for the 5282, it is in C:\nburn\MOD5282\system\bsp.c

the value in the system file is usually given to more precision.

eg for 5282 the data sheet says the clock is 66MHz, while the information in bsp.c gives the figure of 66355200Hz