Skip to main content
HLaus.2
Associate
December 13, 2021
Question

USART running 7N1. My STM32F429 must interface an old modbus system running 7N1 on a RS422 bus, as slave. However, I can't see how to setup the STM32 as 7bit, NONE, 1 stopbit - not in Qube, not be registeres direct. Is this true ?

  • December 13, 2021
  • 6 replies
  • 2134 views

..

This topic has been closed for replies.

6 replies

LCE
Principal II
December 13, 2021

"7N1" usually means 1 start bit, and I haven't seen any UART / RS232 like interface without a start bit in the last 20 years - but I haven't seen all! ;)

Anyway, I can't check the F429, but I just see that only the newer STMs have the 7N1 options (checked: STM32G4, STM32F7 ref manuals).

So that might get tricky, if you cannot switch the STM, on the other hand surely possible, as Modbus is rather slow (9k6?).

HLaus.2
HLaus.2Author
Associate
December 13, 2021

"7N1" means: 7 data, no parity and 1 stop bit. All uart communication uses 1 start bit - this has allways been so. But that is not the question.

How do I setup the STM32F429 to read the incomming modus with the framing 7N1, without getting framing errors, etc.

Muhammed Güler
Senior III
December 13, 2021

bit 7 will act as your stop bit when sending and receiving single bytes. When sending and receiving multi-bytes, you will need to think of all the data as one big bit string and use it in 7-bit chunks. the extra stop bits shouldn't be a big problem.

You can also switch to one of the STM32's MCUs that support 7-bit UART (eg STM32F7,H7,L4)

HLaus.2
HLaus.2Author
Associate
December 13, 2021

Ok, thanks for the reply. But.... the incomming data stream is 7N1 - which means (if the STM is programmed to 8 data, No parity) the incomming stop bit databit will be treated as the 8th - and the STM uart will be missing a stopbit - which will be a framing error doc according to Reference manual RM0090, page 977: "The stop bit is not recognized on reception at the expected time". A quick test gives USART_SR_FE - framing errors.

LCE
Principal II
December 13, 2021

This should work if you set up the STM's UART without a stop bit, as @Muhammed G�ler​ proposed.

Just mask the last bit (MSB) of each received byte.

TDK
December 13, 2021

It is not possible to set up a UART on the STM32F4 without a stop bit.

"If you feel a post has answered your question, please click ""Accept as Solution""."
TDK
December 13, 2021

The UART in the STM32F4 can have either 8 or 9 data bits (including parity). 7-N-1 is not a supported configuration.

See the USART_CR1 register for details.

"If you feel a post has answered your question, please click ""Accept as Solution""."
HLaus.2
HLaus.2Author
Associate
December 13, 2021

Usart can't be setup without stopbits. I was looking for confirmation of my setup and the errors I see, so thanks to TDK for Your answer.