cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F091 RS-485 Half_Duplex_Init vs UART_Init

sean2399
Associate
Posted on October 29, 2016 at 21:08

I have a custom STM32F091 board with ST1480AC RS-485 transceiver in master mode with a single client. HAL_USART_Transmit_IT() works every single time but Receive_IT() only half the time. I have monitored the receive variable during debug and found that the transmit message (with a completely different variable) is echoed in the receive buffer.

I am utilizing a GPIO (not UART RTS) as the Driver Enable (DE) with !RE always low. I pull Driver Enable low in a function call from the TxCpltCallback, and only get a RxCpltCallback on the second and every other Receive_IT(). I have attributed this to the Receive buffer not being large enough to accommodate both the transmitted echo and the desired receive message. There are both a 4 character and a 5 character transmit, and both received messages are an ''ACK\r'' (or ''NAK\r'').

I am utilizing the HAL_UART_Init() API from the STM32CubeMX and I think that might be part of the problem. There are also HAL_HalfDuplex_Init() as well as HAL_RS485EX_Init() API's, but I find the corresponding documentation for these lacking.

I have tried using the UART_Half_Duplex_Enable bit individually as well the HAL_HalfDuplex_EnableTransmitter() and HAL_HalfDuplexEnableReceiver() where appropriate but instead get nothing at all in the Receive_IT() buffer.

I feel this is more of an initialization/setup issue more than an algorithm issue or timing issue. There might be some of the latter, but if I am trying to use RS-485 differently than a standard UART initialization then I'm not going to get far, and that's where I am presently. Any insight would be greatly appreciated.

#rs485 #stm32f0 #half-duplex
0 REPLIES 0