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

want to give up .. WDT

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



Joined: 16 Sep 2008
Posts: 7

View user's profile Send private message

want to give up .. WDT
PostPosted: Sun Sep 28, 2008 7:47 pm     Reply with quote

Have worked on WDT for 3 weeks already but still can't make it work....
Really want to give up ..
>.<
Pls help me, i need some tips and do a last try . PIC16F72 ..................
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 28, 2008 8:16 pm     Reply with quote

CCS example file for WDT on 16F-series PICs:
Quote:
c:\program files\picc\examples\ex_wdt.c


More info:
http://www.ccsinfo.com/forum/viewtopic.php?t=25062
http://www.ccsinfo.com/forum/viewtopic.php?t=31022
http://www.ccsinfo.com/forum/viewtopic.php?t=23411
brett777_L



Joined: 16 Sep 2008
Posts: 7

View user's profile Send private message

PostPosted: Sun Sep 28, 2008 9:15 pm     Reply with quote

Hi PCM, I have started with sample program from
C:\Program Files\PICC\Examples

This sample program is keeping reset every 2 sec, and i read those posts you suggested, i tried to add restart_wdt into program, but it still keeps resetting.
Code:

#include <16F72.h>
#fuses RC,WDT,PROTECT

#use delay(clock=4000000,[b]restart_wdt [/b])

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

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


i don't know why watchdog is not cleared in this program ?
i think this is the same happening in below post:
http://www.ccsinfo.com/forum/viewtopic.php?t=25062
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 28, 2008 10:16 pm     Reply with quote

How do you know it resets ? You don't have any printf statements
or any LEDs to show the progress of the program.

Are you running this program on a board ? Or are you running it in a
simulator, or an emulator such as Proteus ?
brett777_L



Joined: 16 Sep 2008
Posts: 7

View user's profile Send private message

PostPosted: Sun Sep 28, 2008 10:25 pm     Reply with quote

I'm running on a board, all components (LED, power supply connected with DMM)shut down and reset every 2 sec.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 28, 2008 10:39 pm     Reply with quote

Did you build this board yourself, or did you buy the board ?

If you bought it, then post the manufacturer and name or model number
of the board.

If you built it yourself, have you ever been able to run any program
successfully on this board ?
Guest








PostPosted: Sun Sep 28, 2008 11:39 pm     Reply with quote

This is a prototype board i made in school time, it works with current program if no watchdog. If i add in above wdt code, the whole system keeps resetting every 2 sec..
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 28, 2008 11:55 pm     Reply with quote

I'm going to give up on helping, because your program doesn't output
to any LED. If it doesn't have the WDT enabled, it won't do anything
except silently sit in a while() loop forever. There's no indication that
it "works" or does anything. It's not a test program. I'm giving up.
brett777_L



Joined: 16 Sep 2008
Posts: 7

View user's profile Send private message

PostPosted: Mon Sep 29, 2008 12:19 am     Reply with quote

that's great ! i also give up
i'm first timer in C and CCS, no teacher is tough, just study micro processor 2 weeks .

anyway, give up ! cheers !
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Mon Sep 29, 2008 2:32 am     Reply with quote

So, how do you know it has reset ? Exactly!

Your printf statements are commented out, you don't appear to be controlling an LED, you don't have an #USE RS232 statement so if you did uncomment the printf's they would most likely would still fail!

Are you trying to monitor it using the debugger ?
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Mon Sep 29, 2008 2:52 am     Reply with quote

Hey brett777_L,

C'mon, don't give up so easily. PCM Programmer was just indicating that to get help on the forum you would have to make it clear to people what you are attempting to do.

So, though spoon feeding is not recommended, I'm posting what your code should look like.

Code:

#include <16F72.h>
#fuses RC,WDT,PROTECT
#use rs232(baud=9600, xmit=pin_a2,rcv=pin_a3)

#use delay(clock=4000000)

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

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



You seem to be using an RC oscillator. Do note that RC oscillators aren't recommended for RS232. Try using a 4MHz XT or a higher speed HS.

Rohit
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