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 CCS Technical Support

use rs232 with parity=E

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



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

use rs232 with parity=E
PostPosted: Fri May 25, 2007 6:33 am     Reply with quote

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)

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

PostPosted: Fri May 25, 2007 6:38 am     Reply with quote

what does Parity=E means ?
Mortenc



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Fri May 25, 2007 6:43 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri May 25, 2007 6:58 am     Reply with quote

What makes you think that the parity is not working?

r.b.
Ttelmah
Guest







PostPosted: Fri May 25, 2007 7:01 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri May 25, 2007 7:17 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri May 25, 2007 7:22 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri May 25, 2007 7:37 am     Reply with quote

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







PostPosted: Fri May 25, 2007 9:11 am     Reply with quote

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. Smile
As another poster has said, the parity is on the data byte only.

Best Wishes
Mortenc



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Fri May 25, 2007 9:35 am     Reply with quote

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.
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