Implementation of Flow Control in STM32F427VI
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.