| 
	
	|  |  |  
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| filjoa 
 
 
 Joined: 04 May 2008
 Posts: 260
 
 
 
			    
 
 | 
			
				| program crash |  
				|  Posted: Wed May 01, 2013 12:12 pm |   |  
				| 
 |  
				| 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
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed May 01, 2013 12:15 pm |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed May 01, 2013 4:56 pm |   |  
				| 
 |  
				| 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
 |  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |