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

Failure on watchdog pic18f46k80
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mhz1575



Joined: 20 Jun 2008
Posts: 14

View user's profile Send private message

Failure on watchdog pic18f46k80
PostPosted: Mon Mar 17, 2014 2:23 pm     Reply with quote

Hello folks,
I have a problem on watchdog because my feeling it that doesn't work.
I forced a problem on the software and the micro didn't reboot.
Is my code wrong?
CCS PCH 5.0

Thank you
Mario
Code:

#include <18F46K80.h>
#device ADC=10 // 10 Bit 0..1023
#FUSES WDT
#FUSES WDT512                 
#FUSES NOXINST                  //Extended set extension and Indexed         
#FUSES NOBROWNOUT               //No brownout reset
#use delay(crystal=20mhz)
.........

void main()
{
   
   boot();
   setup_wdt(WDT_ON);

while(true)
{
.............
restart_wdt();
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 17, 2014 2:30 pm     Reply with quote

Read this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=51760
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Mon Mar 17, 2014 3:03 pm     Reply with quote

Other possibility is the old MPLAB one. A search here will find this.
mhz1575



Joined: 20 Jun 2008
Posts: 14

View user's profile Send private message

PostPosted: Tue Mar 18, 2014 3:58 am     Reply with quote

Hi, I read the post in the past but do not solve my problem.
Can someone tell me which string have I to write for use the wdt on my pic?
Fuse, enable and disable.
I assume that mine is wrong where I don't know.

On the forum I found these simple instructions, the same of mine but on my micro doesn't works. Sad
Code:

#include <18F66J60.h>
#fuses HS
#fuses WDT,WDT512
#use delay(clock=10M)
void main()
{
   SETUP_WDT(WDT_ON);
   while(1)
   {
      delay_ms(32000);
   }
}

Thank you for your help Sad Sad
drh



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

View user's profile Send private message

PostPosted: Tue Mar 18, 2014 8:56 am     Reply with quote

#FUSES WDT_SW
_________________
David
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Tue Mar 18, 2014 12:34 pm     Reply with quote

With the watchdog enabled, as you show it should be triggering. I go back to my possibility that this is the old MPLAB problem. Are you compiling through MPLAB?.
If you are, you need to ensure you are setting this to compile for 'release' It defaults to 'debug', and this overrides (turns off) the watchdog...
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Wed Mar 19, 2014 5:16 am     Reply with quote

Thread title: Failure on watchdog pic18f46k80

Code: #include <18F66J60.h>
mhz1575



Joined: 20 Jun 2008
Posts: 14

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 1:14 am     Reply with quote

Hello folks,
I'm coming back to these issue because after many test following all your indications the situation doesn't change.
The situation is this:

My compiler enviroment is only a CCS 5
I wrote code both for PCM or PCH but didn't works

Due to your experience is better to use Microchip ide mplab + ccs compiler?
Other suggest to obtain a watchdog?

Thank you
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 1:25 am     Reply with quote

How do you know the watchdog reset is not happening?
mhz1575



Joined: 20 Jun 2008
Posts: 14

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 11:13 am     Reply with quote

I know for two reasons:
First on my effective program where I have a modem that didn't answer on the uart blocking on a getc.

Second using a very simple sw where there isn't a reboot by wdt.
Consider that to write this test sw I have used the CCS wizard.

I'm frustrated....

Code:

#include <18F46K80.h>
#device ADC=16

#FUSES WDT                      //Watch Dog Timer
#FUSES WDT512                  //Watch Dog Timer uses 1:512 Postscale
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOBROWNOUT               //No brownout reset

#use delay(crystal=20000000)
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=GPS,restart_wdt,errors)

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

   setup_wdt(WDT_ON);

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

}
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 11:42 am     Reply with quote

It won't give a restart on a getc, since you are turning that off. That is what 'restart_wdt' does in the #use RS232. It adds code to the RS232 routines to prevent the watchdog triggering in these....
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 12:02 pm     Reply with quote

And.. If you are testing in Debug mode, watchdog is disabled.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 12:29 pm     Reply with quote

Quote:
Consider that to write this test sw I have used the CCS wizard.

I'm frustrated....

Expanding on Ttelmah's comment (I was testing this in hardware at
the same time):

You edited the CCS example file, ex_wdt18.c and added the parameter
shown below in bold:
Quote:
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=GPS,restart_wdt,errors)

This is the reason why your program is not working. Remove the restart_wdt parameter.
mhz1575



Joined: 20 Jun 2008
Posts: 14

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 12:33 pm     Reply with quote

Opps, sometimes happen to do wrong after many many test.
Anyway removing restart_wdt from uart declaration the situation didn't change on the test program attacched in the last post. The micro didn't restart.... ufff ufff ufff

No debug, sure.
Could be a problem on the 18f46k80.h files?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 12:51 pm     Reply with quote

1. Are you testing this WDT program on a real hardware board ?

2. Did you buy the board ? Or did you build it yourself ?
If you bought the board, post a link to the website for the board.
If you made the board by yourself, post a link to the schematic.

3. Post your CCS compiler version. Example of version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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