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 support@ccsinfo.com

WDT in PIC18 it's not working

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



Joined: 30 Jan 2008
Posts: 197

View user's profile Send private message

WDT in PIC18 it's not working
PostPosted: Thu Apr 05, 2018 8:04 pm     Reply with quote

Hi, I am use a PIC18F4620 at 20Mhz and the CCS version 4.074 to I am using the WDT.

As you can see in my code, the WDT is working, the problem is that it does not stop when the setup_wdt(WDT_OFF) command, there are parts of my code that I need to disable and in others enable the WDT but it is not disabled and the WDT keeps running, can someone tell me what my error is?

Code:
#include <18F4620.h>
#fuses HS,WDT32768,PROTECT,NOLVP,NOBROWNOUT
#use delay(clock=20MHz)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)// RS232 Estándar


main()   {

   switch ( restart_cause() )
   {
      case WDT_TIMEOUT:
      {
         printf("\r\nRestarted processor because of watchdog timeout!\r\n");
         break;
      }
      case NORMAL_POWER_UP:
      {
         printf("\r\nNormal power up!\r\n");
         break;
      }
   }

   //setup_wdt(WDT_ON)
   setup_wdt(WDT_OFF);

   while(TRUE)
   {
      restart_wdt();
      printf("Hit any key to avoid a watchdog timeout.\r\n");
      getc();
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 05, 2018 8:25 pm     Reply with quote

Add NOWDT to your #fuses line. Then you can turn the WDT on and off
by software control. This is in the PIC data sheet.
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Fri Apr 06, 2018 4:12 am     Reply with quote

If you are having to turn the watchdog on and off then you've got a big design/architecture problem. If you use the watchdog at all, and most people who are using it/having trouble using it on PICs don't need it at all and would be better off without it, then you should turn it on and leave it on. If you keep turning it on and off then you pretty much lose any protection against errant code that it provides.
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