![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
carl
Joined: 06 Feb 2008 Posts: 240 Location: Chester
|
WDT |
Posted: Fri Jul 31, 2015 6:31 am |
|
|
Hi all,
Hope you can help. Some pre-requisites:
Compiler Version 4.141
Using 16f877
Using MPLAB (in release mode, WTD enabled in settings).
I have never used the WDT function ever - always tried to steer clear of it.
But I am going to need it for a particular project.
Basically I have started with a simple program below, but it doesn't work.
On initialisation the LED should flash for 2s, and then go into the while loop () and flash every 0.2s. It makes no difference if 'reset_wdt' line is there or not, so it must not be even starting/working.
The LED just keeps flashing at 0.2s intervals, whereas it should reset back to 2s when the reset_wdt line is commented out.
the code: Code: | #include "16f877.h"
#fuses XT, NOPROTECT, NOPUT, NOBROWNOUT, NOLVP, WDT,
#use delay(clock=4000000, RESTART_WDT)
#include "M300107.h" //pin assignments
void main(){
setup_wdt(WDT_2304MS);
output_low( RUN_LED ); // turn on RUN LED
delay_ms(2000);
output_high( RUN_LED ); // turn off RUN LED
delay_ms(2000);
while (true){
output_low( RUN_LED );
delay_ms(200);
output_high( RUN_LED );
delay_ms(200);
// restart_wdt();
}
}
|
Any help would be much appreciated.
Carl |
|
![](templates/subSilver/images/spacer.gif) |
drh
Joined: 12 Jul 2004 Posts: 192 Location: Hemet, California USA
|
|
Posted: Fri Jul 31, 2015 7:40 am |
|
|
Quote: | #use delay(clock=4000000, RESTART_WDT) |
This will restart the WDT in the delay routine. Remove it and try again. _________________ David |
|
![](templates/subSilver/images/spacer.gif) |
carl
Joined: 06 Feb 2008 Posts: 240 Location: Chester
|
|
Posted: Fri Jul 31, 2015 8:29 am |
|
|
Excellent,
All working as it should:)
Much appreciated. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|