Adaptive baud rate data receiving method, sending method, device, equipment and medium
By encoding and decoding the first byte of the data frame and determining the baud rate in conjunction with the sampling clock frequency, the problem of baud rate being limited to classical values in serial communication is solved, achieving adaptive baud rate and improving the system's flexibility and reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CRM ICBG (WUXI) CO LTD
- Filing Date
- 2024-12-27
- Publication Date
- 2026-06-30
AI Technical Summary
In existing serial communication, the baud rate is limited to a few classic values, and the process of changing them is cumbersome, resulting in low system flexibility and reliability.
An adaptive baud rate method is adopted, which encodes the first byte of the data frame, decodes it according to the encoding and decoding rules, and determines the baud rate in combination with the sampling clock frequency, so as to realize the adaptive baud rate of the data frame without resetting the classic value.
It improves the system's flexibility and reliability, reduces the complexity of changing baud rates, and enhances the accuracy and efficiency of data transmission.
Smart Images

Figure CN122316539A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of adaptive baud rate determination technology, and in particular to an adaptive baud rate data receiving method, transmitting method, apparatus, device, and medium. Background Technology
[0002] In existing serial communication technologies, the host sends specific configuration data, typically characterized by 0x55 or 0xaa, because its waveform is a square wave, making it simpler for the receiving end to count each bit and calculate the baud rate. The slave device calculates the corresponding baud rate information based on the width of the received characteristic data and its own sampling clock frequency, and then receives frame information on the bus according to the calculated baud rate information. If the configuration data is changed, the data frame timing needs to be re-analyzed and the baud rate recalculated, a cumbersome process.
[0003] However, baud rates are limited to a few classic values, and changing them is cumbersome. Summary of the Invention
[0004] This application provides an improved adaptive baud rate data receiving method, transmitting method, apparatus, device, and medium.
[0005] This application provides an adaptive baud rate data receiving method, applied at a receiving end, the adaptive baud rate data receiving method comprising:
[0006] The encoded data frame sent by the sending end is received; the first byte of the encoded data frame is encoded, and the first byte has data content;
[0007] After detecting the communication start signal of the encoded data frame, the encoded data frame is sampled using a sampling clock;
[0008] According to the encoding and decoding rules, the sampled encoded data frame is decoded to obtain the first byte after decoding;
[0009] Based on the decoded first byte and the frequency of the sampling clock, the baud rate of the first byte is determined and used as the baud rate of the decoded data frame; and,
[0010] According to the baud rate, the remaining bytes of the decoded data frame on the bus are received.
[0011] Furthermore, the sampling clock is determined in the following manner:
[0012] The sampling clock is obtained based on the maximum baud rate obtained from Nyquist sampling and the minimum pulse width of the encoded feature bytes.
[0013] Furthermore, the step of decoding the sampled encoded data frame according to the encoding / decoding rules to obtain the decoded first byte includes:
[0014] After detecting the communication start signal of the encoded data frame, the length of the start bit is determined to be a reference length of 1 bit;
[0015] According to the encoding and decoding rules, when the length of the high and low levels of a single bit does not exceed the reference length, and the length of the high level is less than the length of the low level, the bits of the first byte are identified as the first binary value, and...
[0016] When the length of the high level is greater than the length of the low level, the bits of the first byte are identified as the second binary value, and the decoded first byte is obtained.
[0017] Furthermore, after decoding the sampled encoded data frame according to the encoding / decoding rules, the method further includes:
[0018] After detecting the communication start signal of the encoded data frame, the length of the start bit is determined to be a reference length of 1 bit;
[0019] If the length of a single bit of high or low level exceeds the reference length, an error signal is sent to the transmitting end to reset and initialize the transmitting and receiving ends, and then the execution of the received encoded data frame sent by the transmitting end continues.
[0020] This application provides an adaptive baud rate data receiving device, applied at a receiving end, for implementing the adaptive baud rate data receiving method described above. The adaptive baud rate data receiving device includes:
[0021] A data frame receiving module is used to receive an encoded data frame sent by a sending end; the first byte of the encoded data frame is encoded, and the first byte has data content;
[0022] The sampling module is used to sample the encoded data frame using a sampling clock after detecting the communication start signal of the encoded data frame;
[0023] The decoding module is used to decode the sampled encoded data frame according to the encoding and decoding rules to obtain the decoded first byte;
[0024] A baud rate determination module is used to determine the baud rate of the first byte based on the decoded first byte and the frequency of the sampling clock, as the baud rate of the decoded data frame; and,
[0025] A baud rate adaptive receiving module is used to receive the remaining bytes of the decoded data frame on the bus according to the baud rate.
[0026] This application provides an adaptive baud rate data transmission method, applied at a transmitting end, the adaptive baud rate data transmission method comprising:
[0027] According to the encoding and decoding rules, the first byte of the data frame is encoded to obtain the encoded data frame; the encoded data frame contains the remaining bytes except for the first byte, and the first byte has data content;
[0028] The encoded data frame is sent to the receiving end so that the receiving end receives the encoded data frame sent by the sending end; the first byte of the encoded data frame is encoded and has data content; after detecting the communication start signal of the encoded data frame, the encoded data frame is sampled using a sampling clock; the sampled encoded data frame is decoded according to the encoding and decoding rules to obtain the decoded first byte; the baud rate of the first byte is determined according to the frequency of the decoded first byte and the sampling clock, and is used as the baud rate of the decoded data frame; and the remaining bytes of the decoded data frame on the bus are received according to the baud rate.
[0029] Furthermore, the process of encoding the first byte of the data frame according to the encoding / decoding rules to obtain the encoded data frame includes:
[0030] After detecting the communication start signal of the encoded data frame, the duration of the start bit level is determined to be a reference time of 1 bit.
[0031] According to the encoding and decoding rules, if the duration of the high and low levels of a single bit does not exceed the reference time, and the duration of the high level is less than the duration of the low level, it is identified as the first binary value.
[0032] When the duration of the high level is greater than the duration of the low level, it is identified as the second binary value, and the encoded data frame is obtained.
[0033] This application provides an adaptive baud rate data transmission device, applied at a transmitting end, for implementing the adaptive baud rate data transmission method described above. The adaptive baud rate data transmission device includes:
[0034] The encoding module is used to encode the first byte of a data frame according to encoding and decoding rules to obtain an encoded data frame; the encoded data frame contains the remaining bytes except for the first byte, and the first byte has data content;
[0035] A transmitting module is configured to transmit the encoded data frame to a receiving end so that the receiving end receives the encoded data frame transmitted by the transmitting end; the first byte of the encoded data frame is encoded, and the first byte has data content; after detecting the communication start signal of the encoded data frame, the encoded data frame is sampled using a sampling clock; the sampled encoded data frame is decoded according to the encoding and decoding rules to obtain the decoded first byte; the baud rate of the first byte is determined according to the frequency of the decoded first byte and the sampling clock, which is used as the baud rate of the decoded data frame; and the remaining bytes of the decoded data frame on the bus are received according to the baud rate.
[0036] This application provides an electronic device including one or more processors for implementing the method described in any of the preceding claims.
[0037] This application provides a computer-readable storage medium having a program stored thereon that, when executed by a processor, implements the method described in any of the preceding claims.
[0038] This application provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the method described in any of the preceding claims.
[0039] In some embodiments, the adaptive baud rate data receiving method of this application encodes the first byte of the data frame; decodes the sampled encoded data frame according to the encoding and decoding rules to obtain the decoded first byte; and determines the baud rate of the first byte as the baud rate of the decoded data frame based on the decoded first byte and the frequency of the sampling clock. Thus, the baud rate is not limited to a few classic values, and encoding can be achieved using only the first byte of the data content of the data frame itself. There is no need to specially set specific classic values, nor is it necessary to change classic values; therefore, there is no replacement process or cumbersome replacement involved.
[0040] In addition, the adaptive baud rate data transmission method of this application reduces sampling error by encoding the first byte of the data frame as a synchronization byte, eliminates the need for pre-agreed feature values, and improves system flexibility. Attached Figure Description
[0041] Figure 1 This is a schematic diagram of the serial communication baud rate adaptive system in the adaptive baud rate data receiving method of this application embodiment;
[0042] Figure 2 The diagram shown is a flowchart illustrating the adaptive baud rate data receiving method according to an embodiment of this application.
[0043] Figure 3 As shown Figure 2 The diagram shows the sampling clock flow of the adaptive baud rate data reception method.
[0044] Figure 4 As shown Figure 2 The diagram shows the decoding process of serial communication in the adaptive baud rate data reception method.
[0045] Figure 5 The diagram shown is a structural schematic of the adaptive baud rate data receiving device provided in an embodiment of this application;
[0046] Figure 6 The diagram shown is a flowchart illustrating the adaptive baud rate data transmission method according to an embodiment of this application.
[0047] Figure 7 As shown Figure 2 The diagram shows a bus idle level that is high in the encoding timing diagram of the adaptive baud rate data receiving method.
[0048] Figure 8 As shown Figure 2 The diagram shows a bus idle level being low in the encoding timing diagram of the adaptive baud rate data reception method.
[0049] Figure 9 The diagram shown is a flowchart illustrating the specific application of adaptive baud rate in an embodiment of this application.
[0050] Figure 10 The diagram shown is a structural schematic of an adaptive baud rate data transmission device according to an embodiment of this application;
[0051] Figure 11 The diagram shown is a structural schematic of an electronic device provided in an embodiment of this application. Detailed Implementation
[0052] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0053] It should be noted that the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification in other embodiments. In some other embodiments, the methods may include more or fewer steps than described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; and multiple steps described in this specification may be combined into a single step in other embodiments.
[0054] To address the technical problem of baud rates being limited to a few classic values and the cumbersome process of changing them, this application provides an adaptive baud rate data reception method. The method encodes the first byte of a data frame; according to encoding / decoding rules, it decodes the sampled encoded data frame to obtain the decoded first byte; and based on the decoded first byte and the sampling clock frequency, determines the baud rate of the first byte as the baud rate of the decoded data frame. Thus, the baud rate is not limited to a few classic values, and encoding can be achieved using only the first byte of the data content of the data frame itself. There is no need to specially set or change any classic values, and therefore, there is no cumbersome change process.
[0055] Figure 1 This is a schematic diagram of the serial communication baud rate adaptive system in the adaptive baud rate data receiving method of this application embodiment.
[0056] like Figure 1 As shown, the receiving end in this paper can be called the slave end. The transmitting end in this paper can be called the master end. In serial communication, the transmitting end does not need to synchronize its clock with the receiving end, but the signals in the data frame sent by the transmitting end need to indicate the start bit and the end bit.
[0057] The host machine encodes the first byte of each data frame sent each time according to the encoding and decoding rules to obtain the encoded data frame, and sends the encoded data frame to the slave machine. The first byte of the data frame is always encoded.
[0058] First, the slave device can generate its own sampling clock. Second, the slave device performs two-stage synchronization: synchronizing the received encoded data frames in two stages to avoid metastability. Third, the slave device uses edge detection as a communication start signal, tracking the length of the clock's level change. Fourth, the slave device decodes the first byte of the encoded data according to the encoding / decoding rules. Fifth, the slave device calculates the baud rate: based on the feature byte length and the sampling clock frequency, it calculates the baud rate of the first byte, which becomes the baud rate of the decoded data frame, and uses this baud rate to receive the remaining bytes of the decoded data frame on the bus.
[0059] This includes edge detection at the receiver end, such as detecting the falling (rising) edge as a communication start signal. The following sections will provide a detailed introduction from both the receiver and transmitter perspectives.
[0060] Figure 2 The diagram shown is a flowchart of an adaptive baud rate data receiving method according to an embodiment of this application.
[0061] like Figure 2 The first aspect shown describes the adaptive baud rate data reception method applied at the receiving end. This adaptive baud rate data reception method may include, but is not limited to, steps 110 to 150:
[0062] Step 110: Receive the encoded data frame sent by the sending end; the first byte in the encoded data frame is encoded, and the first byte has data content.
[0063] The encoded data described above may include, but is not limited to, multiple data frames. These data frames include a first byte and the remaining bytes except for the start bit. The data frame format may include, but is not limited to, a start bit, a first byte, an address byte, a data byte, a parity bit, and a stop bit.
[0064] The first byte being encoded (called the synchronization byte) is 8 bits of encoded data used to synchronize the baud rate, so as to achieve synchronization between the data frame received by the receiving end and the data frame sent by the sending end, so as to determine whether the signal in the data frame sent by the sending end needs to indicate the start bit, thereby collecting data in a timely manner and avoiding omissions.
[0065] Next, the first byte in each of the above data frames can contain the data content of the data frame itself, and does not need to be the content of a special classic value.
[0066] In this paper, when the sending end sends the next data frame, the first byte of the next data frame is encoded before the sending end sends it again. Correspondingly, in step 110, the receiving end receives the encoded next data frame and adaptively calculates the baud rate. In this way, the first byte of the data frame is encoded each time a data frame is sent, without needing to change several fixed classical values, thus avoiding the tedious operation of the replacement process.
[0067] Step 120: After detecting the communication start signal of the encoded data frame, the encoded data frame is sampled using a sampling clock.
[0068] The receiving end monitors changes in the voltage level on the data line and uses these changes to determine the signal to begin receiving encoded data frames. A voltage level change indicates the detection of the communication start signal for the encoded data frame.
[0069] First, the transmission time of the varying levels is counted using a sampling clock to determine the transmission time of 1 bit. Second, the baud rate of the first byte is obtained based on the transmission time. Third, using the baud rate of the first byte, the received signal containing the remaining data frames is sampled to receive frame information from the bus for data transmission.
[0070] Step 130: According to the encoding and decoding rules, the sampled encoded data frame is decoded to obtain the first byte after decoding.
[0071] The encoding and decoding rules described in this paper are used to encode and decode the first byte of a data frame. These rules are categorized according to the transmission medium and may include, but are not limited to, one or more of binary encoding, Manchester encoding, and differential Manchester encoding.
[0072] Step 140: Based on the decoded first byte and the sampling clock frequency, determine the baud rate of the first byte, which will be used as the baud rate of the decoded data frame. And,
[0073] Step 150: Receive the remaining bytes of the decoded data frame on the bus according to the baud rate.
[0074] In this embodiment, the first byte of the data frame is used as a synchronization byte. In this way, each frame of data can adapt to the baud rate without the need for power-on reset, thus improving system reliability.
[0075] Figure 3 As shown Figure 2 The diagram shows the sampling clock flow of the adaptive baud rate data reception method.
[0076] like Figure 2 and Figure 3 As shown, the sampling clock is determined as follows: based on the maximum baud rate obtained from Nyquist sampling and the minimum pulse width of the encoded feature bytes, the sampling clock is obtained.
[0077] According to the Nyquist sampling theorem, the system clock at the receiving end is twice the maximum baud rate. Since the first byte is encoded, it is assumed that the minimum pulse width of the encoded data frame is... The sampling clock can then be 2m times the maximum baud rate, i.e., f clk =2mf max After determining the sampling clock at the receiving end, both the transmitting and receiving ends are reset and initialized. The transmitting end sends data, and the receiving end samples the data using the sampling clock.
[0078] For example, let the length of the first 8-bit byte be cnt, then the theoretical formula for calculating Bps (Baud Rate) is as follows, where fclk This is the sampling clock.
[0079]
[0080] The Nyquist sampling formula is as follows:
[0081] f clk >2f max (2)
[0082] In the formula, f clk f is the sampling clock frequency. max This represents the maximum baud rate. Therefore, the formula for calculating the baud rate based on Nyquist sampling is as follows:
[0083]
[0084] In the formula, R clk f is the sampling rate. clk f is the sampling clock frequency. baud Let f be the baud rate. Therefore, to accurately receive 1 bit, the system clock only needs to be twice the baud rate, i.e., f. clk ≥2f baud (4).
[0085] Since this embodiment encodes the first byte, it is assumed that the minimum pulse width of the encoded feature byte is... Therefore, the sampling clock frequency is designed to be 2m times the maximum baud rate, i.e., f clk =2mf max (5).
[0086] In this embodiment, a suitable sampling clock frequency is designed based on Nyquist sampling, which can not only preserve the complete information of the signal without distortion, but also reduce useless sampling and decision-making, thereby reducing system power consumption.
[0087] Figure 4 As shown Figure 2 The diagram shows the serial communication decoding process in the adaptive baud rate data reception method.
[0088] like Figure 4 As shown, a clock counting module is used to count the high and low levels after the stop bit, and then decodes them according to the encoding and decoding rules. A detailed explanation follows.
[0089] Step 130 above may further include, but is not limited to, steps (1) to (2):
[0090] (1) After detecting the communication start signal of the encoded data frame, determine the length of the start bit as a reference length of 1 bit.
[0091] (2) According to the encoding and decoding rules, when the length of the high and low levels of a bit does not exceed the reference length, when the length of the high level is less than the length of the low level, the bit of the first byte is identified as the first binary value, and when the length of the high level is greater than the length of the low level, the bit of the first byte is identified as the second binary value, thus obtaining the first byte after decoding.
[0092] The first and second binary values mentioned above can be set according to user needs, and can be two different binary values.
[0093] In this embodiment of the application, when the length of the high and low levels of one bit does not exceed the reference length, the decoding method for the first byte is simple, which is beneficial for fast and accurate decoding.
[0094] After step 130 above, the method further includes step (3): after decoding the sampled encoded data frame according to the encoding and decoding rules, after detecting the communication start signal of the encoded data frame, the length of the start bit is determined to be a reference length of 1 bit. If the length of the high and low levels of 1 bit exceeds the reference length, an error signal is sent to the sending end to reset and initialize the sending end and the receiving end, and the sending end resends the first byte and returns to continue executing the received encoded data frame sent by the sending end.
[0095] In this embodiment, if the length of a single bit's high / low level exceeds the reference length, an error signal is sent to the transmitting end, thus adding a verification mechanism. This improves the effectiveness and accuracy of decoding. Furthermore, upon receiving the first byte, the duration of its high / low levels is monitored for abnormalities to determine if the encoded first byte has been correctly transmitted. Simultaneously, the first byte serves as a synchronization byte; the host encodes the transmitted first byte, determining bit1 and bit0 based on the duty cycle of its high / low levels.
[0096] Continue as Figure 4 As shown, the function determines whether the bus idle level is high or low. When the bus idle level is high, the edge detection circuit at the receiving end detects the falling edge pulse as a communication start signal, counts the low levels until a high level appears, and records the length of this low level as a 1-bit start bit.
[0097] When the bus idle level is low, the edge detection circuit at the receiving end detects the rising edge pulse as the communication start signal, counts the high level until a low level appears, and records the length of the high level as 1 bit (bit) start bit.
[0098] The length of the high (low) level after the start bit is counted. It is then determined whether the high (low) level length is less than or equal to 1 bit. If yes, the receiver sends an error signal, both the transmitter and receiver reset, and the transmitter retransmits the first byte. If no, the high (low) level length is less than 1 bit, the length of the high level is then determined whether it is greater than the length of the low level. If no, the high level length is less than the low level length, and that bit is identified as "0". If yes, the high level length is greater than the low level length, and that bit is identified as "1".
[0099] Secondly, based on the same concept as the above-described method, this application also provides an adaptive baud rate data receiving device, such as... Figure 5 As shown, this adaptive baud rate data receiving device is applied at the receiving end to implement the adaptive baud rate data receiving method described above, and may include the following modules:
[0100] like Figure 5 As shown, the data frame receiving module 31 is used to receive the encoded data frame sent by the sending end; the first byte in the encoded data frame is encoded, and the first byte has data content;
[0101] The sampling module 32 is used to sample the encoded data frame using a sampling clock after detecting the communication start signal of the encoded data frame;
[0102] The decoding module 33 is used to decode the sampled encoded data frame according to the encoding and decoding rules to obtain the decoded first byte;
[0103] The baud rate determination module 34 is used to determine the baud rate of the first byte based on the decoded first byte and the frequency of the sampling clock, as the baud rate of the decoded data frame; and,
[0104] The baud rate adaptive receiving module 35 is used to receive the remaining bytes of the decoded data frame on the bus according to the baud rate.
[0105] As one embodiment, the adaptive baud rate data receiving device may further include a sampling clock generation module:
[0106] The sampling clock generation module is used to obtain the sampling clock based on the maximum baud rate obtained from Nyquist sampling and the minimum pulse width of the encoded feature bytes.
[0107] Thirdly, Figure 6The diagram shown is a flowchart illustrating the adaptive baud rate data transmission method according to an embodiment of this application.
[0108] like Figure 6 As shown, this adaptive baud rate data transmission method is applied at the transmitting end, and the adaptive baud rate data transmission method may include, but is not limited to, the following steps 210 to 220:
[0109] Step 210: According to the encoding and decoding rules, the first byte of the data frame is encoded to obtain the encoded data frame; the encoded data frame contains the remaining bytes except for the first byte, and the first byte has data content.
[0110] When using binary encoding rules, as long as the lengths of the high and low levels are different, different binary values can be decoded.
[0111] For example, at the transmitting end, assume that the data duration of 1 bit is an even multiple of time T, such as 4T. Correspondingly, the high and low levels can be 1:3 of 3T, thus decoding different binary values.
[0112] For example, at the transmitting end, suppose the data duration of 1 bit is an odd multiple of time T, such as 3T. Correspondingly, the high and low levels can be 1:2 of 3T, thus decoding different binary values. See below for a detailed explanation.
[0113] Step 220: Send an encoded data frame to the receiving end so that the receiving end can receive the encoded data frame sent by the sending end; the first byte of the encoded data frame is encoded and has data content; after detecting the communication start signal of the encoded data frame, the encoded data frame is sampled using a sampling clock; according to the encoding and decoding rules, the sampled encoded data frame is decoded to obtain the decoded first byte; the baud rate of the first byte is determined according to the decoded first byte and the frequency of the sampling clock, which is used as the baud rate of the decoded data frame; and, according to the baud rate, the remaining bytes of the decoded data frame on the bus are received.
[0114] In this embodiment of the application, by encoding the first byte of the data frame as a synchronization byte, sampling errors can be reduced, feature values do not need to be agreed upon in advance, and system flexibility is improved.
[0115] Continue as Figure 6 As shown, step 210 above may include the following steps:
[0116] After detecting the communication start signal of the encoded data frame, the duration of the start bit level is determined to be a reference time of 1 bit.
[0117] According to the encoding and decoding rules, if the duration of the high and low levels of a single bit does not exceed the reference time, when the duration of the high level is less than the duration of the low level, it is identified as a first binary value, and when the duration of the high level is greater than the duration of the low level, it is identified as a second binary value, thus obtaining the encoded data frame.
[0118] According to the encoding and decoding rules, the duration of the high and low levels of a single bit must not exceed the reference time. Therefore, during decoding, if the length of a single bit exceeds the reference length, it is considered an error, and an error signal is sent to the transmitting end.
[0119] In this embodiment, duration and binary value are used for encoding, which is simple and convenient for fast encoding.
[0120] Figure 7 As shown Figure 2 The diagram shows a bus idle level that is high in the encoding timing diagram of the adaptive baud rate data receiving method. Figure 8 As shown Figure 2 The diagram shows a bus idle level that is low in the encoding timing diagram of the adaptive baud rate data reception method.
[0121] continue Figure 7 The indicated bus idle level is high, and communication begins upon detection of a falling edge pulse. Assuming a 1-bit data duration is 3T, sending a high level for 1T followed by a low level for 2T represents logic "0", and sending a high level for 2T followed by a low level for 1T represents logic "1". This aligns better with users' conventional definitions of high and low levels, making it more intuitive and convenient. Of course, the encoding rule could also be that sending a high level for 1T followed by a low level for 2T represents logic "1", and sending a high level for 2T followed by a low level for 1T represents logic "0", which will not be elaborated upon here.
[0122] continue Figure 8 The indicated bus idle level is low, and communication begins upon detection of a rising edge pulse. Assuming a 1-bit data duration is 3T, then sending a low level for 2T and a high level for 1T represents logic "0", and sending a low level for 1T and a high level for 2T represents logic "1". This aligns better with users' conventional definitions of high and low levels, making it more intuitive and convenient. Of course, the encoding rule could also be that sending a low level for 2T and a high level for 1T represents logic "1", and sending a low level for 1T and a high level for 2T represents logic "0", which will not be elaborated upon here.
[0123] Figure 9 The diagram shown is a flowchart illustrating the specific application of adaptive baud rate in an embodiment of this application.
[0124] like Figure 9 As shown, firstly, the sampling clock is generated based on the Nyquist sampling theorem and the encoded information of the first byte.
[0125] Second, the host and slave are reset and initialized, and the host sends the encoded data frame.
[0126] Third, determine whether the bus idle level is high.
[0127] Fourth, if so, that is, when the bus idle level is high, then determine whether a falling edge pulse is detected, so that the slave end can detect the falling edge signal by the edge detection circuit as the communication start signal.
[0128] Fifth, count the low levels after the falling edge until a high level appears, and record it as a 1-bit start bit.
[0129] Sixth, if not, that is, if the bus idle level is not high, then determine whether a rising edge pulse has been detected, so that the slave end can detect the rising edge signal by the edge detection circuit as the communication start signal.
[0130] Seventh, if yes, that is, if a rising edge pulse is detected, the slave device counts the high level after the rising edge until a low level is detected, and records it as a 1-bit start bit. If no rising edge pulse is detected, the process returns to step two above.
[0131] Eighth, the first 8-bit byte is following the start bit. The slave clock counting module counts the high (low) levels after the start bit.
[0132] Ninth, the decoding module decodes the data according to the encoding / decoding rules to generate the corresponding data, as follows: Figure 7 and Figure 8 Taking the encoding and decoding rules of the first byte as an example, when the length of the high (low) level is greater than or equal to 1 bit, the slave sends an error signal, the master and slave reset and initialize, and the master resends the first byte. Otherwise, when the length of the high level is less than the length of the low level, the bit is identified as "0", and when the length of the high level is greater than the length of the low level, the bit is identified as "1".
[0133] Accordingly, the system receives the first 8 bits in sequence, calculates the baud rate based on the length of the first byte, and uses this baud rate for communication. It then receives the remaining data of the data frame until a stop bit is detected, at which point communication ends.
[0134] Taking the first byte of the data frame sent by the host as FF as an example, the baud rate adaptive principle of this embodiment of the invention is as follows:
[0135] First, the host processes the first byte FF. Figure 7 and Figure 8 The encoding operation shown is then sent to the slave device, which then uses... Figure 3 The generated clock is sampled, and clock counting is performed after the communication start signal is detected, and based on... Figure 4 The decoding process shown decodes the 8 bits after the start bit, calculates the baud rate based on the length of the first 8-bit byte obtained from the counting, and uses this baud rate for communication.
[0136] Fourthly, based on the same application concept as the above method, embodiments of this application also provide an adaptive baud rate data transmission device, such as... Figure 10 As shown, this adaptive baud rate data transmission device is applied at the transmitting end to implement the above-described adaptive baud rate data transmission method, and may include, but is not limited to, the following modules:
[0137] The encoding module 51 is used to encode the first byte of the data frame according to the encoding and decoding rules to obtain the encoded data frame; the encoded data frame contains the remaining bytes except for the first byte, and the first byte has data content;
[0138] The transmitting module 52 is configured to transmit an encoded data frame to the receiving end so that the receiving end receives the encoded data frame transmitted by the transmitting end; the first byte of the encoded data frame is encoded and has data content; after detecting the communication start signal of the encoded data frame, the encoded data frame is sampled using a sampling clock; the sampled encoded data frame is decoded according to the encoding and decoding rules to obtain the decoded first byte; the baud rate of the first byte is determined according to the frequency of the decoded first byte and the sampling clock, which is used as the baud rate of the decoded data frame; and the remaining bytes of the decoded data frame on the bus are received according to the baud rate.
[0139] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, which can achieve the same technical effect, and will not be repeated here.
[0140] This application provides an electronic device, including the aforementioned adaptive baud rate data transmission device and / or adaptive baud rate data receiving device.
[0141] The method provided in this invention can be applied to electronic devices. Specifically, the electronic device can be a desktop computer, a portable computer, a smart mobile terminal, a server, a PDA (Personal Digital Assistant), or a handheld terminal, etc. The PDA can include industrial PDAs and consumer PDAs. Any electronic device that can implement the embodiments of this invention falls within the protection scope of this invention and is not limited thereto.
[0142] Figure 11 The diagram shown is a structural schematic of the electronic device 70 provided in an embodiment of this application.
[0143] like Figure 11 As shown, the electronic device 70 includes one or more processors 71 for implementing the adaptive baud rate data transmission method and / or adaptive baud rate data reception method as described above.
[0144] In some embodiments, electronic device 70 may include storage medium 79. For example, computer-readable storage medium may store a program that can be invoked by processor 71, and may include non-volatile storage medium. In some embodiments, electronic device 70 may include memory 78 and interface 77. In some embodiments, electronic device 70 may also include other hardware depending on the specific application.
[0145] The computer-readable storage medium of this application embodiment stores a program thereon, which, when executed by processor 71, is used to implement the adaptive baud rate data transmission method and / or adaptive baud rate data reception method as described above.
[0146] This application provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the method described in any of the preceding claims.
[0147] This application also provides a computer program stored in a computer-readable storage medium, for example... Figure 11 The storage medium 79, and when the processor executes the computer program, causes the processor 71 to perform the method described above.
[0148] This application may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing program code. Computer-readable storage media include permanent and non-permanent, removable and non-removable media, and information storage can be implemented using any method or technology. Information may be computer-readable instructions, data structures, program modules, or other data. Examples of computer-readable storage media include, but are not limited to: phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.
[0149] The above description is merely a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of protection of this specification.
[0150] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Without further limitation, an element qualified by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A method of adaptive baud rate data reception, characterized by, The adaptive baud rate data receiving method, applied at the receiving end, includes: The encoded data frame sent by the sending end is received; the first byte of the encoded data frame is encoded, and the first byte has data content; After detecting the communication start signal of the encoded data frame, the encoded data frame is sampled using a sampling clock; According to the encoding and decoding rules, the sampled encoded data frame is decoded to obtain the first byte after decoding; Based on the decoded first byte and the frequency of the sampling clock, the baud rate of the first byte is determined and used as the baud rate of the decoded data frame; and, According to the baud rate, the remaining bytes of the decoded data frame on the bus are received.
2. The adaptive baud rate data receiving method of claim 1, wherein, The sampling clock is determined in the following manner: The sampling clock is obtained based on the maximum baud rate obtained from Nyquist sampling and the minimum pulse width of the encoded feature bytes.
3. The adaptive baud rate data receiving method of claim 1, wherein, The step of decoding the sampled encoded data frame according to the encoding and decoding rules to obtain the decoded first byte includes: After detecting the communication start signal of the encoded data frame, the length of the start bit is determined to be a reference length of 1 bit; According to the encoding and decoding rules, when the length of the high and low levels of a single bit does not exceed the reference length, and the length of the high level is less than the length of the low level, the bits of the first byte are identified as the first binary value, and... When the length of the high level is greater than the length of the low level, the bits of the first byte are identified as the second binary value, and the decoded first byte is obtained.
4. The adaptive-baud-rate data receiving method of claim 1, wherein, After decoding the sampled encoded data frame according to the encoding / decoding rules, the method further includes: After detecting the communication start signal of the encoded data frame, the length of the start bit is determined to be a reference length of 1 bit; If the length of a single bit of high or low level exceeds the reference length, an error signal is sent to the transmitting end to reset and initialize the transmitting and receiving ends, and then the execution of the received encoded data frame sent by the transmitting end continues.
5. A data receiving apparatus of adaptive baud rate, characterized by comprising: Applied at the receiving end, for implementing the adaptive baud rate data receiving method as described in any one of claims 1 to 4, the adaptive baud rate data receiving device includes: A data frame receiving module is used to receive an encoded data frame sent by a sending end; the first byte of the encoded data frame is encoded, and the first byte has data content; The sampling module is used to sample the encoded data frame using a sampling clock after detecting the communication start signal of the encoded data frame; The decoding module is used to decode the sampled encoded data frame according to the encoding and decoding rules to obtain the decoded first byte; A baud rate determination module is used to determine the baud rate of the first byte based on the decoded first byte and the frequency of the sampling clock, as the baud rate of the decoded data frame; and, A baud rate adaptive receiving module is used to receive the remaining bytes of the decoded data frame on the bus according to the baud rate.
6. A data transmission method of adaptive baud rate, characterized by, The adaptive baud rate data transmission method, applied at the transmitting end, includes: According to the encoding and decoding rules, the first byte of the data frame is encoded to obtain the encoded data frame; the encoded data frame contains the remaining bytes except for the first byte, and the first byte has data content; The encoded data frame is sent to the receiving end so that the receiving end receives the encoded data frame sent by the sending end; the first byte of the encoded data frame is encoded and has data content; after detecting the communication start signal of the encoded data frame, the encoded data frame is sampled using a sampling clock; the sampled encoded data frame is decoded according to the encoding and decoding rules to obtain the decoded first byte; the baud rate of the first byte is determined according to the frequency of the decoded first byte and the sampling clock, and is used as the baud rate of the decoded data frame; and the remaining bytes of the decoded data frame on the bus are received according to the baud rate.
7. The adaptive-baud-rate data transmission method of claim 6, wherein, The process of encoding the first byte of a data frame according to encoding / decoding rules to obtain an encoded data frame includes: After detecting the communication start signal of the encoded data frame, the duration of the start bit level is determined to be a reference time of 1 bit. According to the encoding and decoding rules, when the duration of the high and low levels of a single bit does not exceed the reference time, and the duration of the high level is less than the duration of the low level, it is identified as the first binary value. When the duration of the high level is greater than the duration of the low level, it is identified as the second binary value, and the encoded data frame is obtained.
8. A data transmission device with adaptive baud rate, characterized in that, Applied to the transmitting end, for implementing the adaptive baud rate data transmission method as described in any one of claims 6 to 7, the adaptive baud rate data transmission device includes: The encoding module is used to encode the first byte of a data frame according to encoding and decoding rules to obtain an encoded data frame; the encoded data frame contains the remaining bytes except for the first byte, and the first byte has data content; A transmitting module is configured to transmit the encoded data frame to a receiving end so that the receiving end receives the encoded data frame transmitted by the transmitting end; the first byte of the encoded data frame is encoded, and the first byte has data content; after detecting the communication start signal of the encoded data frame, the encoded data frame is sampled using a sampling clock; the sampled encoded data frame is decoded according to the encoding and decoding rules to obtain the decoded first byte; the baud rate of the first byte is determined according to the frequency of the decoded first byte and the sampling clock, which is used as the baud rate of the decoded data frame; and the remaining bytes of the decoded data frame on the bus are received according to the baud rate.
9. An electronic device, comprising: It includes one or more processors for implementing the adaptive baud rate data receiving method as described in any one of claims 1-4 or the adaptive baud rate data transmitting method as described in any one of claims 6-7.
10. A computer-readable storage medium, characterized in that, It stores a program that, when executed by a processor, implements the adaptive baud rate data receiving method as described in any one of claims 1-4 or the adaptive baud rate data sending method as described in any one of claims 6-7.