Neil
To answer the original question:
Flow control on transmission ensures that the transmitter stops if the remote receiver signals that it can not receive any more data. It then continues when the remote receiver signals that it can again accept data.
In the other direction, the receiver signals to the remote transmitter if its input buffer is so full that it shoudl not receive any more data for the time being. Once the receiver buffer has adequate space again it signals that it can receive again.
By enabling USE_XON_OFF when the UART is opened (or configured / re-configured) it will set it to software flow control mode where XOFF (control character 0x13) is used to signal that the transmitter should pause and XON (control character 0x11) that the transmitter may continue again. Both sides must be configured to use XON/XOFF for it to operate correctly. This is not always suitable for connections where binary data is sent where these control characters can occur in the data stream - although many higher level protocols (eg. PPP) allow such control characters to be escaped so that they are avoided. In the uTasker project ensure also that SERIAL_SUPPORT_XON_XOFF is enabled so that the support is really in the code. All uTasker supported devices always support XON/XOFF mode of operation.
By enabling RTS_CTS when the UART is configured, hardware flow control is activated. This works like XON/XOFF but instead of the control signals being escape characters the HW control lines RTS and CTS are used. When a receiver can not receive any more characters is negates its CTS line - this is connected to the transmitters RTS input and this must stop sending when it detectes that the receiver is not ready to receive. Again, both sides must be configured to use the same flow control technique for it to work correctly.
Whether RTS_CTS mode is actually supported depends on the processor. As of writing the M5223X project doesn't contain this support but it will be added in accordance to this description. Watch the thread for more details.
In both cases (SW or HW flow control) there is a question as to when the input buffer becomes critically full, resulting in the flow being quenched. And also when it is adequately empty to allow more data to be received.
There are two methods in the uTasker project:
Enabling SUPPORT_FLOW_HIGH_LOW in config.h allows these levels to be set when configuring the interface. Generally they are set at 20% and 80% of the input buffer size but other values may be more suitable for particular projects. See the demo project (applicatio.c) for an example of configuring the values:
tInterfaceParameters.ucFlowHighWater = temp_pars->temp_parameters.ucFlowHigh;
tInterfaceParameters.ucFlowLowWater = temp_pars->temp_parameters.ucFlowLow;
where the default values are 80 and 20.
If the luxury of SUPPORT_FLOW_HIGH_LOW is not required, the values can alternatively be configured in config.h:
#define HIGH_WATER_MARK 20 // stop flow control when the input buffer has less than this space (if variable settings are required, use SUPPORT_FLOW_HIGH_LOW define)
#define LOW_WATER_MARK 20 // restart when the input buffer content falls below this value
When supported, the RTS input is handled as a interrupt to control the transmitter. In the other direction, the CTS output is automatically controlled by the driver receiver depending on the amount of received data in its input buffer waiting to be read.
Note that if the UART is used in DMA mode XON/XOFF operation will generally not be possible. There are some chips (like the 68302 which has a communications processor built in which does DMA transfers and also checks for flow control characters) but most can not do this and so it will not work. When using DMA mode, RTS/CTS mode of operation is possible. Whether this is implemented depends on the development state. Initially RTS/CTS will be implemented in interrupt driven mode and then RTS/CTS/DMA combinations may be looked at.
Regards
Mark