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

rebooting

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








rebooting
PostPosted: Tue Aug 21, 2007 3:29 pm     Reply with quote

I have a PIC18F2520 as a slave. I have another device(Master) that reads the data from the slave. All the PIC18F2520(SLAVE) does, is run an infinite loop and acquire data from a few sensors. And the master in turn gets the values of the sensors from the slave.

I noticed that the PIC18F2520(Slave) resets every 125 to 130 secs. I wanted to know what is causing the PIC to reset every time Sad !!

Thank you.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 21, 2007 3:38 pm     Reply with quote

Quote:

I noticed that the PIC18F2520(Slave) resets every 125 to 130 secs.


The watchdog timer is probably enabled. See this section
from the 18F2520 data sheet below (in bold):
Quote:
23.2 Watchdog Timer (WDT)

For PIC18F2420/2520/4420/4520 devices, the WDT is
driven by the INTRC source. When the WDT is
enabled, the clock source is also enabled. The nominal
WDT period is 4 ms and has the same stability as the
INTRC oscillator.
The 4 ms period of the WDT is multiplied by a 16-bit
postscaler. Any output of the WDT postscaler is
selected by a multiplexer, controlled by bits in
Configuration Register 2H. Available periods range
from 4 ms to 131.072 seconds (2.18 minutes).
Guest








PostPosted: Tue Aug 21, 2007 8:43 pm     Reply with quote

Is there a line of code in C, that will completely disable the WDT and never let the PIC reset?
Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 21, 2007 11:01 pm     Reply with quote

Put NOWDT in your #fuses statement, like this:
Quote:
#include <18F2520.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//=================================
void main()
{

while(1);
}


Then look through your program and make sure you do not have
the following line, which will turn on the Watchdog timer. If you've
got this line in there, then delete it.
Code:
setup_wdt(WDT_ON);
Guest








PostPosted: Wed Aug 22, 2007 7:19 am     Reply with quote

Thank You Smile
It works.
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