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 on PIC18F46K22

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



Joined: 19 Dec 2014
Posts: 23

View user's profile Send private message

WDT on PIC18F46K22
PostPosted: Fri Mar 01, 2019 7:11 am     Reply with quote

Hi all,
I am using:
pcwhdupd Version 5.82.20.10
PIC18F46K22

I am trying to add a WDT in my code so I went and try the CCS example:
ex_wdt18.c
I just replace the clock with clock=64MHz,crystal=16MHz and replace the device with PIC18F46K22.

I was expecting the PIC to reset itself if I didn't press a key... But nothing is happening. Is there anything special about the PIC18F46K22 ?

Code:

#include <18F46K22.h>
#use delay(clock=64MHz,crystal=16MHz)
#USE rs232(baud=9600, UART1, errors, stream=to_Screen)

void 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);

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

Thank you!
RNR
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 01, 2019 7:27 am     Reply with quote

You need to build in 'release' mode and NOT be connected to an ICD or debugger.
IE: PIC has to be 'standalone'.....
if you are connected to icd/debugger, there's software that shuts off the wdt.
RNR107



Joined: 19 Dec 2014
Posts: 23

View user's profile Send private message

PostPosted: Fri Mar 01, 2019 9:20 am     Reply with quote

Hi temtronic,
That's a good one! I didn't know that.... Thanks!

Found an other problem (and the solution) I think there is a mistake in the CCS 18F46K22.h file. WDT_TIMEOUT is defined as 7 but I am getting 15 from RESTART_CAUSE() ???
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 01, 2019 9:38 am     Reply with quote

Unfortunately this PC (W7) has decided to not let me play with PICs since Wednesday. No amount of remove/add/pray to the Great PIC in the sky has got it 'up and running'.
BTW I've never used the WDT on the 46k22, though it is my favorite.

Jay
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