Page 1 of 1

WDT and FC

Posted: Wed Jan 17, 2018 6:02 am
by QMESAR
Hi Team.
Please help me understand how the watchdog is handled in FC.
If I select the auto clear in the build properties where does FC clear the WDT ? at the end pf the main loop or somewhere else?
123.jpg
123.jpg (45.67 KiB) Viewed 3125 times
I suppose I need to configure the WDT Timeout by setting the WDTCON register is this done by a normal C call ?

125.jpg
125.jpg (147.97 KiB) Viewed 3125 times
I only need to enable the WDT in Config and then it will run to what ever I set in the WDTCON as time , I am confused as to where FC clear the watchdog and how to you manually clear the WDT in FC
124.jpg
124.jpg (73.32 KiB) Viewed 3125 times
Thanks for the help and pointers it is appreciated.
:D

Re: WDT and FC

Posted: Wed Jan 17, 2018 12:59 pm
by Benj
Hi Peter,

The Auto Clear Watchdog Timer checkbox automatically clears the watchdog timer whenever a component macro is called and also when a millisecond or second delay is called.

If you want to clear the watchdog timer yourself then you can do so using this line of C code.

Code: Select all

MX_CLEAR_WATCHDOG;
To write to the Watchdog timeout register you would simply do this.

Code: Select all

WDTCONbits.WDTPS = 0b01011;
Hope this helps.

Re: WDT and FC

Posted: Wed Jan 17, 2018 1:52 pm
by QMESAR
Hi Ben.

Thank a million,it is clear now ,I also suppose when not activating the auto clear and setting the WDT too ON, I can clear it in the FC where I need it :D

Re: WDT and FC

Posted: Thu Jan 18, 2018 6:52 pm
by Benj
Thank a million,it is clear now ,I also suppose when not activating the auto clear and setting the WDT too ON, I can clear it in the FC where I need it :D
Yep it's best to control it yourself if you can.

The main reason for having the auto clear watchdog is if you have delays in your program which are larger than the watchdog timeout period. In this case we break up the delay into manageable sections with clear commands in between however in practise this can extend the overall length of the delay.