![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
benoitstjean
Joined: 30 Oct 2007 Posts: 553 Location: Ottawa, Ontario, Canada
|
7-bit serial data not working? |
Posted: Tue Oct 23, 2012 11:43 am |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
benoitstjean
Joined: 30 Oct 2007 Posts: 553 Location: Ottawa, Ontario, Canada
|
|
Posted: Tue Oct 23, 2012 12:24 pm |
|
|
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) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Oct 23, 2012 1:14 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
drh
Joined: 12 Jul 2004 Posts: 192 Location: Hemet, California USA
|
|
Posted: Wed Oct 24, 2012 7:55 am |
|
|
The documentation should have said:
"Bits 5-7 only available with FORCE_SW". _________________ David |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|