I have an application that uses the UART_RTOS_Receive() and associated functions. Currently this is implemented in MCUXpresso with FreeRTOS. But now I would like to implement hardware flow control using RTS/CTS.
Is there an API that supports this? If not what would be the "correct" way to manipulate the UART0_MODEM and associated registers?
As a minimum, I need to be able to drive RTS low (seems default is high) to get the transfer kicked off.
Thanks for any pointers, Dave
解決済! 解決策の投稿を見る。
I was unable to find any support APIs (such as HAL_Read_UART_Config()) and ended up inserting the following code:
========================================================
// Taken from fsl_uart.c (around line 315)
// Set tx/rx FIFO watermark
UART0->TWFIFO = 0;
UART0->RWFIFO = 1;
// Enable tx/rx FIFO
UART0->PFIFO |= (UART_PFIFO_TXFE_MASK | UART_PFIFO_RXFE_MASK);
// Flush FIFO
UART0->CFIFO |= (UART_CFIFO_TXFLUSH_MASK | UART_CFIFO_RXFLUSH_MASK);
// Enable receiver RTS(request-to-send) function.
UART0->MODEM |= UART_MODEM_RXRTSE_MASK;
// Enable transmitter CTS(clear-to-send) function.
UART0->MODEM |= UART_MODEM_TXCTSE_MASK;
========================================================
This pulled the control lines to their correct values and the serial link is now operational. In order to "de-initialize" these lines, the last two lines of code become:
UART0->MODEM &= ~UART_MODEM_RXRTSE_MASK;
UART0->MODEM &= ~UART_MODEM_TXCTSE_MASK;
I was unable to find any support APIs (such as HAL_Read_UART_Config()) and ended up inserting the following code:
========================================================
// Taken from fsl_uart.c (around line 315)
// Set tx/rx FIFO watermark
UART0->TWFIFO = 0;
UART0->RWFIFO = 1;
// Enable tx/rx FIFO
UART0->PFIFO |= (UART_PFIFO_TXFE_MASK | UART_PFIFO_RXFE_MASK);
// Flush FIFO
UART0->CFIFO |= (UART_CFIFO_TXFLUSH_MASK | UART_CFIFO_RXFLUSH_MASK);
// Enable receiver RTS(request-to-send) function.
UART0->MODEM |= UART_MODEM_RXRTSE_MASK;
// Enable transmitter CTS(clear-to-send) function.
UART0->MODEM |= UART_MODEM_TXCTSE_MASK;
========================================================
This pulled the control lines to their correct values and the serial link is now operational. In order to "de-initialize" these lines, the last two lines of code become:
UART0->MODEM &= ~UART_MODEM_RXRTSE_MASK;
UART0->MODEM &= ~UART_MODEM_TXCTSE_MASK;
Hi,
I agree with you that there is not hal function to configure the hardware flow control mode, you have to write register yourself.
BR
Xiangjun Rong
Hi,
For hardware flow control, this is the uart signals:
RXD: input data pin
TXD:output data pin
RTS:output request transmit signal
CTS:input clear to send signal.
So if you want to two uart(Uart0 and Uart1) to communicate with hardware flow control, the RTS of Uart0 must be connected to CTS of Uart1, the CTS of Uart0 must be connected to RTS of Uart1.
From software, you just need to enable the flow control by configuring the UARTx_MODEM register.
Hope it can help you
BR
XiangJun Rong