Method for Adjusting Baud Rate, Electronic Device and Computer Storage Medium
By obtaining the baud rate error between the transmitter and the receiver in asynchronous serial communication, and using the preset compensation parameter table to correct the baud rate, the problem of inaccurate data transmission caused by baud rate error is solved, and the reliability of data transmission is improved.
Patent Information
- Application Number
- CN202110138768.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-01
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2041-02-01
AI Technical Summary
In asynchronous serial communication, the baud rate error between the receiver and the transmitter causes inaccurate data transmission, which may lead to failure of data transmission.
By obtaining the baud rate error between the transmitter and the receiver, a preset compensation parameter table is obtained based on the error, and the baud rate is corrected by using this table to adjust the baud rate.
The adjusted baud rate can reduce the deviation of data sampling points caused by baud rate error, ensure that data transmission meets the requirements of communication protocols, and thus improve the reliability of data transmission.
Smart Images

Figure CN114840464B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technologies, and in particular, to a method for adjusting the baud rate, an electronic device, and a computer storage medium. Background Art
[0002] A Universal Asynchronous Receiver / Transmitter (UART) is a general-purpose synchronous / asynchronous serial transceiver module. Asynchronous serial communication transmits data according to a certain communication protocol and communication rate according to the data format. In asynchronous serial communication, the baud rate is used to describe the data transmission rate.
[0003] In actual work, the environment where the receiving end and the sending end are located and other factors, such as too long transmission distance, clock error, etc., will cause errors in the baud rate of the receiving end and / or the sending end, resulting in the data sent by the sending end not being accurately received at the receiving end and causing data transmission failure. Summary of the Invention
[0004] The main technical problem to be solved by this application is how to improve the reliability of data transmission.
[0005] To solve the above technical problem, a technical solution adopted by this application is: to provide a method for adjusting the baud rate. The method includes: obtaining the error of the baud rate between the sending end and the receiving end; obtaining a preset compensation parameter table based on the error; and using the preset compensation parameter table to correct the baud rate according to each bit to adjust the baud rate.
[0006] To solve the above technical problem, a technical solution adopted by this application is: to provide an electronic device. The electronic device includes a processor and a memory coupled to the processor. When the processor executes the program instructions in the memory, it is used to implement the above method for adjusting the baud rate
[0007] To solve the above technical problem, a technical solution adopted by this application is: to provide a computer storage medium. The computer storage medium stores program instructions, and when the program instructions are executed, the above method for adjusting the baud rate is implemented.
[0008] The beneficial effects of this application are as follows: Different from the prior art, the embodiments of this application obtain the corresponding preset compensation parameter table based on the error of the baud rate, and use the preset compensation parameter table to correct the baud rate bit by bit. Therefore, the baud rate can be adjusted so that data transmission is performed according to the adjusted baud rate, which can reduce the deviation between the actual sampling points and the ideal sampling points of the data at the data sending end and / or the receiving end exceeding the requirements of the communication protocol due to the error of the baud rate, thereby causing the problem of data transmission failure. Therefore, the embodiments of this application can reduce the error of the baud rate so that the deviation between the actual sampling points and the ideal sampling points of the data meets the requirements of the communication protocol, can improve the baud rate accuracy, and thus can increase the reliability of data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings. Among them:
[0010] Figure 1 is a schematic diagram of UART data transmission;
[0011] Figure 2 is a schematic flowchart of an embodiment of the method for adjusting the baud rate in this application;
[0012] Figure 3 is Figure 2 a specific flowchart of step S201 in the embodiment;
[0013] Figure 4 is Figure 2 a specific flowchart of step S202 in the embodiment;
[0014] Figure 5 is Figure 2 a specific flowchart of step S203 in the embodiment;
[0015] Figure 6 is a schematic flowchart of an embodiment of the method for adjusting the baud rate in this application;
[0016] Figure 7 is a schematic flowchart of an embodiment of the method for adjusting the baud rate in this application;
[0017] Figure 8 is a schematic flowchart of the process of generating the first preset compensation table and the second preset compensation table in the method for adjusting the baud rate in this application;
[0018] Figure 9 is a schematic structural diagram of an embodiment of the electronic device in this application;
[0019] Figure 10 It is a schematic structural diagram of an embodiment of the computer storage medium of the present application. Detailed implementation manners
[0020] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0021] The terms "first" and "second" in the present application are only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. In the description of the present application, the meaning of "a plurality" is at least two, such as two, three, etc., unless otherwise specifically defined. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but optionally further includes unlisted steps or units, or optionally further includes other steps or units inherent to these processes, methods, products or devices.
[0022] As Figure 1 shown, the basic protocol of UART is as follows: The transmitter / receiver obtains the value (0 or 1) of each bit by sampling the ideal sampling point (generally the ideal sampling point is the midpoint) of each bit in the data, and so on for other bits, so as to obtain a byte or a frame of data. In actual applications, there will be a certain error in the baud rate, and this error will cause the actual sampling point not to be in the middle of each bit. In order to obtain stable and reliable communication, the protocol requires that the deviation between the actual sampling point of the last bit and the ideal sampling point does not exceed + / -50% (right deviation is defined as + and left deviation is defined as -), that is, the baud rate must reach a certain accuracy; taking the example that each byte or each frame of data includes 10 bits (including start / stop bits), the error of each bit should not exceed 5%. According to the principle of splitting equally between the transmitter / receiver, the baud rate error required for each bit does not exceed 2.5%; the requirement of the protocol for the baud rate accuracy increases with the increase in the number of bits included in each byte or each frame of data.
[0023] To solve the above technical problems, the present application first proposes a method for adjusting the baud rate, as Figure 2 shown, Figure 2 is a schematic flowchart of an embodiment of the method for adjusting the baud rate of the present application. The method for adjusting the baud rate in this embodiment specifically includes the following steps:
[0024] Step S201: Obtain the error of the baud rate between the sending end and the receiving end.
[0025] Asynchronous serial communication transmits data according to the data format, a certain communication protocol, and communication rate. In asynchronous serial communication, the baud rate is usually used to describe the data transmission rate; in asynchronous serial communication, the binary data series appears in the form of digital signal waveforms and is transmitted through the baud rate clock to control the binary data series.
[0026] When sending data, the sending end serially shifts the data in the shift register bit by bit according to the baud rate; when receiving data, the receiving end samples the received data bits according to the baud rate and serially enters them into the shift register bit by bit. It can be seen that the baud rate acts on each bit transmission of the digital waveform. Therefore, the accuracy or error of the baud rate will directly affect the reliability of data transmission.
[0027] To improve the reliability of data transmission, the baud rate of the sending end should be consistent with that of the receiving end, and the baud rate clock of the sending end should be synchronized with the baud rate clock of the receiving end.
[0028] The clock error is the main source of the baud rate error. The higher the accuracy of the clock, the greater the cost of the clock module in the chip (including labor, cost, etc.); and when the receiving end or the sending end does not meet the above accuracy or error requirements, the communication will go wrong.
[0029] It should be noted that in this embodiment, the baud rate error can be obtained.
[0030] Optionally, this embodiment can adopt the method as Figure 3 shown to implement step S201. The method of this embodiment includes steps S301 to S304.
[0031] Step S301: Transmit and receive test data with an oscilloscope.
[0032] Under the assumption of no baud rate error, configure a certain baud rate and transmit, and then receive and measure the pulse width through an oscilloscope or other means.
[0033] Step S302: Calculate the first difference between the total pulse width of the test data and the theoretical pulse width of the total pulse width.
[0034] As can be seen from the above analysis, in asynchronous serial communication, the binary data series appears in the form of digital signal waveforms. Therefore, the test data received by the receiving end is a pulse signal.
[0035] The theoretical pulse width is the pulse width of the test data received by the receiving end when referring to the baud rate (without error).
[0036] As can be seen from the above analysis, the baud rate controls the transmission and reception of data through the rising and falling edges of the pulse signal. The error of the sampling point of the baud rate is actually the difference between the actual pulse width and the theoretical pulse width. Therefore, the difference between the pulse width of the pulse signal of the last bit of the test data and the theoretical pulse width is the sampling error of the last bit (essentially the cumulative sampling error of all bits), that is, the cumulative error of the baud rate.
[0037] Step S303: Obtain the number of bits of the test data, and calculate the ratio of the first difference to the number as the error of the baud rate.
[0038] In this embodiment, by averaging the cumulative error, that is, the sampling error of the last bit, to each bit, the error of the baud rate can be obtained.
[0039] In this embodiment, the error of the baud rate can be obtained by using test data. For example, the sending end sends test data (such as 0x55, 0xAA, 0x5A, 0xA5, etc.). Then, after the receiving end receives the test data, it identifies the total sampling error of multiple bits therein, and then divides the total sampling error by the total number of these multiple bits, thereby obtaining the error of the baud rate; in other embodiments, the baud rate can also be known. For example, the baud rate clock error of the receiving end and / or the sending end can be obtained from the clock module to obtain the baud rate error.
[0040] In another embodiment, the second difference between the single pulse width of the test data and the theoretical pulse width of the single pulse width can also be calculated, and the second difference is used as the error of the baud rate.
[0041] Step S202: Obtain a preset compensation parameter table based on the error.
[0042] Among them, the error includes the error amplitude and the offset direction. The preset compensation parameter table of this embodiment includes a first preset compensation table and a second preset compensation table. The first preset compensation table is used to store the first preset compensation amplitude, and the second preset compensation table is used to store the first preset compensation direction.
[0043] In practical applications, a configuration register A can be added to implement the second preset compensation table. The configuration register A is used to store the first preset compensation direction of each bit; a configuration register B can be added to implement the first preset compensation table. The configuration register B is used to store the first preset compensation amplitude of each bit.
[0044] Optionally, this embodiment can implement step S202 through the method as Figure 4 shown. The method of this embodiment includes step S401 and step S402.
[0045] Step S401: In response to the error margin of the error being within a preset range, obtain a first preset compensation table corresponding to the preset range.
[0046] The storage medium stores multiple groups of register A and register B, multiple preset ranges, and the mapping relationship between register A and register B and the preset ranges.
[0047] When (the controller) determines that the error margin of the baud rate error is within the preset range, obtain the register B corresponding to this preset range.
[0048] Step S402: In response to the offset direction of the error being the preset offset direction, obtain a second preset compensation table corresponding to the preset offset direction.
[0049] When it is determined that the offset direction of the baud rate error is the preset offset direction, obtain the register A corresponding to this preset offset direction.
[0050] Further, determine whether the error margin is greater than or equal to the margin threshold; if the error margin is greater than or equal to the margin threshold, execute step S401; in response to the error margin being less than the margin threshold, it is considered that the error of the current baud rate will not cause data transmission errors, and thus there is no need to correct the error of the current baud rate to improve data transmission efficiency.
[0051] The margin threshold can be 50%, or 40%, etc.; the margin threshold can be reasonably set according to performance such as data transmission reliability and data transmission efficiency.
[0052] In other embodiments, step S402 can be executed first, and then step S401.
[0053] Step S203: Use the preset compensation parameter table to correct the baud rate bit by bit to adjust the baud rate.
[0054] Further, perform data transmission at the adjusted baud rate.
[0055] Different from the prior art, in this embodiment, a corresponding preset compensation parameter table is obtained based on the error of the baud rate, and the preset compensation parameter table is used to correct the baud rate bit by bit. Therefore, the baud rate can be adjusted so that data transmission is performed at the adjusted baud rate, which can reduce the problem that due to the error of the baud rate, the deviation between the actual sampling point and the ideal sampling point of the data at the data sending end / or the receiving end exceeds the requirements of the communication protocol, resulting in data transmission failure. Therefore, this embodiment can reduce the error of the baud rate so that the deviation between the actual sampling point and the ideal sampling point of the data meets the requirements of the communication protocol, can improve the baud rate accuracy, and thus can increase the reliability of data transmission.
[0056] Among them, the first preset compensation table of this embodiment includes a preset serial number and a first preset compensation amplitude corresponding to the preset serial number, and the second preset compensation table includes a preset serial number and a first preset compensation direction corresponding to the preset serial number.
[0057] As can be seen from the above analysis, this embodiment uses register A to implement the second preset compensation table and register B to implement the first preset compensation table. In an application scenario, register A is shown in Tables 1 and 2, and register B is shown in Tables 3 and 4.
[0058] Table 1
[0059]
[0060]
[0061] Table 2
[0062]
[0063] As can be seen from Tables 1 and 2, register A stores the first preset compensation direction of each bit.
[0064] Table 3
[0065]
[0066] Table 4
[0067]
[0068] As can be seen from Tables 3 and 4, register B stores the first preset compensation amplitude of each bit.
[0069] Optionally, this embodiment can implement step S203 through the method shown in Figure 5 . The method of this embodiment includes steps S501 to S503.
[0070] Step S501: Obtain each bit of the data.
[0071] Obtain the first serial number and the preset sampling point (ideal sampling point) of each bit.
[0072] Step S502: In response to the first serial number being the same as the preset serial number, obtain the first preset compensation amplitude from the first preset compensation table and obtain the first preset compensation direction from the second preset compensation table.
[0073] Obtain the first preset compensation amplitude of each bit from configuration register B respectively.
[0074] Among them, in the field of chip design, the first preset compensation amplitude for each bit can be 1 / (2^n) to improve the compensation efficiency. Of course, the first preset compensation amplitude for each bit can be set according to actual applications to ensure that the compensation amplitude for each bit is optimal, so that the sampling error for each bit after compensation is within the range required by the protocol; the size of the first preset compensation amplitude for each bit can be fixed or adjustable.
[0075] Obtain the first preset compensation direction for each bit from register A respectively, where the first preset compensation direction includes a forward shift direction (right adjustment) and a backward shift direction (left adjustment).
[0076] Step S503: Adjust the preset sampling points of the bits according to each bit by using the first preset compensation direction and the first preset compensation amplitude.
[0077] Among them, the first preset compensation amplitudes of all bits of the data are at least partially different.
[0078] Optionally, this embodiment can implement step S502 through step S61 and step S62.
[0079] Step S61: In response to the first preset compensation direction being the forward shift direction, move the preset sampling point of the bit forward by the first preset compensation amplitude to obtain the actual sampling point.
[0080] Step S62: In response to the first preset compensation direction being the backward shift direction, move the actual sampling point of the bit backward by the first preset compensation amplitude to obtain the actual sampling point.
[0081] Furthermore, the first preset compensation direction can also include a zero offset. In response to the first preset compensation direction being the zero offset (no adjustment), use the preset sampling point of the bit as the actual sampling point, that is, do not compensate this bit.
[0082] In an application scenario, as Figure 6 shown, the data includes 10 bits, and the first preset compensation direction includes: zero offset 0 (indicating no adjustment), forward shift direction +1 (indicating right adjustment), backward shift direction -1 (indicating left adjustment); the error for each bit caused by the baud rate is +4%, and the cumulative error up to the last bit is about 40%, that is, +0.4 bits; under the original baud rate configuration, after measuring the baud rate error through waveform measurement or knowing the baud rate error, set the compensation direction and compensation amplitude of 5% for each bit according to the baud rate error. The actual sampling points of the compensated bits can have a small deviation from the preset sampling points (ideal sampling points). Although there is a deviation, there will be no communication error.
[0083] Specifically, the baud rate error is +4%, the cumulative sampling error of start-bit3 is +20%, and for each of the 4 bits of start-bit2, it is adjusted leftward by -5%, that is, the cumulative adjustment is -20%, so that the cumulative sampling error up to bit 3 is 0%; and so on, the baud rate adjustment as shown in Figure 6 can be achieved.
[0084] In an application scenario, as shown in Figure 7 , the data includes 10 bits, and the first preset compensation direction includes: zero offset 0 (indicating no adjustment), forward shift direction +1 (indicating rightward adjustment), backward shift direction -1 (indicating leftward adjustment); the error of each bit caused by the baud rate is +7%, and the cumulative error up to the last bit is about 70%, that is, +0.7 bits; under the original baud rate configuration, after measuring the baud rate error through the waveform or knowing the baud rate error, the compensation direction and compensation amplitude of 5% for each bit are set according to the baud rate error, and the actual sampling points of the compensated bits can have a small deviation from the preset sampling points (ideal sampling points), and although there is a deviation, there will be no communication error.
[0085] Specifically, the baud rate error is +7%, and for each bit, it is adjusted leftward by -5%, that is, the cumulative adjustment is -50%, so that the cumulative sampling error of the last bit is 20%; which is much less than 50%, and normal communication can be ensured.
[0086] This application can set the compensation amplitude according to the baud rate adjustment accuracy and efficiency. For example, when the error is large, a larger compensation amplitude can be set to improve the adjustment efficiency; and for another example, when the error is small, a smaller compensation amplitude can be set to improve the adjustment accuracy.
[0087] In other embodiments, the baud rate deviation of the sending end can be obtained and corrected at the receiving end; or the baud rate deviation of the receiving end can be obtained and corrected at the sending end.
[0088] This embodiment can adopt the method shown in Figure 8 to generate the first preset compensation table and the second preset compensation table. The method of this embodiment specifically includes the following steps:
[0089] Step S801: Set the preset cumulative error and the total number of bits of the data.
[0090] In an application scenario, the preset cumulative error is set to +40% and the total number of bits of the data is 10 bits.
[0091] Step S802: Divide the preset cumulative error by the total number of bits to obtain the preset error of the baud rate.
[0092] In this application scenario, the calculated preset error of the baud rate is +4%.
[0093] Step S803: Set the second preset compensation amplitude and the second preset compensation direction for each bit of the preset error setting data.
[0094] Set the second preset compensation amplitude for each bit to 5%, and the second preset compensation direction to the backward shift direction (adjust to the left); the second preset compensation amplitude is less than the amplitude threshold to avoid transmission bit errors.
[0095] Further, in response to the cumulative compensation amplitude of the bit being zero, set the second preset compensation amplitude of the bit to zero.
[0096] The sampling point before compensation for each bit has a preset error of +4%. The sampling error of the next bit will accumulate the sampling error of the previous bit. For example, the sampling error of the first bit is +4%, the sampling error of the second bit is +8%, and so on. The sampling error of the fifth bit is +20%; for each bit from the first bit to the fourth bit, adjust -5% to the left, that is, the cumulative adjustment is -20%, so that the cumulative sampling error in the fourth bit is 0%. The second preset compensation amplitude of the fourth bit can be set to zero.
[0097] Step S804: Generate a first preset compensation table using the second sequence number and the second preset compensation amplitude of the bit.
[0098] Store the second sequence number and the second preset compensation amplitude of each bit in the first preset compensation table.
[0099] Step S805: Generate a second preset compensation table using the second sequence number and the second preset compensation direction of the bit.
[0100] Store the second sequence number and the second preset compensation direction of each bit in the second preset compensation table.
[0101] Execute steps S801 to S805 multiple times to obtain multiple groups of first preset compensation parameter tables and second preset compensation parameter tables.
[0102] The present application further proposes an electronic device, such as Figure 9 shown, Figure 9 is a schematic structural diagram of an embodiment of the electronic device of the present application. The electronic device 80 of this embodiment includes a processor 81 and a memory 82 coupled to the processor 81
[0103] The electronic device 80 further includes: an input / output device 83 and a bus 84.
[0104] The processor 81, the memory 82, and the input / output device 83 are respectively connected to the bus 84. The memory 82 stores program data, and the processor 81 is used to execute the program data to implement the method for adjusting the baud rate in the above embodiment.
[0105] In this embodiment, the processor 81 can also be referred to as a CPU (Central Processing Unit). The processor 81 may be an integrated circuit chip with signal processing capabilities. The processor 81 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor 81 can also be any conventional processor, etc.
[0106] Among them, the electronic device 80 in this embodiment can be a communication device such as a UART.
[0107] The present application further provides a computer storage medium, such as Figure 10 as shown Figure 10 is a schematic structural diagram of an embodiment of the computer storage medium of the present application. The computer storage medium 90 stores program instructions 91 thereon. When the program instructions 91 are executed by a processor (not shown in the figure), the method for adjusting the baud rate described above is implemented.
[0108] The computer storage medium 90 in this embodiment can be, but is not limited to, a USB flash drive, an SD card, a PD optical drive, a mobile hard disk, a large-capacity floppy drive, a flash memory, a multimedia memory card, a server, etc.
[0109] Different from the prior art, the method for adjusting the baud rate in the embodiment of the present application includes: obtaining the error of the baud rate between the sending end and the receiving end; obtaining a preset compensation parameter table based on the error; and using the preset compensation parameter table to correct the baud rate according to each bit to adjust the baud rate. In the embodiment of the present application, a corresponding preset compensation parameter table is obtained based on the error of the baud rate, and the preset compensation parameter table is used to correct the baud rate according to each bit. Therefore, the baud rate can be adjusted so that data transmission is performed according to the adjusted baud rate, and the deviation between the actual sampling point and the ideal sampling point of the data at the data sending end and / or receiving end caused by the error of the baud rate exceeding the requirements of the communication protocol, resulting in data transmission failure, can be reduced. Therefore, the embodiment of the present application can reduce the error of the baud rate so that the deviation between the actual sampling point and the ideal sampling point of the data meets the requirements of the communication protocol, thereby improving the reliability of data transmission.
[0110] In addition, when the above functions are implemented in the form of software functions and sold or used as independent products, they can be stored in a storage medium readable by a mobile terminal. That is, the present application also provides a storage device storing program data, and the program data can be executed to implement the methods of the above embodiments. The storage device can be a USB flash drive, an optical disc, a server, etc. That is to say, the present application can be embodied in the form of a software product, which includes several instructions for causing an intelligent terminal to execute all or part of the steps of the methods described in each embodiment.
[0111] In the description of the present application, the descriptions referring to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples", etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0112] In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present application, the meaning of "a plurality" is at least two, such as two, three, etc., unless otherwise specifically defined.
[0113] Any process or method description in the flowchart or described in other ways herein can be understood as representing a module, segment, or part of code including one or more executable instructions for implementing a specific logical function or process. The scope of the preferred embodiments of the present application includes additional implementations, where the functions can be executed in a substantially simultaneous manner or in the reverse order according to the involved functions, rather than in the order shown or discussed, which should be understood by those skilled in the art of the embodiments of the present application.
[0114] The logic and / or steps represented in the flowchart or otherwise described herein can be considered, for example, a definitional sequence of executable instructions for implementing a logical function, which can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device (which can be a personal computer, server, network device, or other system that can fetch and execute instructions from the instruction execution system, apparatus, or device). For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of the computer-readable medium include the following: an electrical connection portion having one or more wirings (electronic device), a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable medium on which the program can be printed, as the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpretation, or otherwise processing it as appropriate, and then storing it in a computer memory.
[0115] The above are only the embodiments of the present application, and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be included in the patent protection scope of the present application by the same token.
Claims
1. A method for adjusting the baud rate, characterized in that, the method includes: obtaining the error of the baud rate between the transmitter and the receiver; obtaining a preset compensation parameter table based on the error; using the preset compensation parameter table to correct the baud rate per bit to adjust the baud rate so that the deviation between the actual sampling point and the preset sampling point of the bit is within a preset range; wherein, the preset sampling point is the middle moment point of the bit; wherein, the step of obtaining the preset compensation parameter table based on the error includes: in response to the error amplitude of the error being within a preset range, obtaining a first preset compensation table corresponding to the preset range; in response to the offset direction of the error being a preset offset direction, obtaining a second preset compensation table corresponding to the preset offset direction; wherein, the first preset compensation table includes a preset serial number and a first preset compensation amplitude corresponding to the preset serial number, and the second preset compensation table includes the preset serial number and a first preset compensation direction corresponding to the preset serial number. The step of using the preset compensation parameter table to correct the baud rate per bit includes: obtaining each bit of the data; in response to the first serial number of the bit being the same as the preset serial number, obtaining the first preset compensation direction from the second preset compensation table and obtaining the first preset compensation amplitude from the first preset compensation table; using the first preset compensation direction and the first preset compensation amplitude to adjust the preset sampling point of the bit per bit.
2. The method according to claim 1, characterized in that, the first preset compensation amplitudes of all the bits of the data are at least partially different.
3. The method according to claim 1, characterized in that, the first preset compensation direction includes a forward shift direction, a backward shift direction, and a zero offset. The step of using the first preset compensation direction and the first preset compensation amplitude to adjust the preset sampling point of the bit per bit includes: in response to the first preset compensation direction being the forward shift direction, moving the preset sampling point of the bit forward by the first preset compensation amplitude to obtain an actual sampling point; in response to the first preset compensation direction being the backward shift direction, moving the preset sampling point of the bit backward by the first preset compensation amplitude to obtain an actual sampling point; the step of using the preset compensation parameter table to correct the baud rate per bit further includes: in response to the first preset compensation direction being the zero offset, using the preset sampling point of the bit as the actual sampling point.
4. The method according to claim 1, characterized in that, the step of obtaining the error of the baud rate between the transmitter and the receiver includes: transmitting and receiving test data by an oscilloscope; calculating a first difference between the total pulse width of the test data and the theoretical pulse width of the total pulse width, or calculating a second difference between the single pulse width of the test data and the theoretical pulse width of the single pulse width; Obtain the number of bits of the test data, and calculate the ratio of the first difference to the number as the error of the baud rate, or use the second difference as the error of the baud rate.
5. The method according to claim 4, wherein, the method further includes: setting a preset cumulative error and the total number of bits of the data; dividing the preset cumulative error by the total number of bits to obtain a preset error of the baud rate; setting a second preset compensation amplitude and a second preset compensation direction for each bit of the data according to the preset error; generating the first preset compensation table by using the second sequence number of the bit and the second preset compensation amplitude; generating the second preset compensation table by using the second sequence number of the bit and the second preset compensation direction.
6. The method according to claim 5, wherein, the second preset compensation amplitude is less than an amplitude threshold, and the method further includes: in response to the cumulative compensation amplitude of the bit being zero, setting the second preset compensation amplitude of the bit to zero.
7. The method according to any one of claims 1 to 6, wherein, the method further includes: in response to the error amplitude being greater than or equal to the amplitude threshold, performing the step of generating a compensation parameter table based on the error.
8. An electronic device, wherein, the electronic device includes a processor and a memory coupled to the processor, and when the processor executes program instructions in the memory, it is used to implement the method for adjusting the baud rate according to any one of claims 1-7.
9. A computer storage medium, wherein, program instructions are stored on the computer storage medium, and when the program instructions are executed, they are used to implement the method for adjusting the baud rate according to any one of claims 1-7.
Citation Information
Patent Citations
Sampling clock synchronizing method and system
CN102932084A