Electronic – STM32 RS485 connection

rs232rs422rs485serialstm32

I want to interface stm32f0 with rs422 (half duplex and full duplex). What I'm not getting how to connect RE and DE signals to rs 232. From UART I'll be having RX, TX, VCC and GND pins which i need to connect to TTL to RS232 converter ( http://www.emartee.com/Images/websites/emartee.com/T1d6JsXfBrXXXJ2U79_105143_jpg_310x310.jpg ) but where i should connect the RE and DE signals?

Best Answer

The answer, as found in some random documentation checked into GitHub, is:

RS485 flow control (Driver enable feature) handling is possible through the following procedure:

# Program the Baud rate, Word length = 8 bits, Stop bits, Parity, Transmitter/Receiver modes and hardware flow control values using the USART_Init() function.

# Enable the Driver Enable using the USART_DECmd() function.

# Configures the Driver Enable polarity using the USART_DEPolarityConfig() function.

# Configures the Driver Enable assertion time using USART_SetDEAssertionTime() function and deassertion time using the USART_SetDEDeassertionTime() function.

# Enable the USART using the USART_Cmd() function.

The assertion and dessertion times are expressed in sample time units (1/8 or 1/16 bit time, depending on the oversampling rate).

https://github.com/szczys/stm32f0-discovery-basic-template/blob/master/Libraries/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_usart.c

This lets me Google search for the USART_DECmd command, which in turn leads me to the following application note:

http://www.st.com/content/ccc/resource/technical/document/application_note/c8/5f/ef/b7/f8/a5/48/15/DM00055208.pdf/files/DM00055208.pdf/jcr:content/translations/en.DM00055208.pdf

This contains the final gold medal sentence:

The DE signal is mapped to the RTS pin of the USART, and in this application it is
connected with the pin 12 of port A (PA12).
(For STM32F05x)

Should it be this hard to find this out? No. But we live in an imperfect world.

The "receive enable" signal input on your transciever can either be wired to always-on (you will receive your own data,) or you can wire it to an inverse of the DE signal; typically using a pull-up and a N-channel MOSFET (like BS-138) with gate tied to the DE output signal. Or just use a transciever that switches both directions with a single pin :-)

Related Topic