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

Serial communications and stop bits

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







Serial communications and stop bits
PostPosted: Thu Dec 16, 2004 3:48 am     Reply with quote

Hi
Is there a way to set the number of stop bits in serial
communications? Apparently, with high baud rates (115200)
I loose the communication with my device (who uses
a 2 stop bits protocol, while PIC uses 1). Lower baud
rates (9600) are much better (almost 90% of success in
sending messages) but I need to switch to 115200
Thanks in advance, ciao!
mauro
Ttelmah
Guest







Re: Serial communications and stop bits
PostPosted: Thu Dec 16, 2004 4:09 am     Reply with quote

mauro wrote:
Hi
Is there a way to set the number of stop bits in serial
communications? Apparently, with high baud rates (115200)
I loose the communication with my device (who uses
a 2 stop bits protocol, while PIC uses 1). Lower baud
rates (9600) are much better (almost 90% of success in
sending messages) but I need to switch to 115200
Thanks in advance, ciao!
mauro

There is one way of 'cheating' this.
The UART on the PIC, only supports one stop bit. However it supports 9bit comms. If you set the ninth bit, this gets sent as another 'high' bit before the single stop bit, generating effectively two stop bits. The chip will then receive the extra stop bit as the ninth data bit, which can be ignored.
Set the UART up to use 9bit comms, and when you would call 'putc', instead call a 'wrapper' function, like:
Code:

#bit ninth_bit = RS232_ERRORS.7

void putc9(int8 val) {
   ninth_bit=1;
   putc(val);
}


This then ensures the ninth bit is set for each byte, and generates the required effect.

Best Wishes
mauro
Guest







Re: Serial communications and stop bits
PostPosted: Thu Dec 16, 2004 7:33 am     Reply with quote

Ttelmah wrote:

There is one way of 'cheating' this.[...]


thank you very much, it works perfectly!
I had already tried the 9-bit data solution but hadn't
managed to get it working...
ciao and thanks again

mauro
Ttelmah
Guest







PostPosted: Thu Dec 16, 2004 9:37 am     Reply with quote

Glad it worked. :-)
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