cancel
Showing results for 
Search instead for 
Did you mean: 

Uart Parity problem

davidw
Associate II
Posted on May 01, 2009 at 07:55

Uart Parity problem

3 REPLIES 3
davidw
Associate II
Posted on May 17, 2011 at 13:10

Hi all,

STM32F103ZE

Has anyone had problems with parity on Uart1 (not checked the others yet), even and none appear to work correctly but odd simply does nothing usefull as far as I can tell. The settings in the register match thoses in the reference manual, but the output is wrong.

I have tried:

8 databits plus parity giving 7 databits and the parity bit at the reciever.

9 databits plus parity which I would expect to give 8 databits and the parity bit at the reciever, however it does not appear to do so.

when in this last mode, an ascii message can be read correctly with 8n1

TIA,

Dave

[ This message was edited by: davidw.evans on 30-04-2009 13:59 ]

[ This message was edited by: davidw.evans on 30-04-2009 14:00 ]

picguy
Associate II
Posted on May 17, 2011 at 13:10

I was all set to say “RS-232 parity – no such thing� then I checked the STM32 docs. I learn something new every day.

My advice: don’t use parity. Use 10-bit frames. Start 8 data bits & stop. No parity. On normal ADCII text the high bit in each byte will be zero. This is what you want for communication with other software.

Need parity? Fix hardware first. Still need parity? Be sure your receiver wants the parity you are sending. A protocol analyzer may help you see what you are sending. Or use a digital scope as a logic analyzer.

Hardware troubles? Define a protocol with serious error recovery. Hint: when sending commands make the commands something that can be done again. I.e. zero a byte rather than subtract one knowing that the byte was one. Acknowledge all commands. Time out on acknowledgment. Etc.

davidw
Associate II
Posted on May 17, 2011 at 13:10

Hi Picguy,

Thanks for your reply.

That’s fine if you are in control of the design of everything you are connecting to, however I have to interface with existing equipment that needs 8 data bits and parity.

In this instance we are connecting to a thermal printer, so we send ASCII and control characters thus 8 data bits are required, at some point in the past when rs232 was the USB of its day odd parity was chosen so that’s what I need to support.

cheers,

Dave

[ This message was edited by: davidw.evans on 01-05-2009 11:30 ]