Skip to main content
A Bravos
Associate III
Jun 28, 2019 4:04 PM UTC
Solved

It will be possible communicates with 7 bits + 2 stop bits, in Stm32f103c8t6?

I need to make a device that communicates (modbus) with a product that uses the rs232 protocol, with 7 bits and 2 stop bits. I use CubeMx and HAL libs. There is some process to do this. As is known in STM32, only have 8 and 9 bits in length.

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Jun 28, 2019 7:08 PM UTC

Yes 8N1 would work

Sending as

USART1->DR = data | 0x80;

Receiving as

data = USART1->DR & 0x7F;

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

4 replies

Tesla DeLorean
Guru
Jun 28, 2019 4:14 PM UTC

The stop bit is just a high bit, the UART shifts least significant bit first. Worst case you should be able to mask DR on reads, and OR on high bits on writes to DR

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
A Bravos
A BravosAuthor
Associate III
Jun 28, 2019 5:04 PM UTC

Thank you Clive Two.Zero for your response.

I think DR (reading / writing) means date? But what's the setup on CubeMx? 8bits N 1 or other option.

Thanks for the information

Bravos

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Jun 28, 2019 7:08 PM UTC

Yes 8N1 would work

Sending as

USART1->DR = data | 0x80;

Receiving as

data = USART1->DR & 0x7F;

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
A Bravos
A BravosAuthor
Associate III
Jun 30, 2019 7:09 AM UTC

Thank you again Clive Two.Zero for your response.

It's working