Browse over 10,000 Electronics Projects

Automatic baud-rate detection

Automatic baud-rate detection

Automatic baud-rate detection is desirable in many applications. Microchip standard USART module that the company embeds in most of its PIC microcontrollers lends itself to a simple and easily implemented automatic baud-detection scheme.
Figure represents a general-case signal typically seen on the RX pin of a PIC microcontroller. The time, p, is the number of instruction cycles from the end of the start bit to the beginning of the stop bit. This definition allows you to relate baud rate, B, to the total time it takes for the RX pin on the microcontroller to see eight bits of data. Eight is a convenient figure for a binary machine. Basically. The term (FOSC/4) is the instruction rate of a PIC microcontroller. The term 8/B is the eight bit-times that the RX pin sees. Relating the two baud-rate equations.


The simplified result leads to a simple equation that you can easily implement on a PIC microcontroller. Count the total numbers of instruction cycles for eight bit-times. Divide the result by 32. (In other words, shift the count right five times.) Add a rounding bit. Then, decrement the value by one. Finally, load the SPBRG register with the result to synchronize the PIC microcontroller to the incoming baud rate. It is important to select the right control signal so that the microcontroller samples the correct number of bits. For this implementation, the signal in Figure 2 is an ideal control signal. You take measurements from the rising edge, and the pulse is symmetric. Figure 3 shows the simplified program flow for the baud-rate detection.

It is useful to know the valid frequency range for a baud rate, SPBRG value, and tolerable error. The following equation defines error as follows:–

Visit Here for more.