cancel
Showing results for 
Search instead for 
Did you mean: 

Implementation of Flow Control in STM32F427VI

As.51
Associate III

Hello everyone.

I have an issue with the communication between STM32F427VI to Gemalto PLS-W.

The uart that is configured as the following:

void MX_USART3_UART_Init(void)
{
 
  huart3.Instance = USART3;
  huart3.Init.BaudRate = 230400;
  huart3.Init.WordLength = UART_WORDLENGTH_8B;
  huart3.Init.StopBits = UART_STOPBITS_1;
  huart3.Init.Parity = UART_PARITY_NONE;
  huart3.Init.Mode = UART_MODE_TX_RX;
  huart3.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS;
  huart3.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart3) != HAL_OK)
  {
    Error_Handler();
  }
 
}

The communication works okay until I tried to pass an image file from the PLS to STM MCU.

The file is 117,197 bytes and I am passing 128 bytes segments in every loop.

At some points the PLS module freeze or restart.

This is the response from Gemalto:

This problem is known, the hardware flow control on STM is not so good implemented - the RTS pin is triggering in every time when it gets any char on its serial port.

The correct behavior is triggering RTS when the buffer is full. When the module sends a long string, it receives a lot of RTS peaks so the transmission is interrupted all the time.

When the baudrate is high, it is possible that the module hangs and then resets but this situation, of course, is abnormal.

At this moment, we propose the workaround - on the STM side, hardware flow control should be disabled and you must write simple software flow control and control the RTS/CTS lines itself. This solution allows you to bypass the incorrect implementation of HFC through a simple buffer and the control of its overflow.

The minimum baudrate that can I use is 230400. Even tough, I tried with 115200 and the behavior is the same.

Someone did something like this? There is an example for this STM version?

Thank you.

3 REPLIES 3

There's probably no universal solution, as it depends on the definition of "buffer full" - which depends on the particular application.

So, it's upon you, to judge, when does your program need to tell the other party "stop sending data now", and then simply pull the RTS (which is set as GPIO output) inactive (high); and when your program is ready to receive more data, pull RTS active (low).

JW

So as far I understand, I need to cancel the default flow control for PIN CTS RTS and pull them according to my usage. But how can I define a buffer size to reduce the number of pulls in RTS CTS lines. Currently the hardware flowcontrol is pulling the lines too fast and the PLS module restarts.

As.51
Associate III

Any ideas?

Please see this https://community.st.com/s/question/0D50X0000AclTJwSQM/problem-with-uart-rts-handling.

This is exactly the same issue.