AnsweredAssumed Answered

Problem using RS485 on STM32F030R8T6

Question asked by Gates on Oct 2, 2014
Latest reply on Oct 9, 2014 by Montassar BEN ROMDHANE
Hello,

I am trying to initiate a RS485 communication with the STM32F0308DISCOVERY kit. My code is based on the "UART_TwoBoards_ComIT" example that I found in the STM32Cube repository (\STM32Cube\Repository\STM32Cube_FW_F0_V1.0.0\Projects\STM32F072B-Discovery\Examples\UART\UART_TwoBoards_ComIT). In this code, I added the following block after UART initialization block to use the DE pin (PA12):

1.if(HAL_RS485Ex_Init(&UartHandle, UART_DE_POLARITY_LOW, 0, 0) != HAL_OK)
2.  {
3.    Error_Handler();
4.  }

I didn’t connected the STM32F0308DISCOVERY kit to another STM32F0308DISCOVERY kit but I connected it to a computer through a RS485 transceiver and then to a RS485 to USB adapter. On the computer, I have a terminal that is supposed to send an echo.
When I press the "USER" button, The terminal displays “****UART_TwoBoards_ComIT****  ****UART_TwoBoards_ComIT****” and send back it to the STM32F0308DISCOVERY kit.
This echo is never received by the MCU because the program is stuck at the following line:

1./*##-5- Wait for the end of the transfer ###################################*/  
2.while (UartReady != SET)
3.{
4.}

When I put a scope on the PA12 pin, the line is still high but it should be low to make the RS485 transceiver connect the RS485 line to the RX pin of the MCU.

I thought that the DE line was automatically toggled when using the “HAL_UART_Transmit_IT” or the “HAL_UART_Receive_IT” function. Is it true? Am I supposed to use another function to toggle this pin before reading or writing?

Outcomes