disable watchdog in 18F452

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
elec
Posts: 6
Joined: Sat Jun 11, 2011 10:04 pm
Contact:

disable watchdog in 18F452

Post by elec »

hi;
i'm new beginner in programing 18F452 with FLOWCODE 3,i tried to disabbe WATCHDOG by adding C code (clear_wdt) ,but when i start compiling i have got this message RETURN CODE = 1 , then i discovered that the syntax is wrong ,so would you helpe me to solve the problem
thank you

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: disable watchdog in 18F452

Post by medelec35 »

I always use

Code: Select all

MX_CLEAR_WATCHDOG;
Within the cblock

Martin
Martin

elec
Posts: 6
Joined: Sat Jun 11, 2011 10:04 pm
Contact:

Re: disable watchdog in 18F452

Post by elec »

could you explain more please

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: disable watchdog in 18F452

Post by medelec35 »

I am assuming you would like to keep watchdog enabled, so chip resets if it gets corrupted or locked in a loop?
clear_wdt is the command used in assembly language to reset WDT so chip does not get reset.
If instead of

Code: Select all

clear_wdt
you use a box with

Code: Select all

MX_CLEAR_WATCHDOG;
Then it is compiler independent so if you will be using Flowcode V4 then

Code: Select all

MX_CLEAR_WATCHDOG;
within a Ccode Box can be used with Hitec or BoostC
See: http://www.matrixmultimedia.com/mmforum ... 232#p17232
But should work OK for Flowcode V3 also.
However If you are talking about totally disabling WDT you you don't need any commands to rest the timer within 18ms (or what ever time-out is configured for)
Then you will need to alter the chip configuration settings to disable watchdog.
Just go to 'Chip' menu then 'Configure.
If you are in the simple configuration, it's best to permanently change to advance configuration by clicking on 'Options', then un-tick 'Use simple Config screen'
Click OK for settings to apply.
Now go again to 'Chip' 'Configure. You will see the full configuration options for your target device.
There you can set correct settings e.g. Watchdog and Low voltage programming disabled etc.
See: http://www.matrixmultimedia.com/mmforum ... =26&t=6936

Hope this helps

Martin
Martin

elec
Posts: 6
Joined: Sat Jun 11, 2011 10:04 pm
Contact:

Re: disable watchdog in 18F452

Post by elec »

her's the file but ther's always a reset caused by watchdog
TEST.fcf
(4.5 KiB) Downloaded 460 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: disable watchdog in 18F452

Post by medelec35 »

Hi elec,
Yes I can see why you are experiencing watchdog time-out, and there is a workaround.
Assuming the standard WD time out is 18ms, you have got a 1 second delay.
So you WD time-out will occur during that 1 second delay.
The solution for Flowcode V3 is to create that 1 second delay using loops, with a clear watchdog and ms delay (e.g 5 or 10ms) embedded within the loop.
See: http://www.matrixmultimedia.com/mmforum ... 626#p19626
If you have Flowcode V4 then there is a new feature which allows you to select 'Auto Clear Watchdog'
This is what the help files say about it:
Auto Clear Watchdog
This is used to automatically clear the watchdog timer every time a component macro is called which will stop the target device from detecting a false stop condition and resetting.
Auto Clear Watchdog in V4 can be found within 'View'/'project options'

The other work around is use C Code to change the watchdog prescaller. For this you will need to look the device data sheet.
As a bit of help, Format to assign a register with a value:

Code: Select all

option_reg = 0XF; 
within a Ccode box
Or clearing a bit of a register E.g bit7 you can use:

Code: Select all

clear_bit(option_reg , 7);
Or setting a bit you can use:

Code: Select all

set_bit(option_reg,7);
The examples I have used are randomly chosen, so they won't necessary be the ones to use for extending WD Time-out period.

Hope this helps
Martin
Martin

elec
Posts: 6
Joined: Sat Jun 11, 2011 10:04 pm
Contact:

Re: disable watchdog in 18F452

Post by elec »

thank's a lot i'll work on ,

Post Reply