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

How to change PARITY in run-time ?

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



Joined: 05 Aug 2009
Posts: 37

View user's profile Send private message MSN Messenger

How to change PARITY in run-time ?
PostPosted: Thu May 08, 2014 10:07 pm     Reply with quote

Good day for everyone.

I have question need help ! Very Happy

The CCS library have provided "set_uart_speed( )" function to change baud rate in run-time but I also hope to change PARITY and data bits (5-9) of RS232.

Any syntax can achieve this function ? Question
Ttelmah



Joined: 11 Mar 2010
Posts: 19222

View user's profile Send private message

PostPosted: Fri May 09, 2014 12:26 am     Reply with quote

You have to use multiple streams.

However be aware, that the hardware only supports 8 or 9 bits total data. So 7 bits with parity, 8 bits with parity, 8 bits no parity and 9 bits no parity are the only versions that can actually be generated by the hardware UART. Whether parity is actually generated correctly, depends then on the compiler version (a lot don't). The chip itself does not support or understand parity at all, it is a software solution used. Hence the next paragraph.

The easiest way is to just have two streams supporting 8, or 9 bit modes, and generate the parity yourself (efficient routines to do this have been published here). You then avoid any compiler issues regarding parity.

However the need for different data lengths has almost totally vanished in recent years, with 99.9% of systems using 8bit, with or without parity only.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri May 09, 2014 2:33 pm     Reply with quote

Who wants to use parity anyway?
It creates 12,5% extra data overhead but can only detect a limited set of communication errors (only when an odd number of bits is flipped).
Other error detecting mechanisms like CRC have much less overhead and will detect a wider range of practical communication errors.
temtronic



Joined: 01 Jul 2010
Posts: 9108
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri May 09, 2014 5:47 pm     Reply with quote

also...
...it's not very common to NOT know what the other device's communications specs are BEFORE you connect to it.Without knowing the specs, you'll always get errors.
While there are 'autobaud' detect algorithms I've never needed them or parity 'trees' in the past 20+ years and I've connected to a lot of 'interesting' stuff.


hth
jay
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