WDT and FC

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

WDT and FC

Post 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 3043 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 3043 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 3043 times
Thanks for the help and pointers it is appreciated.
:D

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WDT and FC

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

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: WDT and FC

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WDT and FC

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

Post Reply