SWCU193A April 2023 – August 2024 CC2340R2 , CC2340R5 , CC2340R5-Q1
Flow control can be accomplished by hardware and the following sections describe the implementation method. Hardware flow control between two devices is accomplished by connecting the RTS (request-to-send) output to the CTS (clear-to-send) input on the receiving device and connecting the RTS output on the receiving device to the CTS input. The RTS output signal is low active, the CTS input expects a low signal on a send request, as shown in Figure 19-3.
The CTS input controls the transmitter, the Device 0 and Device 1 transmitter can only transmit data when their CTS input is asserted low. When RTS flow control is enabled, the RTS output signal indicates the state of the receive FIFO. For example, the CTS of the Device 1 remains asserted low until the preprogrammed RX FIFO level of Device 0 is reached, indicating that the receive FIFO of Device 0 has no space to store additional characters.
The UART:CTL register bits CTSEN and RTSEN specify the flow control mode as shown in the following table.
CTSEN | RTSEN | Description |
1 | 1 | RTS and CTS flow control enabled |
1 | 0 | Only CTS flow control enabled |
0 | 1 | Only RTS flow control enabled |
0 | 0 | RTS and CTS flow control disabled |
When RTSEN is set to 1, the value of the UART:CTL.RTS bit is ignored and the RTS output signal is generated by the hardware trigger levels as described below. When RTSEN bit is cleared, the RTS signal output is controlled by the UART:CTL.RTS bit for SW control.
The RTS flow control logic is linked to the programmable receive FIFO trigger levels. The trigger level can be configured using the UART.IFLS register. When RTS flow control is enabled, the RTS is asserted (low) until the receive FIFO is filled up to the trigger level. When the receive FIFO trigger level is reached, the RTS signal is deasserted (high), indicating that there is no more room to receive any more data. The transmission of data is expected to cease after the current character has been transmitted. The RTS signal is reasserted (low) when data has been read out of the receive FIFO so that the FIFO is filled to less than the trigger level. If RTS flow control is disabled and the UART is still enabled, then data is received until the receive FIFO is full, or no more data is transmitted.
The RTS signal is deasserted when the FIFO trigger level is reached by putting the last received character into the FIFO. This means that on a back-to-back transmit, another character transfer can already be started by the sender prior to the RTS signal being deasserted. In such cases, the trigger level needs to be set to one level lower so that all data can be received and added into the FIFO.
If CTS flow control is enabled, then the transmitter checks the CTS signal before transmitting the next byte. If the CTS signal is asserted (low), it transmits the byte otherwise transmission does not occur. The data continues to be transmitted while CTS is asserted (low), and the transmit FIFO is not empty. If the transmit FIFO is empty and the CTS signal is asserted (low) no data is transmitted. If the CTS signal is deasserted (high) and CTS flow control is enabled, then the current character transmission is completed before stopping. If CTS flow control is disabled and the UART is enabled, then the data continues to be transmitted until the transmit FIFO is empty.
Software flow control between two devices is accomplished by using interrupts to indicate the status of the UART. Interrupts can be generated for the CTS signal by setting the UART.IMSC[1] CTSMIM bit. The raw and masked interrupt status can be checked using the UART.RIS and UART.MIS registers. These interrupts can be cleared using the UART.ICR register.