2025-08-19 12:03 AM
Hello everyone,
I'm using the USART 1 of the STM32U375-KG. Regarding this I have two questiones:
1.) Can I use UART CTS (clear to send) and DE (driver enable) at the same time? In the device configuration tool I can only select "CTS only" or "Hardware Flow Control (RS485)".
Backgound: I'm implementing a hart driver for the DAC8740H. For the UART control there are two pins "CD" and "RTS". The protocol is half duplex. I'm only allowed to send data, if "CD" is low. Thus this pin works like standard RS232 CTS. The RTS pin enables the TX driver. Thus this pin works like RS485 DE (driver enable).
2.) I'm using the USART 1 with a GPDMA to receive data. It happens that I get a parity error or framing error from time to time (that is correct). In the USART interrupt the Rx transfer and the DMA will be ended. Is there a way to avoid that or do I really have to restart the DMA transfer with "HAL_UART_Receive_DMA(*)"?
Kind regards,
Nico
Code where RX is ended: stm32u3xx_hal_uart.c line 2392ff:
/* If Error is to be considered as blocking :
- Receiver Timeout error in Reception
- Overrun error in Reception
- any error occurs in DMA mode reception
*/
errorcode = huart->ErrorCode;
if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR)) ||
((errorcode & (HAL_UART_ERROR_RTO | HAL_UART_ERROR_ORE)) != 0U))
{
/* Blocking error : transfer is aborted
Set the UART state ready to be able to start again the process,
Disable Rx Interrupts, and disable Rx DMA request, if ongoing */
UART_EndRxTransfer(huart);
#if defined(HAL_DMA_MODULE_ENABLED)
/* Abort the UART DMA Rx channel if enabled */
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
{
/* Disable the UART DMA Rx request if enabled */
ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
/* Abort the UART DMA Rx channel */
if (huart->hdmarx != NULL)
{
/* Set the UART DMA Abort callback :
will lead to call HAL_UART_ErrorCallback() at end of DMA abort procedure */
huart->hdmarx->XferAbortCallback = UART_DMAAbortOnError;
/* Abort DMA RX */
if (HAL_DMA_Abort_IT(huart->hdmarx) != HAL_OK)
{
/* Call Directly huart->hdmarx->XferAbortCallback function in case of error */
huart->hdmarx->XferAbortCallback(huart->hdmarx);
}
}
else
{
/* Call user error callback */
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
/*Call registered error callback*/
huart->ErrorCallback(huart);
#else
/*Call legacy weak error callback*/
HAL_UART_ErrorCallback(huart);
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
2025-08-19 12:35 AM
> Can I use UART CTS (clear to send) and DE (driver enable) at the same time?
Probably yes. Try.
> In the device configuration tool I can only select "CTS only" or "Hardware Flow Control (RS485)".
It may be a limitation of that configuration tool (CubeMX?) and its accompanying "library" (Cube/HAL).
> In the USART interrupt the Rx transfer and the DMA will be ended.
Again, that's a limitation of Cube/HAL. Don't use it, if it does not suit you. It's written to fit a "typical usage" and inevitably can't implement every possible usage cases.
JW