CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

WDT

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

WDT
PostPosted: Fri Jul 31, 2015 6:31 am     Reply with quote

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
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Fri Jul 31, 2015 7:40 am     Reply with quote

Quote:
#use delay(clock=4000000, RESTART_WDT)


This will restart the WDT in the delay routine. Remove it and try again.
_________________
David
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Fri Jul 31, 2015 8:29 am     Reply with quote

Excellent,

All working as it should:)

Much appreciated.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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