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

program crash

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



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

program crash
PostPosted: Wed May 01, 2013 12:12 pm     Reply with quote

Hi

I try read from GPS module and write on windows terminal with PIC18F458 @ 20Mhz but program crash after read +-9 strings.
Code:

#include <18F458.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,BROWNOUT,STVREN
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, stream=gpsport)
#use rs232(baud=9600,parity=N,xmit=PIN_C4,rcv=PIN_C5,bits=8, stream=outport)

#include<string.h>
#include<stdlib.h>
   
   int1 data_available=FALSE;   
   char c;
   
   void rda_isr();
 
#int_rda
void rda_isr(void)
   {
   c = getc(gpsport);
   data_available=TRUE;
   
   fputc(c,outport);
   }
   

void main(void)
{   
   enable_interrupts(GLOBAL);
   enable_interrupts(INT_RDA);

while(TRUE)
{

}
}

Any idea where stay the problem?

best regards
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed May 01, 2013 12:15 pm     Reply with quote

Hi,

Modify your #use rs232 line as shown below.

Code:

#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, stream=gpsport, Errors)


BTW, your program is probably not 'crashing' in the traditional sense. Rather,
the UART is becoming over-run, and is locking up, preventing other
characters from being received. The addition of 'Errors' to the #use rs232 line
will allow the UART to recover in the event of an over-run.

It's not a good idea to be putting something like your putc inside the serial
ISR. You should be reading characters into a buffer, and then printing them
out in your Main() routine. Looke at the example program ex_sisr.c to see
how this is done!

John
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Wed May 01, 2013 4:56 pm     Reply with quote

Hi

thanks ezflyr

Problem solved, with "ERRORS" add, it make UART reset...

I know this is not correct, but is the 1st test, to start the program.

best regards
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