Page 1 of 1

Auto clear watchdog problem

Posted: Tue Feb 09, 2010 9:45 pm
by Brian Walsh
My next evaluation project with FC4 is interrupt on change to portb. This is used with an encoder on bits 4 & 5.

There is a brief preamble followed by the main loop which outputs an integer value representing the encoder position via RS232.

When a change in the relevant bits of portb occurs, the interrupt handler modifies the position integer value and returns control to the main loop.

While watching program performance, I noticed that, after a couple of minutes, the position variable zeroed itself.

The auto clear watchdog check box in project options is ticked but changing the watchdog postscaler value changes the time out period so I'm pretty sure this is the culprit.

Adding the line 'asm clrwdt' to the main loop solves the problem - so something's not right.

Brian Walsh.

Re: Auto clear watchdog problem

Posted: Wed Feb 10, 2010 8:12 am
by Steve
Thanks for the note - I'll get someone here to investigate.

Re: Auto clear watchdog problem

Posted: Wed Feb 10, 2010 9:28 am
by Steve
We know why you are having this issue. The "auto-clear watchdog timer" actually only affects the delay icon in Flowcode. If you are not using it, then you will need to issue occasional C-icon "clrwdt();" commands.

Also note that relatively large delays in the code for Flowcode components include clrwdt statements.

Re: Auto clear watchdog problem

Posted: Fri Feb 12, 2010 5:02 pm
by medelec35
steve wrote:you will need to issue occasional C-icon "clrwdt();" commands.
Or clear_wdt();
since with 16F737 clrwdt(); does not complie due to error.
steve wrote: The "auto-clear watchdog timer" actually only affects the delay icon in Flowcode .
Thought it also affects the delays within component macros?

Re: Auto clear watchdog problem

Posted: Mon Feb 15, 2010 2:03 pm
by Benj
Hello Medelec

Ok this is a problem that I think I should be able to resolve in the next release.

If anyone is using a device from the 16F737 product family and want to use the watchdog delays then they will need to make the following modification to their internals.h file found in the FCD directory.

#define MX_CLEAR_WATCHDOG CLRWDT()

becomes

#define MX_CLEAR_WATCHDOG clear_wdt()

You can comment out the first line and that way it is easy to change back if you are using a different device.

Re: Auto clear watchdog problem

Posted: Fri Feb 19, 2010 9:46 am
by Benj
Hello

Sorry I think I may have made a mistake here. Please ignore my last posting.

There are two defines inside the internals file.

This is the BoostC clear watchdog command.

#define MX_CLEAR_WATCHDOG clear_wdt()

and here is the HITECH clear watchdog command.

#define MX_CLEAR_WATCHDOG CLRWDT()

The file should be ok as is and does not require editing.

To use extra watchdog clear commands in your program choose the appriopriate statement for your compiler.

BoostC - clear_wdt();
HITECH - CLRWDT();

Re: Auto clear watchdog problem

Posted: Fri Feb 19, 2010 10:16 am
by Steve
Or just use the following, which should be compiler-independent:

Code: Select all

MX_CLEAR_WATCHDOG;

Re: Auto clear watchdog problem

Posted: Tue Jul 06, 2010 4:20 pm
by medelec35
There is an issue with 16F883 and auto clear watchdog. When auto clear watchdog is selected, even if watchdog timer config. is set to off. the duty of both PWM channels are lower than normal and are no longer adjustable. If auto clear watchdog is un-ticked then PWM Duty increases to normal, and regain variable control again.
Is there a known issue/fix with Auto clear watchdog, or would you like me to send software in question for testing?
Thanks.

Re: Auto clear watchdog problem

Posted: Wed Jul 07, 2010 6:51 am
by Steve
I've not heard of this issue. Please create a simple program and post on this forum so we can investigate. Thanks.

Re: Auto clear watchdog problem

Posted: Wed Jul 07, 2010 1:44 pm
by Benj
Hello Medelec,

Right as far as I can see there is a bit of a problem as both PWM timer1 and Watchdog timer use the same input prescaler peripheral.

If you are leaving the watchdog configuration setting disabled then the watchdog itself will be disabled.

Enabling the autoclear watchdog simply uses the BoostC or HiTech C clear watchdog commands so it seems that this command is automatically switching the prescaler from the timer1 peripheral to the watchdog timer.

Therefore if you are using PWM then you will have to either not use the watchdog at all or you may be able to clear the watchdog timer using direct register access rather then using the clear function. There may also be a way to switch the prescaler back to the control of the timer 1 but im not sure about this.

Anyway have a bit of a play and let me know who you get on.

Re: Auto clear watchdog problem

Posted: Wed Jul 07, 2010 3:44 pm
by medelec35
Thank you for that valuable information, I appreciate it. There is however one thing I have noticed, when I did a cut down version to post online, with Auto watchdog clear enabled, the PWM was working 100% OK. One difference was I deleted a 2 second delay, so I wonder if working for short time delay periods, but not longer delays? Unfortunately I cannot test that with 16F883, as they keep failing to program via ICSP. (well some can program up to about 5 times, others would not program at all. Un like 16F737 which would program 100%)
When I can I will try that theory.
Thanks once again.

Re: Auto clear watchdog problem

Posted: Wed Jul 07, 2010 9:39 pm
by medelec35
Hmm I am a bit confused. I thought timer1 prescaler used T1CON.

WDT shares prescaler with Timer0 which is OPTION_REG which has nothing to do with PWM, as you said, PWM uses timer1
Unless I have got something wrong?

Which Registor are you referring to that gets changed please?

Re: Auto clear watchdog problem

Posted: Tue Jul 13, 2010 7:28 am
by medelec35
Benj wrote: Anyway have a bit of a play and let me know who you get on.
I have got round the auto clear watchdog issue by using delays like the one below:
Thanks again.
Auto Clear Watchdog Issue.JPG
Auto Clear Watchdog Issue.JPG (11.78 KiB) Viewed 12053 times
Two second delay

Re: Auto clear watchdog problem

Posted: Tue Jul 13, 2010 10:02 am
by Benj
Hi Medelec,

Your right the watchdog shares the prescaler resource with timer 0 and not timer 1. The powerup timer uses timer 1 but this should not be active during operation.

Im a bit stumped by this. Thanks for posting up the workaround.

If I get some time I would like to have a look at the assembler code to see exactly what is going wrong with this.