20.4.1.4 Auto-Baud Feature
The auto-baud feature allows the receiver to determine the baud rate of
the transmitter and synchronize to it. The transmitter sends a byte value of 0x55 (Sync
byte) to the receiver, and the receiver calculates the average bit time from the falling
edges. The UxBRG register is then written with the corresponding value. Sync byte (0x55)
will not be stored in the Rx buffer. Auto-baud is supported in both Legacy and Fractional
Baud Rate Generation modes (CLKMOD = 1
or 0
). The Sync
byte may be preceded with a Break.
To enable auto-baud, the ABDEN bit (UxCON[6]) is set and the UART will begin to look for a falling edge (Start bit of Sync byte). While the auto-baud sequence is in progress, the UART state machine is held in Idle mode. On the fifth RX pin falling edge, an accumulated BRG counter value totaling the proper BRG period is transferred to the UxBRG register. Once the auto-baud process is complete, the ABDEN bit will be cleared by hardware and the ABDIF flag (UxUIR[6]) is set. If the ABDIE (UxUIR[2]) interrupt enable bit is set, an event interrupt will be generated. See Figure 20-5 for the Auto-Baud Detection sequence.
If the fifth and final falling edge is not detected before the BRG counter rolls over, the ABDOVIF flag (UxSTAT[5]) will set to indicate the condition. The flag cannot be cleared until ABDEN is cleared. If the ABDOVIE bit (UxSTAT[13]) is set, an error interrupt will be generated. For more information on interrupts, see Interrupts.
Auto-baud setup procedure:
- Configure the UART for receive operation as detailed in Asynchronous Receive.
- Set the ABDEN bit. If a Break precedes the Sync byte, also set the WUE (UxCON[12]) bit to configure the UART to perform the auto-baud procedure on the Sync and not the Break. The RXBKIF flag (UxSTAT[2]) will not be set.
- Poll the ABDEN or ABDIF bit to determine when the auto-baud has finished.
Alternatively, if a Break precedes the Sync and it is desired to detect the Break, use the following sequence:
- Configure the UART for receive operation as detailed in Asynchronous Receive.
- Wait for the RXBKIF flag to set (see Break Character Reception for details).
- Immediately set the ABDEN bit.
- Poll the ABDEN or ABDIF bit to determine when the auto-baud has finished.