摘要 |
Disclosed are a self-adaptive baud rate system and method. The method includes: a) receiving first data and second data; b) judging whether or not a falling edge of a start bit in a synchronization code of the first data and second data is detected; c) if the falling edge is not detected, then return to step b); and if the falling edge is detected, then a first counting is started from a rising edge after the start bit based on a reference clock, and stopped at the next falling edge, and a first count value is obtained; and a second counting is started from the falling edge where the first counting was stopped, and stopped at the next rising edge, and a second count value is obtained; and d) acquiring a baud rate according to the relationships among the first count value and the second count value and a first threshold. By way of using a CPLD to detect the baud rate and encoding format of a Modbus data frame remotely according to the present application, there is no need to manually set the baud rate and encoding format locally. The function of remote auto-detection of the baud rate and encoding format can be achieved by the present application, and the materials and assembly costs of the rotary encoder are omitted. |