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
disable watchdog in 18F452
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: disable watchdog in 18F452
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 you use a box with
Then it is compiler independent so if you will be using Flowcode V4 then 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
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
Code: Select all
MX_CLEAR_WATCHDOG;
Code: Select all
MX_CLEAR_WATCHDOG;
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: disable watchdog in 18F452
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:
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: within a Ccode box
Or clearing a bit of a register E.g bit7 you can use:
Or setting a bit you can use:
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
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 in V4 can be found within 'View'/'project options'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.
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;
Or clearing a bit of a register E.g bit7 you can use:
Code: Select all
clear_bit(option_reg , 7);
Code: Select all
set_bit(option_reg,7);
Hope this helps
Martin
Martin