User:Uli/Serial Port Bit Rate Error Testing

This page describes how to use a function generator to check the maximum bit rate deviation a UART serial port can sustain before transmission errors occur.

= Basic concept = Using the most common UART frame format (8N1), a square wave (alternating bits of 0 and 1) is interpreted as a sequence of 0x55 ('U') bytes. If such a signal is fed into the RX pin of a UART, a stream of U's will be received. The bit rate in this case is equivalent to twice the signal frequency in Hz, i.e. a 57600 Hz signal results in a 115200 bps data stream.

Even low-end function generators allow very fine tuning of the signal frequency, and it is possible to check the maximum deviation an UART can tolerate by slowly shifting the frequency up or down and checking at which point the stream of U's is slowed down (due to frame errors detected by the UART hardware) or corrupted.

= Generating the correct signal = Depending on the quality of the signal generator (and the skill of the operator), there may be some non-obvious pitfalls when setting up the output signal.

Waveform
Intuitively, one might be inclined to set the output to "Square Wave". This waveform has a negative voltage component, however, which can cause damage to the UART input. The zero-referenced waveform required is commonly called "CMOS".

Amplitude
There are at least some devices in which the signal amplitude is the peak-to-peak voltage of a signal with both positive and negative components. Counterintuitively, It is therefore necessary to set the amplitude to twice the desired positive-peak voltage (6.6V in case of a 3.3V input) when producing a "CMOS" waveform. It is highly recommended to check the actual behavior of the signal generator used with an oscilloscope, because errors can damage the UART input.

= Performing the test =
 * Set the generator to produce a signal at a frequency of half the bit rate to be tested.
 * Having verified that the produced signal actually looks as desired, connect the output of the signal generator to the UART's RX input.
 * Run the command . A steady stream of 'U' characters should appear.
 * Slowly shift the frequency up. Some corruption will occur at the moment the frequency is changed, but should subside quickly.
 * At some point, the stream of U's will slow down, the serial driver will report frame errors or different characters will be received. Shift the frequency back down until these issues disappear and a steady stream of U's is received again. You have now determined the maximum tolerated baud rate deviation:.
 * Perform the last two steps in reverse to determine the minimum tolerated baud rate deviation.