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

Loop problem

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







Loop problem
PostPosted: Thu May 29, 2008 2:34 am     Reply with quote

void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
//setup_oscillator(OSC_8MHZ|OSC_TIMER1);

disable_interrupts (global);

fputs("Test", SOFT_UART);
fputs("Bla", SOFT_UART);

}


Anyone knows why this little piece of code shows me this?

Test
Bla
Test
Bla
etc etc.

It looks like my program hangs in a non defined loop.

I hope you guys can help me out.

Thanks alot
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

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

PostPosted: Thu May 29, 2008 3:48 am     Reply with quote

You don't give your PIC or your fuses, so I'll assume you've got a part where if the WDT is enabled via fuses, it cannot be disabled via software (setup_wdt).

Your code drop off the end, the pic goes to sleep, and the wdt restarts the pic a short while later.
_________________
Andrew
Voltagerange
Guest







Now everthing is here:)
PostPosted: Thu May 29, 2008 4:19 am     Reply with quote

#include <18F4320.h>
#device adc=8

#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES MCLR //Master Clear pin enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOCPB //No Boot Block code protection
#FUSES NOWRTB //Boot block not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET

#use delay(clock=8000000)
#use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, stream=HW_UART)
#use rs232(baud=9600,parity=N,xmit=PIN_D0,rcv=PIN_D1,bits=8, stream=SOFT_UART)

Also my whole header file.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Re: Now everthing is here:)
PostPosted: Thu May 29, 2008 8:20 am     Reply with quote

I'm not sure why your program is looping, especially since you have the NOWDT fuse specified. But why are you allowing your program to fall off the end? This calls for some experiments. To see if something is resetting your PIC, change the program to:
Code:

k = 0;
while(1)
{
   k++;
  fprintf(SOFT_UART,"%1d ",k);
}

What this program does should tell you a lot.

Robert Scott
Real-Time Specialties
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Fri May 30, 2008 1:34 am     Reply with quote

Look at the .lst file and see what the last instruction is after the last line in main.
D-Kens



Joined: 09 May 2005
Posts: 35
Location: Toulouse (France)

View user's profile Send private message MSN Messenger

PostPosted: Mon Jun 02, 2008 12:53 am     Reply with quote

I'd suggest that you read the restart_cause() value to check the reason why your PIC is rebooting. Wink
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

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

PostPosted: Tue Jun 03, 2008 9:19 am     Reply with quote

You do have a pullup on MCLR?
_________________
Andrew
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

PostPosted: Tue Jun 03, 2008 10:27 am     Reply with quote

Apparently the OP (Voltagerange) has lost interest in his question. He has not answered any of the helpful questions or suggestions that have been posed for the last 5 days.

Robert Scott
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