| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			hentropy
 
 
  Joined: 27 Oct 2004 Posts: 6 Location: Kuala Lumpur, Malaysia 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| How do you detect a parity error with a software USART? | 
			 
			
				 Posted: Sat Oct 30, 2004 12:52 am     | 
				     | 
			 
			
				
  | 
			 
			
				Hi guys,
 
 
I would really appreciate your assistance for this beginner's problem:
 
 
I'm using the software USART of a PIC16F874 to receive information for display on an LCD panel. I noticed that there are occasional errors in my transmission, so I decided to enable Even parity.
 
 
 	  | Code: | 	 		  #include <16f874.h>
 
#fuses XT,NOWDT,NOPROTECT,PUT,NOLVP
 
#use delay( clock=4000000 )
 
#use rs232( baud=1200, parity=E, bits=8, xmit=PIN_A4, rcv=PIN_A5, errors ) | 	  
 
 
Unfortunately, RS232_ERRORS doesn't work with the software USART, giving an "Undefined identifier" compiler error (although the documentation says it's suppose to have some use). Therefore, I don't think I can test for any error conditions.
 
 
How would you guys do it? | 
			 
		  | 
	
	
		  | 
	
	
		
			ckielstra
 
 
  Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sat Oct 30, 2004 8:15 am     | 
				     | 
			 
			
				
  | 
			 
			
				 	  | Quote: | 	 		  | Unfortunately, RS232_ERRORS doesn't work with the software USART, giving an "Undefined identifier" compiler error | 	  
 
From the documentation you can conclude the RS232_ERRORS variable in a No UART configuration only has a purpose when using 9 data bits and/or the FLOAT_HIGH option. You are using neither of these settings and therefor the variable is optimized away causing your error.
 
 
But then, you start wondering how the compiler can ever return a parity error... Being curious I looked into the code generated for the RS-232 software receive and it turns out the parity is not checked at all!!! The parity bit is just skipped and no checks are performed. I know the CCS documentation isn't perfect, but this omission surprises me a lot.
 
B.T.W. I checked in PCH v3.187 | 
			 
		  | 
	
	
		  | 
	
	
		
			hentropy
 
 
  Joined: 27 Oct 2004 Posts: 6 Location: Kuala Lumpur, Malaysia 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sun Oct 31, 2004 10:06 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Thanks for your reply ckielstra. At least now i know there's _NO_ way to do that.
 
(I'm using PCM v 3.117.) | 
			 
		  | 
	
	
		  | 
	
	
		
			asmallri
 
 
  Joined: 12 Aug 2004 Posts: 1660 Location: Perth, Australia 
			
			 
			 
			 
			 
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Nov 01, 2004 4:26 pm     | 
				     | 
			 
			
				
  | 
			 
			
				 	  | Quote: | 	 		  | ...At least now i know there's _NO_ way to do that.  | 	   Not quite. You can code your own software uart - then you can do whatever you want | 
			 
		  | 
	
	
		  | 
	
	
		 |