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

7-bit serial data not working?

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



Joined: 30 Oct 2007
Posts: 553
Location: Ottawa, Ontario, Canada

View user's profile Send private message

7-bit serial data not working?
PostPosted: Tue Oct 23, 2012 11:43 am     Reply with quote

PIC: 24HJ128GP306
CCS: 4.132

I was just wondering if anyone had ever tried to send 7-bit data through a PIC24 UART. The code below is supposed to configure my SERIAL_STREAM UART to be 7 bits, then I send 0x81, then the SERIAL STREAM is set as 8-bits then I send 0x18.

What I would expect would be that 0x81 be sent as 0x01 since the high-bit (bit 7) would be ignored since I'm sending 7-bit data but that's not the case...

0x18 remains as-is since it's sent as 8-bit.

I connected a logic analyzer to my TX line and when I send the code below, I see 0x81 and 0x18 as the result of the captured data.
Code:

#use rs232( UART1, baud=57600, parity=N, bits=7, STREAM = SERIAL_STREAM )

fputc( '\x81', SERIAL_STREAM );

#use rs232( UART1, baud=57600, parity=N, bits=8, STREAM = SERIAL_STREAM )

fputc( '\x18', SERIAL_STREAM );


So, should I open a ticket with CCS or does anyone have an explanation for this behaviour?
benoitstjean



Joined: 30 Oct 2007
Posts: 553
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Tue Oct 23, 2012 12:24 pm     Reply with quote

Ok, so I guess I was mislead again by CCS's documentation.

Based on the PIC documentation, it seems that it's only 8-bit and 9-bit data on the PIC...

But CCS's documentation shows, under #USE RS232:

BITS =X Where x is 5-9 (5-7 may not be used with the SCI)
Ttelmah



Joined: 11 Mar 2010
Posts: 19369

View user's profile Send private message

PostPosted: Tue Oct 23, 2012 1:14 pm     Reply with quote

You can send 7bit data, if you enable parity, or use a software UART. The compiler calculates the parity and generates this as the eighth bit.

Best Wishes
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Wed Oct 24, 2012 7:55 am     Reply with quote

The documentation should have said:
"Bits 5-7 only available with FORCE_SW".
_________________
David
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