| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| Mortenc 
 
 
 Joined: 22 Feb 2007
 Posts: 55
 
 
 
			    
 
 | 
			
				| use rs232 with parity=E |  
				|  Posted: Fri May 25, 2007 6:33 am |   |  
				| 
 |  
				| Hello Forum, 
 I'am new with C-compiler.
 I have made a rs232 communication with parity=N, but now I'am trying to make a rs232 com. with parity=E.
 It seems to that the parity is not working.
 My processor is PIC16F883.
 
 #use rs232(baud=19200,parity=E,xmit=PIN_C6,rcv=PIN_C7,bits=8, stream=EK)
 
 Does anyone have experience with this?
 |  | 
	
		|  | 
	
		| Joyce 
 
 
 Joined: 25 May 2007
 Posts: 2
 Location: Rennes (France)
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Fri May 25, 2007 6:38 am |   |  
				| 
 |  
				| what does Parity=E means ? |  | 
	
		|  | 
	
		| Mortenc 
 
 
 Joined: 22 Feb 2007
 Posts: 55
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri May 25, 2007 6:43 am |   |  
				| 
 |  
				| E = even 
 The CCS manual tells that you can use: N for no, E for even and o for odd.
 The is used for simple, but fast making a check about the communication is failed or good.
 |  | 
	
		|  | 
	
		| rberek 
 
 
 Joined: 10 Jan 2005
 Posts: 207
 Location: Ottawa, Canada
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri May 25, 2007 6:58 am |   |  
				| 
 |  
				| What makes you think that the parity is not working? 
 r.b.
 |  | 
	
		|  | 
	
		| Ttelmah Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				|  |  
				|  Posted: Fri May 25, 2007 7:01 am |   |  
				| 
 |  
				| What compiler version?. What doesn't work?.
 Basically, the PIC's don't support parity. What is done, is if parity is enabled, then 9bit transmission is used (for 8bit data), and the 9th bit is set to the required parity value. On reception, the parity returned in the 9th bit (either accessed through RS232_ERRORS, or using a 'long' to retrieve the value). There have been problems in the past with some particular compiler versions (and threads about it here).
 
 Best Wishes
 |  | 
	
		|  | 
	
		| Mortenc 
 
 
 Joined: 22 Feb 2007
 Posts: 55
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri May 25, 2007 7:17 am |   |  
				| 
 |  
				| I have measured with an oscilloskope. 
 I try send 0xA2 = 10100010
 and try     0xB3 = 10110011
 
 Both is not even in my understanding. and I look for a low
 I can not see anything else unless the stop bit which is high.
 
 My compiler version is PCM 4.038
 
 In the CCS manual about "use rs232" I can't see anything about that the PIC doesn't support parity E and O. Does the compiler not taken care of that? (I think I can do it in assembler with this processor)
 |  | 
	
		|  | 
	
		| rberek 
 
 
 Joined: 10 Jan 2005
 Posts: 207
 Location: Ottawa, Canada
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri May 25, 2007 7:22 am |   |  
				| 
 |  
				| I believe parity is calculated across the data byte only in RS232.  The parity bit would be high for each of the two bytes you have transmitted if you are using even parity. 
 
 
 r.b.
 |  | 
	
		|  | 
	
		| Mortenc 
 
 
 Joined: 22 Feb 2007
 Posts: 55
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri May 25, 2007 7:37 am |   |  
				| 
 |  
				| Thanks to rberek 
 It seems to I have misunderstand the EVEN.
 I must do some more test to check the working.
 I tried to communicate with another device and it did answer me.
 This device use 8 databit and parity EVEN.
 I'am wondering about I must use "bits=9" but then the compiling fails and says that "the data is out of range - too many bits".
 |  | 
	
		|  | 
	
		| Ttelmah Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				|  |  
				|  Posted: Fri May 25, 2007 9:11 am |   |  
				| 
 |  
				| No. The point is the compiler automatically uses the 9bit mode to send the parity for you. You can't generate parity on 9bit values, since this would require a ten bit mode!. Hence the error.
   As another poster has said, the parity is on the data byte only.
 
 Best Wishes
 |  | 
	
		|  | 
	
		| Mortenc 
 
 
 Joined: 22 Feb 2007
 Posts: 55
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri May 25, 2007 9:35 am |   |  
				| 
 |  
				| Thanks a lot - I love these forums. 
 I must continue after the weekend. It seems to that there is something  wrong with the device I have to communicate with.
 |  | 
	
		|  | 
	
		|  |