View previous topic :: View next topic |
Author |
Message |
Guest
|
rebooting |
Posted: Tue Aug 21, 2007 3:29 pm |
|
|
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 !!
Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 21, 2007 3:38 pm |
|
|
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
|
|
Posted: Tue Aug 21, 2007 8:43 pm |
|
|
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
|
|
Posted: Tue Aug 21, 2007 11:01 pm |
|
|
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.
|
|
|
Guest
|
|
Posted: Wed Aug 22, 2007 7:19 am |
|
|
Thank You
It works. |
|
|
|