cancel
Showing results for 
Search instead for 
Did you mean: 

9-bit UART data not as expected

davidpilcher9
Associate III

Hi

We are using the STM32L4S7AI. We have USART2 configured as 9-bit data.

We are using the HAL and have been using 8-bit HAL on many STM32 for a while... this is our first 9-bit data use.

We set UART_InitTypeDef.WordLength to UART_WORDLENGTH_9B.

On the wire, we have this message:

0693W00000JPNK5QAP.pngWe have our UART configured as 19200, 9bit, 2 STOP, no parity.

So... for the first byte, given the image in the STM MCU guide:

0693W00000JPNKUQA5.png 

I'd expect this to be LSB to MSB and have a value of 2 when read.

We are reading RDR under interrupt. It is a 16bit register:

uint16_t data = READ_REG( port->hwport->Instance->RDR );

data is assigned to 1.

The values on the wire above read as 001 0FE 0F7 0D7 1BE

Why is the STM32 treating the first bit on the wire as the 9th bit?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Looks like you're inverting, the TWO STOP BITs are HIGH, the START BIT is LOW

First 9-bit word here is 0x1FD, second 0x003, third is 0x011

An RS232 level shifter would invert the signal

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

Looks like you're inverting, the TWO STOP BITs are HIGH, the START BIT is LOW

First 9-bit word here is 0x1FD, second 0x003, third is 0x011

An RS232 level shifter would invert the signal

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
davidpilcher9
Associate III

Now I feel dumb. It was 2-wire 485 and the lines were reversed. Now it looks good.

Thanks!