cancel
Showing results for 
Search instead for 
Did you mean: 

Are there any examples of RS485 UART in the F0 STM32 Cube?

SPren
Associate II

I have a STM32F091 Nucleo-64 and have the basic RS232 UART examples (ComPolling and IT) from the Cube working.

I need to implement RS485 and was hoping to find a basic example to build upon.

I'm currently going through the STM32Cube_FW_F0_V1.9.0 examples and RM0091 Reference Guide and am looking at USART_CR1_WAKE and USART_CR1_MME but a simple example would get me over this initial hurdle.

1 ACCEPTED SOLUTION

Accepted Solutions

You need to enable DE pin in GPIO as the corresponding alternate function for USART, enable USART_CR3_DEM, set the correct DE polarity (USART_CR3_DEP), and set DE assertion and deassertion times (USART_CR1_DEAT and USART_CR1_DEDT).

Also you might need to enable RX and TX pin inversion (USART_CR2_RXINV, USART_CR2_TXINV), depending what RS485 transceiver microchip you are using.

If you are using Cube to generate the application's skeleton, then it can do all those things. Just pick the correct settings for your U(S)ARTx peripheral and generate the code.

View solution in original post

1 REPLY 1

You need to enable DE pin in GPIO as the corresponding alternate function for USART, enable USART_CR3_DEM, set the correct DE polarity (USART_CR3_DEP), and set DE assertion and deassertion times (USART_CR1_DEAT and USART_CR1_DEDT).

Also you might need to enable RX and TX pin inversion (USART_CR2_RXINV, USART_CR2_TXINV), depending what RS485 transceiver microchip you are using.

If you are using Cube to generate the application's skeleton, then it can do all those things. Just pick the correct settings for your U(S)ARTx peripheral and generate the code.