|
|
View previous topic :: View next topic |
Author |
Message |
sindyme
Joined: 05 Aug 2009 Posts: 37
|
About RS232 9bit setting and question |
Posted: Sun Apr 25, 2010 8:24 pm |
|
|
morning everybody
I have question about RS232's 9Bit transmission.
How can I setting this syntax -->
Code: |
#use rs232(UART1,baud=115200,parity=N,bits=8,stream=coma) |
or
Code: | #use rs232(UART1,baud=115200,parity=1,bits=9,stream=coma) |
( X ) can't build
or
Code: | #use rs232(UART1,baud=115200,parity=odd,bits=9,stream=coma) |
( X ) can't build
I need setting 9bit mode and odd.
And ~ if I finished the setting, and how can I get the odd bit only ?
I must get the odd bit to calculate.
Example :
start bit
1 data bit
0 data bit
1 data bit
0 data bit
1 data bit
0 data bit
1 data bit
0 data bit
1 odd bit < ------ I want to get it
stop bit |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19497
|
|
Posted: Mon Apr 26, 2010 2:20 am |
|
|
The reason is the hardware...
The PIC UART, supports 8bits, plus one 'extra' bit. Normally this bit is used for parity, _or_ it can be used to give an extra data bit. Problem is there is not a tenth bit available from the hardware to give 9bits plus parity.
So the hardware UART, cannot give 9bits plus parity.
This will work with the software UART, but with the limitations this brings on timings...
In many cases, it doesn't matter. If (for example), you are receiving only, you can set up for 9bits without parity, and the parity bit will arrive when the stop bit ought to be present. Data will still be intact, and the 'OERR' bit may get set (depending on the polarity of the parity bit concerned).
Sending via the software UART, is not so problematical as receiving (especially at high rates), so a 'solution', is to use the hardware UART to receive, either just ignoring parity, using 'ERRORS', and letting the compiler automatically clear the OERR bit, or writing your own code, to work out whether the parity bit should be high or low, and testing if OERR is set, to 'test' for parity errors, then clearing this. Then use a software UART for the TX side.
So, the PIC hardware does not support 9bits plus parity (it is a rare combination).
Best Wishes |
|
|
|
|
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
|