Jump to content
gbgb

Watchdog And Configuration Questions 18F6527

Recommended Posts

I am using the 18F6527 (18F8722 family)

I want to implement a watchdog timer

This seems simple enough:

enable the WDT either by enabling WDTEN in CONFIG2H, or keep WDTEN disabled and do it in code by manipulating SWDTEN in WDTCON.

However some things are not clear to me:

1. How do I reset the watchdog? is it simply an asm CLRWDT within the c code?

2. It says in the maual that reseting the watchdog also clears the prescaler. Does this mean that after each clear I have to reload the prescaler?

3. Which brings me to - can the configuration registers be manipulated at run time via c code? I think that for the 18 family it is possible but am not sure. If so - is it simply writing to them like any other SFR or is there a special procedure? And if not - how do you reload the prescaler if it is cleared at runtime (or prevent form clearing)?

Share this post


Link to post
Share on other sites

Use the function "clear_wdt()" as on page 76 of the manual.

 

The prescaler will retain its value after resetting the watchdog. The counter may get reset.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Thanks,

 

 

Although I am using SourceBoost C I am trying to keep my code as clean as possible from "vendor specific" libraries in case a switch to a different compiler will be required.

So the question still remains - is it simply and inline asm CLRWDT?

 

I will try, but your statement about the prescaler is opposed to what is written in the device datasheet.

Share this post


Link to post
Share on other sites

The manual says you can do it these ways:

clear_wdt();
006C  0064   CLRWDT

asm CLRWDT
006D  0064   CLRWDT

asm
{
 CLRWDT
}
006E  0064   CLRWDT

 

All product the same machine code instruction.

 

The prescaler value is set in the config 2H byte and therefore fixed.

The watchdog counter increments until it meets the prescaler value then resets the chip.

It is the counter that is reset on watchdog clear and sleep not the prescaler.

The prescaler is a multiplexor which taps off the counter outputs.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...