Watchdog timer

Discussion to talk about software related topics only.
Post Reply
BillC
Posts: 72
Joined: Tue Oct 13, 2009 6:22 am
Location: Buckinghamshire, UK

Watchdog timer

Post 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
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: Watchdog timer

Post 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).
BillC
Posts: 72
Joined: Tue Oct 13, 2009 6:22 am
Location: Buckinghamshire, UK

Re: Watchdog timer

Post by BillC »

Fantastic lgitlitz, thats exactly what I needed and very well explained.

Thanks, Bill
vsabino
Posts: 32
Joined: Wed May 14, 2008 8:45 am

Re: Watchdog timer

Post 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
roland.ames

Re: Watchdog timer

Post 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
vsabino
Posts: 32
Joined: Wed May 14, 2008 8:45 am

Re: Watchdog timer

Post 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
roland.ames

Re: Watchdog timer

Post 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
Post Reply