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

Strange automatic reseting behavoir

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



Joined: 26 Mar 2004
Posts: 4

View user's profile Send private message

Strange automatic reseting behavoir
PostPosted: Fri Apr 02, 2004 4:40 pm     Reply with quote

Hi,

My PIC 18F2320 appears to be reseting automatically. The PIC will run for about 136.5 seconds then reset. The time was measured by implementing an interrupt routine which counts every 50ms and prints the tick count.

I have tried several PICs incase it was a fault with the chip.

The trimed down code is show below - nothing obvious seems wrong - however it still resets. The reset is observered by the "ready ?" prompt reapearing. If it is left for many minutes several ready prompts will appear - indicating it still resets when just waiting on the getc().

Code:

#include <18F2320.h>
#device ADC=10
#fuses INTRC,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

void main() {

   setup_oscillator(OSC_8MHZ | OSC_INTRC) ;
   delay_ms(100);

   printf("Ready ?");
   getc();   
   printf("Running...\r\n");
   while(TRUE) {;}
}


The watchdog timer is turned off as is brownout detection - is there someting else that resets the PIC that im forgetting (theres no problems with stack overflow as it just sits in a loop)?

Thanks,

Ben Confused
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Fri Apr 02, 2004 5:13 pm     Reply with quote

Look in the .LST file at the code generated for your while(TRUE) {;} statement. Make sure it is actually implementing an endless loop, not getting derailed and executing every single instruction until the end of the memory and then warpping around which will make you think it is 'reseting'.
Or try using while(TRUE); instead.
ben_r



Joined: 26 Mar 2004
Posts: 4

View user's profile Send private message

PostPosted: Fri Apr 02, 2004 8:25 pm     Reply with quote

Ok - I seem to have made a little progess...

It seems that this is something to do with the watchdog timer not been disabled (the maximum WDT period is 131seconds - about the duration that i am observing). Enabling the WDT and restarting it within loop allows the program to keep running past the 130second limit - but there must be a way of disabling the WDT?

I have explicity disabled it via the fuses config - however it still seems to be triggering. The config fuses in the .lst file look ok:

Code:

/* .c  */
#fuses INTRC_IO,NOWDT

/* .lst */
Configuration Fuses:
   Word  1: C800   INTRC_IO FCMEN IESO
   Word  2: 1E0F   BROWNOUT NOWDT BORV20 NOPUT WDT32768
   Word  3: 8300   CCP2C1 MCLR PBADEN
   Word  4: 0085   STVREN NODEBUG LVP
   Word  5: C00F   NOCPD NOPROTECT NOCPB
   Word  6: E00F   NOWRT NOWRTD NOWRTB NOWRTC
   Word  7: 400F   NOEBTR NOEBTRB


Word 2 - It seems that a WDT32768 is applied, however the bit for the WDT (bit 0 in the high byte) is 0 so that shouldn't cause a problem...

What is strange is that if I explicity set a lower WDT, ie:

Code:

#fuses INTRC_IO,NOWDT,WDT1024


The expected behavoir would be a reset after 4 seconds (assuming that the compiler is not correctly disabling the WDT as observed) - however this still takes 130 or so seconds to reset.

This is all getting very strange - has anyone had success with running the 18F2320 with the WDT disabled? I had a quick look at the device file and the values all seemed correct...I even reinstalled incase I had a corrupt device file.

Any help would be much appreciated...

Thanks,

Ben
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