CN116204479A - Apparatus and method for data transmission - Google Patents

Apparatus and method for data transmission Download PDF

Info

Publication number
CN116204479A
CN116204479A CN202211570515.6A CN202211570515A CN116204479A CN 116204479 A CN116204479 A CN 116204479A CN 202211570515 A CN202211570515 A CN 202211570515A CN 116204479 A CN116204479 A CN 116204479A
Authority
CN
China
Prior art keywords
module
data
wake
receiving
mcu
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211570515.6A
Other languages
Chinese (zh)
Inventor
易成龙
曹杰
何杰
高晗晔
刘乃健
胡万容
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Vango Technologies Inc
Original Assignee
Hangzhou Vango Technologies Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Vango Technologies Inc filed Critical Hangzhou Vango Technologies Inc
Priority to CN202211570515.6A priority Critical patent/CN116204479A/en
Publication of CN116204479A publication Critical patent/CN116204479A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • G06F13/4291Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus using a clocked protocol
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4418Suspend and resume; Hibernate and awake

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Communication Control (AREA)

Abstract

The embodiment of the invention discloses a device and a method for data transmission. The data transmission device comprises: the peripheral bus module is used for carrying out parameter configuration on the UART before the MCU enters a sleep mode; the receiving module is used for receiving data through a preset pin in the UART, judging the received data according to parameter configuration, determining whether to wake up the MCU, generating a first wake-up signal if the judgment result is yes, and sending the first wake-up signal to the MCU; and the sending module is used for receiving the data output by the forwarding module or the peripheral bus module, judging whether to wake up the MCU according to the data, generating a second wake-up signal under the condition that the judgment result is yes, and sending the second wake-up signal to the MCU. According to the scheme provided by the invention, when the MCU is asleep, the UART can realize full duplex communication by depending on a low-frequency clock, supports multiple wake-up types, and meets the technical effect of being applicable to a power system communication diversified scene.

Description

Apparatus and method for data transmission
Technical Field
The present invention relates to the field of communications technology application, and in particular, to a device and a method for data transmission.
Background
In the prior art, when a micro control unit (Microcontroller Unit; abbreviated as MCU) chip is idle, a sleep mode is entered in order to reduce power consumption. When the MCU needs to be used normally, a wake-up signal needs to be generated to wake up the MCU. Under the current technology, the mode of generating the wake-up signal is single, and can not meet various complex requirements in the field of power system communication. In addition, the data frame formats of the different universal asynchronous receiver Transmitter (Universal Asynchronous Receiver/Transmitter, UART) interfaces may be different, and the baud rate may also be different, so that the communication cannot be directly performed, and when the MCU enters the sleep mode, the data cannot be forwarded through the bus.
Aiming at the problem that the communication diversification scene of the power system cannot be met due to single wake-up mode and incompatible communication mode in the prior art, an effective solution is not proposed at present.
Disclosure of Invention
In order to solve the above technical problems, an embodiment of the present invention is expected to provide a device and a method for data transmission, so as to at least solve the problem that in the prior art, due to a single wake-up mode and incompatible communication modes, the communication diversity scenario of the power system cannot be satisfied.
The technical scheme of the invention is realized as follows:
in a first aspect, an embodiment of the present invention provides an apparatus for data transmission, including: the UART device comprises a peripheral bus module, a forwarding module, a self-adaptive baud rate module, a receiving module and a transmitting module, wherein the peripheral bus module is used for carrying out parameter configuration on the UART before the MCU enters a sleep mode; when the MCU enters a sleep mode, the peripheral bus module stops running, the UART runs according to a preset frequency clock, a receiving module is used for receiving data through a preset pin in the UART, judging the received data according to parameter configuration, determining whether to wake up the MCU, generating a first wake-up signal under the condition that the judging result is yes, and sending the first wake-up signal to the MCU; one end of the forwarding module is connected with the output end of the receiving module, the other end of the forwarding module is respectively connected with the input end of the peripheral bus module and the input end of the transmitting module, and the forwarding module is used for determining that data received by the receiving module is transmitted to the peripheral bus module or the transmitting module, and converting the data frame format of the data from the data frame format of the receiving group to the data frame format of the transmitting module according to parameter configuration under the condition that the data frame formats of the receiving module and the transmitting module are different; the transmitting module is used for receiving the data output by the forwarding module or the peripheral bus module, judging whether to wake up the MCU according to the data, generating a second wake-up signal if the judging result is yes, and transmitting the second wake-up signal to the MCU; the self-adaptive baud rate module is respectively connected with the receiving module and the sending module and is used for respectively generating the corresponding baud rates of the receiving module and the sending module so that the receiving module and the sending module execute full duplex communication according to the corresponding baud rates.
Optionally, the receiving module includes: the system comprises a data receiving module, a data receiving processing module, a wake-up signal receiving generating module and a receiving and storing module, wherein the data receiving module is respectively connected with the adaptive baud rate module and the data receiving and processing module, and is used for receiving data through a preset pin in a UART, storing the data into a register, generating a baud rate frequency division coefficient through data frame detection on the data, and sending the baud rate frequency division coefficient to the adaptive baud rate module; the received data processing module is respectively connected with the received wake-up signal generating module and the received storage module and is used for receiving the data received by the data receiving module, decoding and checking the data; the receiving wake-up signal generating module is used for judging whether the data wake-up the MCU according to the decoding result of the data by the receiving data processing module, and generating a first wake-up signal and transmitting the first wake-up signal to the MCU under the condition that the judging result is yes; and the receiving and storing module is used for receiving the data decoded and checked by the received data processing module and storing the decoded and checked data.
Optionally, the sending module includes: the device comprises a transmitting storage module, a transmitting data processing module, a transmitting wake-up signal generating module and a data transmitting module, wherein the transmitting storage module is respectively connected with a forwarding module and a peripheral bus module and is used for receiving data forwarded by the forwarding module or receiving data transmitted by the peripheral bus module before or after the MCU sleeps; one end of the transmission data processing module is connected with the output end of the transmission storage module, and the other end of the transmission data processing module is respectively connected with the data transmission module and the transmission wake-up signal generation module and is used for packaging data in the transmission storage module to obtain a data frame and transmitting the data frame to the data transmission module; the transmission wake-up signal generation module is used for judging whether to wake up the MCU according to the data frame, and generating a second wake-up signal and transmitting the second wake-up signal to the MCU under the condition that the judgment result is yes; and the data transmitting module is used for transmitting the data frames output by the data processing module.
Optionally, the input end of the peripheral bus module is connected with the forwarding module, and the output end of the peripheral bus module is connected with the sending module, so as to send the data forwarded by the forwarding module to the sending module before or after the MCU sleeps; the output end of the peripheral bus module is connected with the adaptive baud rate module and is used for sending the received configuration instruction to the adaptive baud rate module so that the adaptive baud rate module generates the baud rate according to the configuration instruction.
In a second aspect, an embodiment of the present invention provides a method for data transmission, applied to a device for data transmission, where the method includes: when the MCU enters a sleep mode, the peripheral bus module stops running, the UART runs according to a preset frequency clock, and data is received through a preset pin in the UART; selecting a corresponding wake-up mode according to the preset parameter configuration, wherein the wake-up mode comprises: receiving an awake mode or transmitting an awake mode; when the wake-up mode is a receive wake-up mode, generating a first wake-up signal through the receiving module, sending the first wake-up signal to the MCU, waking up the MCU, and sending data to the sending module through the peripheral bus module; or, the data is sent to the sending module through the forwarding module; when the wake-up mode is a transmitting wake-up mode, forwarding data to a transmitting module through a forwarding module, generating a second wake-up signal through preset parameter configuration, transmitting the second wake-up signal to the MCU, waking up the MCU, and transmitting the data through the transmitting module; under the condition of a sleep mode, the data received by the receiving module is forwarded to the sending module through the forwarding module.
Optionally, before the MCU enters the sleep mode, the method further comprises: performing parameter configuration on the UART through the peripheral bus module, wherein the parameter configuration comprises the following steps: data frame format, baud rate, and awake mode.
Optionally, the data frame format includes: a start bit, a data bit, a parity bit, and an end bit, wherein the start bit is fixed to 0; the data bit length is 6-8 bits, the check bit is 1 bit, and the end bit is fixed to be 1.
Further, optionally, the wake-up mode includes: a receive wake mode or a transmit wake mode, wherein the receive wake mode and the transmit wake mode comprise at least one of: the method comprises the steps of waking up a start bit, namely waking up through setting a low level or waking up a falling edge, and generating a first waking up signal or a second waking up signal if the start bit is detected to be low level or the falling edge occurs in the process of receiving or transmitting data; character awakening, wherein when a preset number of characters are received or transmitted, a first awakening signal or a second awakening signal is generated; character matching awakening, and generating a first awakening signal or a second awakening signal when a preset number of characters are received or transmitted and the content of a character sequence is the same as that of the preset character sequence; when the character matching wake-up is a receiving wake-up mode, screening whether the character which is not successfully matched is stored in a receiving storage module or not; the method comprises the steps of threshold value awakening, wherein the threshold value awakening comprises a first threshold value awakening or a second threshold value awakening, wherein the threshold value in the first threshold value awakening is larger than the threshold value in the second threshold value awakening, and when a received or transmitted designated character is larger than the first threshold value awakening or smaller than the second threshold value awakening, a first awakening signal or a second awakening signal is generated; and in the character matching awakening and the threshold awakening, the compared data frame format positions are data bits.
Optionally, forwarding, by the forwarding module, the data received by the receiving module to the sending module includes: under the condition that the data frame formats of the receiving module and the sending module are different, the data frame format of the data is converted from the data frame format of the receiving group to the data frame format of the sending module according to the data frame format set in the parameter configuration.
Optionally, the method further comprises: and according to the baud rate set in the parameter configuration, respectively corresponding baud rates of the receiving module and the sending module, so that the receiving module and the sending module execute full duplex communication according to the corresponding baud rates.
Optionally, the method further comprises: after the MCU wakes up, the frequency of a UART preset frequency clock is adjusted, wherein the frequency of the preset frequency clock is a first frequency, the adjusted frequency is a second frequency, and the second frequency is larger than the first frequency.
The embodiment of the invention provides a device and a method for data transmission. The peripheral bus module is used for carrying out parameter configuration on the UART before the MCU enters a sleep mode; when the MCU enters a sleep mode, the peripheral bus module stops running, the UART runs according to a preset frequency clock, a receiving module is used for receiving data through a preset pin in the UART, judging the received data according to parameter configuration, determining whether to wake up the MCU, generating a first wake-up signal under the condition that the judging result is yes, and sending the first wake-up signal to the MCU; one end of the forwarding module is connected with the output end of the receiving module, the other end of the forwarding module is respectively connected with the input end of the peripheral bus module and the input end of the transmitting module, and the forwarding module is used for determining that data received by the receiving module is transmitted to the peripheral bus module or the transmitting module, and converting the data frame format of the data from the data frame format of the receiving group to the data frame format of the transmitting module according to parameter configuration under the condition that the data frame formats of the receiving module and the transmitting module are different; the transmitting module is used for receiving the data output by the forwarding module or the peripheral bus module, judging whether to wake up the MCU according to the data, generating a second wake-up signal if the judging result is yes, and transmitting the second wake-up signal to the MCU; the self-adaptive baud rate module is respectively connected with the receiving module and the transmitting module and is used for respectively generating the corresponding baud rates of the receiving module and the transmitting module so that the receiving module and the transmitting module execute full-duplex communication according to the corresponding baud rates, and therefore, when the MCU sleeps, the UART can rely on a low-frequency clock to realize full-duplex communication and support multiple awakening types, and the technical effect that the power system communication diversified scene is applicable is met.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiments of the invention and together with the description serve to explain the invention and do not constitute a limitation on the invention. In the drawings:
fig. 1 is a schematic diagram of an apparatus for data transmission according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram illustrating communication between different UART interfaces in a data transmission apparatus according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a data frame format before and after forwarding in a data transmission device according to a first embodiment of the present invention;
fig. 4 is a flow chart of a method for data transmission according to a second embodiment of the present invention;
fig. 5 is a schematic diagram of a communication data frame format adopted in a data transmission method according to a second embodiment of the present invention;
fig. 6 is a flowchart of another data transmission method according to the second embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and in the drawings are used for distinguishing between different objects and not for limiting a particular order.
It should be noted that, the following embodiments of the present invention may be implemented separately or in combination with each other, and the embodiments of the present invention are not limited thereto.
Technical terms related to the embodiments of the present application:
UART: a universal asynchronous receiver Transmitter (Universal Asynchronous Receiver/Transmitter);
MCU: a micro control unit (Micro Controller Unit);
RTC: real Time Clock (Real Time Clock);
LSB: least significant bits (Least Significant Bit);
MSB: a most significant bit (Most Significant Bit);
RAM: a random access memory (Random Access Memory);
FIFO: a first-in first-out data buffer (First In First Out);
DDR: double Data synchronous dynamic random access memory (Double Data Rate).
Example 1
In a first aspect, an embodiment of the present invention provides a data transmission apparatus, and fig. 1 is a schematic diagram of a data transmission apparatus provided in a first embodiment of the present invention; as shown in fig. 1, the apparatus for data transmission provided in the embodiment of the present application includes:
The UART device comprises a peripheral bus module 10, a forwarding module 12, an adaptive baud rate module 14, a receiving module 16 and a transmitting module 18, wherein the peripheral bus module 10 is used for carrying out parameter configuration on the UART before the MCU enters a sleep mode; when the MCU enters a sleep mode, the peripheral bus module 10 stops running, the UART runs according to a preset frequency clock, the receiving module 16 is used for receiving data through a preset pin in the UART, judging the received data according to parameter configuration, determining whether to wake up the MCU, generating a first wake-up signal if the judgment result is yes, and sending the first wake-up signal to the MCU; one end of the forwarding module 12 is connected with the output end of the receiving module 16, the other end of the forwarding module 12 is respectively connected with the input end of the peripheral bus module 10 and the input end of the transmitting module 18, and is used for determining that the data received by the receiving module 16 is transmitted to the peripheral bus module 10 or the transmitting module 18, and converting the data frame format of the data from the data frame format of the receiving group to the data frame format of the transmitting module 18 according to parameter configuration under the condition that the data frame formats of the receiving module 16 and the transmitting module 18 are different; the sending module 18 is configured to receive the data output by the forwarding module 12 or the peripheral bus module 10, determine whether to wake up the MCU according to the data, generate a second wake-up signal if the determination result is yes, and send the second wake-up signal to the MCU; the adaptive baud rate module 14 is connected to the receiving module 16 and the transmitting module 18, respectively, and is configured to generate corresponding baud rates for the receiving module 16 and the transmitting module 18, respectively, so that the receiving module 16 and the transmitting module 18 perform full duplex communication according to the corresponding baud rates.
Optionally, the receiving module 16 includes: the device comprises a data receiving module, a received data processing module, a received wake-up signal generating module and a received storage module, wherein the data receiving module is respectively connected with the adaptive baud rate module 14 and the received data processing module, and is used for receiving data through a preset pin in a UART, storing the data into a register, generating a baud rate frequency division coefficient through data frame detection on the data, and sending the baud rate frequency division coefficient to the adaptive baud rate module 14; the received data processing module is respectively connected with the received wake-up signal generating module and the received storage module and is used for receiving the data received by the data receiving module, decoding and checking the data; the receiving wake-up signal generating module is used for judging whether the data wake-up the MCU according to the decoding result of the data by the receiving data processing module, and generating a first wake-up signal and transmitting the first wake-up signal to the MCU under the condition that the judging result is yes; and the receiving and storing module is used for receiving the data decoded and checked by the received data processing module and storing the decoded and checked data.
Optionally, the sending module 18 includes: the device comprises a transmission storage module, a transmission data processing module, a transmission wake-up signal generation module and a data transmission module, wherein the transmission storage module is respectively connected with a forwarding module 12 and a peripheral bus module 10 and is used for receiving data forwarded by the forwarding module 12 or receiving data transmitted by the peripheral bus module 10 before or after the MCU sleeps; one end of the transmission data processing module is connected with the output end of the transmission storage module, and the other end of the transmission data processing module is respectively connected with the data transmission module and the transmission wake-up signal generation module and is used for packaging data in the transmission storage module to obtain a data frame and transmitting the data frame to the data transmission module; the transmission wake-up signal generation module is used for judging whether to wake up the MCU according to the data frame, and generating a second wake-up signal and transmitting the second wake-up signal to the MCU under the condition that the judgment result is yes; and the data transmitting module is used for transmitting the data frames output by the data processing module.
Optionally, the input end of the peripheral bus module 10 is connected with the forwarding module 12, and the output end of the peripheral bus module 10 is connected with the sending module 18, so as to send the data forwarded by the forwarding module 12 to the sending module 18 before or after the MCU sleeps; the output end of the peripheral bus module 10 is connected to the adaptive baud rate module 14, and is configured to send the received configuration instruction to the adaptive baud rate module 14, so that the adaptive baud rate module 14 generates a baud rate according to the configuration instruction.
In summary, the parameter configuration in the data transmission device provided in the embodiment of the present application includes: data frame format, baud rate, awake mode; before the MCU enters the sleep mode, relevant configurations of the UART with low power consumption, such as data frame format, baud rate, wake-up mode (i.e. parameter configuration in the embodiment of the present application) etc. need to be set through the peripheral bus module 10. When the MCU is asleep, the peripheral bus module 10 stops operating, at which point the UART operates on a low frequency clock (i.e., a preset frequency clock in the embodiments of the present application). The UART then starts full duplex reception of the transmit data and detects whether the wake-up condition is met. When the wake-up condition is satisfied, the UART will generate a wake-up signal, the MCU will enter a normal operation mode, and the peripheral bus module 10 resumes operation. After reconfiguring the relevant configuration of the UART, the MCU may enter the sleep mode again.
Specifically, as shown in fig. 1, in the apparatus for data transmission provided in the embodiment of the present application,
the receiving module 16 includes: the device comprises a data receiving module, a received data processing module, a received wake-up signal generating module and a received storage module; wherein, the liquid crystal display device comprises a liquid crystal display device,
and a data receiving module: one pin (i.e., a preset pin in the UART in the embodiment of the present application) can be selected from a plurality of normal UART pins for data reception and stored into a register. The data frames can also be detected to generate baud rate frequency division coefficients to the adaptive baud rate module 14 to automatically adapt to the communication baud rate.
A received data processing module: when the data receiving module transmits the data to the received data processing module, the data is decoded and checked.
The receiving wake-up signal generating module: when the data processing module decodes the data, if the wake-up condition is met, a wake-up signal (i.e., the first wake-up signal in the embodiment of the application) is generated to the MCU.
And the receiving and storing module is used for: and after the received data processing module decodes and verifies the data, the data is stored in the received storage module.
The transmission module 18 includes: a transmission storage module, a transmission data processing module, a transmission wake-up signal generating module and a data transmission module, wherein,
And the sending storage module is used for: the transmitting storage module can receive the data in the forwarding module 12, and can also receive the data in the peripheral bus module 10 before the MCU sleeps or after waking up.
And the transmission data processing module is used for: when the data is transmitted to the data transmission processing module by the data transmission storage module, the data is encapsulated to form a data frame, and then the data is transmitted to the data transmission module.
A transmission wake-up signal generation module: when the data processing module processes the data, if the wake-up condition is met, a wake-up signal (i.e., a second wake-up signal in the embodiment of the application) is generated to the MCU.
And a data transmitting module: one pin can be selected from a plurality of common UART pins for data transmission.
The receiving storage module and the sending storage module in the embodiment of the present application may include: RAM, FIFO, DDR is described by way of example only, and is not particularly limited.
In addition, the check method that can be used for the check bits in the data frame format in the embodiment of the present application may be parity check, exclusive or check, cyclic redundancy check (Cyclic Redundancy Check, abbreviated as CRC) redundancy check, and the like.
It should be noted that, when the MCU sleeps, the low power UART can support multiple wake-up modes, including N-character reception/transmission wake-up, start bit reception/transmission wake-up, N-character matching reception/transmission wake-up, and threshold reception/transmission wake-up.
Based on the functions of the receiving module 16 and the sending module 18, the mode of waking up the MCU in the data transmission device provided in the embodiment of the present application is specifically as follows:
the wake-up modes can be divided into two main types, namely a reception wake-up mode and a transmission wake-up mode, wherein each type can be divided into four types of wake-up modes. Before the UART goes to sleep, a specific wake-up mode should be set.
The start bit wakes up, and the end bit is fixed to 1 and the start bit is fixed to 0 as known in the data frame format. The wake-up mode can set low level wake-up or falling edge wake-up, namely, when the start bit is detected to be 0 or the falling edge occurs in the process of receiving or transmitting data, a wake-up signal is generated.
The N characters wake up, and when N characters are received or transmitted, a wake-up signal is generated.
N characters are matched and awakened, and when N characters are received or transmitted and the character sequence is the same as the character sequence to be compared, an awakening signal is generated. When the mode is a reception wake-up mode, it may be set whether characters that have not been successfully matched are stored in the reception storage module.
Threshold wake-up is divided into high threshold wake-up and low threshold wake-up, and when a certain character received or transmitted is higher or lower than a threshold, a wake-up signal is generated.
In N character matching awakening and threshold awakening, only data bits are compared, and other bits do not participate in comparison.
When the MCU is asleep, the UART can realize full duplex communication depending on a low-frequency clock, and the data frame format, transmission mode and baud rate of the transmission and the reception can be different. In order to meet various complex demands in the field of power system communication, there are also various ways of generating wake-up sources. For example, when UART is used to receive data of some complex protocols, the following data can be guaranteed to be meaningful only when a correct message header is received, and then an N-character matching wake-up mode can be adopted.
Based on the receiving module 16 and the sending module 18, the apparatus for data transmission provided in the embodiment of the present application further includes:
forwarding module 12: the data in the receiving memory module can be indirectly sent to the sending memory module, and can be sent to the peripheral bus module before the MCU sleeps or after the MCU wakes up, and the forwarding module can determine whether to send the data to the peripheral bus module or the sending memory module. When data flows from the receiving storage module to the transmitting storage module, if the data frame formats of the receiving storage module and the transmitting storage module are different, the forwarding module repackages the data in the receiving storage module according to the format of the transmitting storage module.
Based on the function and connection structure of the forwarding module 12, when the MCU is operating normally, the peripheral bus module 10 can read the data in the receiving memory module and write the data into the transmitting memory module. So that the data received by the UART can now be retransmitted out through the peripheral bus module 10. The data frame format can be modified during forwarding so as to adapt to the data frame formats of different interfaces. The transmission rates of the transmission and the reception may also be different. However, when the MCU enters the sleep mode, the peripheral bus module 10 cannot continue to operate, and the forwarding function cannot be realized at this time.
In the data transmission device provided in this embodiment of the present application, a data path is added between the receiving storage module and the transmitting storage module, where the data path is implemented by the forwarding module 12, and after the MCU enters the sleep mode, the forwarding module 12 may forward the data in the receiving storage module to the transmitting storage module. When data flows from the receiving memory module to the transmitting memory module, if the data frame formats of the two are different, the forwarding module 12 repackages the data in the receiving memory module according to the format of the transmitting memory module. Fig. 2 is a schematic diagram of communication between different UART interfaces in a data transmission apparatus according to an embodiment of the present invention, as shown in fig. 2, when the data frame formats and baud rates of the interfaces UART1 and UART3 are different, the interface UART2 is needed to be used as an intermediary. After the UART2 receives data according to the baud rate of the UART1, it repacks the data according to the data frame format of the UART3, and transmits the data according to the baud rate of the UART 3.
Fig. 3 is a schematic diagram of a data frame format before and after forwarding in a data transmission device according to a first embodiment of the present invention; as shown in fig. 3, the data frame format of UART2 before forwarding is the same as UART1, and is 1-bit start bit, 8-bit data bit, 1-bit check bit, and 1-bit end bit, and the data frame format of UART2 after passing through forwarding module 12 is the same as UART3, and is 2-bit start bit, 6-bit data bit, 1-bit check bit, and 2-bit end bit. When the long data is modified into short data, a cutting-off mode is adopted to cut off the low bits. When short data is modified into long data, a high-order 0-complement mode is adopted. The UART supports LSB and MSB transmission modes, and the receiving and transmitting transmission modes may be different, and when intercepting and supplementing 0, the forwarding module 12 may adjust according to the receiving and transmitting transmission modes. The forwarding module 12 may generate the baud rate according to the received data processing module and the transmitted data processing module respectively because the adaptive baud rate module 14 is capable of generating the baud rate, so the baud rate may be different after the data is forwarded.
It should be noted that, when the MCU sleeps, the low-power UART can forward the received data through the forwarding module, and can modify the format, transmission mode and baud rate of the data frame.
Peripheral bus module 10: before the MCU sleeps or after the MCU wakes, the MCU can receive the data from the forwarding module and can also send the data to the sending storage module. While it can send commands to the adaptive baud rate module to set the baud rate.
In the embodiment of the present application, when the received data is to be sent to the peripheral bus module 10, it is required to go through the forwarding module 12 to the peripheral bus module 10. The peripheral bus module 10 and the adaptive baud rate module 14 have a connection relationship, and belong to the configuration initial baud rate. Adaptive baud rate module 14: in order to achieve full duplex communication, the adaptive baud rate module is capable of generating baud rates for the received data processing module and the transmitted data processing module, respectively.
In the data transmission device provided by the embodiment of the application, the UART with low power consumption can realize UART full duplex communication, and the data frame format, the transmission mode and the baud rate of the transmission and the reception can be different. When the MCU is asleep, the working clock is a low-frequency clock, and when the MCU is awake, the working clock is a peripheral bus (Advanced Peripheral Bus, abbreviated as APB) clock.
The embodiment of the invention provides a device for data transmission. The peripheral bus module is used for carrying out parameter configuration on the UART before the MCU enters a sleep mode; when the MCU enters a sleep mode, the peripheral bus module stops running, the UART runs according to a preset frequency clock, a receiving module is used for receiving data through a preset pin in the UART, judging the received data according to parameter configuration, determining whether to wake up the MCU, generating a first wake-up signal under the condition that the judging result is yes, and sending the first wake-up signal to the MCU; one end of the forwarding module is connected with the output end of the receiving module, the other end of the forwarding module is respectively connected with the input end of the peripheral bus module and the input end of the transmitting module, and the forwarding module is used for determining that data received by the receiving module is transmitted to the peripheral bus module or the transmitting module, and converting the data frame format of the data from the data frame format of the receiving group to the data frame format of the transmitting module according to parameter configuration under the condition that the data frame formats of the receiving module and the transmitting module are different; the transmitting module is used for receiving the data output by the forwarding module or the peripheral bus module, judging whether to wake up the MCU according to the data, generating a second wake-up signal if the judging result is yes, and transmitting the second wake-up signal to the MCU; the self-adaptive baud rate module is respectively connected with the receiving module and the transmitting module and is used for respectively generating the corresponding baud rates of the receiving module and the transmitting module so that the receiving module and the transmitting module execute full-duplex communication according to the corresponding baud rates, and therefore, when the MCU sleeps, the UART can rely on a low-frequency clock to realize full-duplex communication and support multiple awakening types, and the technical effect that the power system communication diversified scene is applicable is met.
Example two
In a second aspect, an embodiment of the present invention provides a method for transmitting data, and fig. 4 is a schematic flow chart of a method for transmitting data provided in a second embodiment of the present invention; as shown in fig. 4, the method for data transmission provided in the embodiment of the present application includes:
step S402, when the MCU enters a sleep mode, the peripheral bus module stops running, the UART runs according to a preset frequency clock, and data is received through a preset pin in the UART;
step S404, selecting a corresponding wake-up mode according to the preset parameter configuration, wherein the wake-up mode comprises: receiving an awake mode or transmitting an awake mode;
step S406, when the wake-up mode is the receive wake-up mode, generating a first wake-up signal by the receive module, sending the first wake-up signal to the MCU, waking up the MCU, and sending data to the send module by the peripheral bus module; or, the data is sent to the sending module through the forwarding module;
when the MCU is awakened, the received data can be sent to the sending module through the forwarding module (without going to the sending module through the peripheral bus module), and the received data can also be sent to the peripheral bus module through the forwarding module (after being awakened, the data can be stored into the register through the bus by adopting the mode, and a user can read the data through the register). Step S408, when the wake-up mode is the transmission wake-up mode, forwarding data to the transmission module through the forwarding module, generating a second wake-up signal through preset parameter configuration, transmitting the second wake-up signal to the MCU, waking up the MCU, and transmitting the data through the transmission module; under the condition of a sleep mode, the data received by the receiving module is forwarded to the sending module through the forwarding module.
Optionally, before the MCU enters the sleep mode in step S402, the method for data transmission provided in the embodiments of the present application further includes: performing parameter configuration on the UART through the peripheral bus module, wherein the parameter configuration comprises the following steps: data frame format, baud rate, and awake mode.
Optionally, the data frame format includes: a start bit, a data bit, a parity bit, and an end bit, wherein the start bit is fixed to 0; the data bit length is 6-8 bits, the check bit is 1 bit, and the end bit is fixed to be 1.
In the method for transmitting data provided in the embodiment of the present application, the UART adopts an asynchronous serial communication mode, and the basic transmission unit is a character. In communication, transmission is performed in a bit-by-bit order, the time interval between every two adjacent bits is fixed, and the interval size can be characterized by the baud rate. Fig. 5 is a schematic diagram of a communication data frame format adopted in a data transmission method according to a second embodiment of the present invention, where, as shown in fig. 5, the data frame format is composed of a start bit, a data bit, a parity bit, and an end bit. Wherein the start bit is fixed to 0, the length is 1-2 bits, the data bit length is 6-8 bits, the check bit is 1 bit, the end bit is fixed to 1, and the length is 1-2 bits.
Further, optionally, the wake-up mode includes: a receive wake mode or a transmit wake mode, wherein the receive wake mode and the transmit wake mode comprise at least one of: the method comprises the steps of waking up a start bit, namely waking up through setting a low level or waking up a falling edge, and generating a first waking up signal or a second waking up signal if the start bit is detected to be low level or the falling edge occurs in the process of receiving or transmitting data; character awakening, wherein when a preset number of characters are received or transmitted, a first awakening signal or a second awakening signal is generated; character matching awakening, and generating a first awakening signal or a second awakening signal when a preset number of characters are received or transmitted and the content of a character sequence is the same as that of the preset character sequence; when the character matching wake-up is a receiving wake-up mode, screening whether the character which is not successfully matched is stored in a receiving storage module or not; the method comprises the steps of threshold value awakening, wherein the threshold value awakening comprises a first threshold value awakening or a second threshold value awakening, wherein the threshold value in the first threshold value awakening is larger than the threshold value in the second threshold value awakening, and when a received or transmitted designated character is larger than the first threshold value awakening or smaller than the second threshold value awakening, a first awakening signal or a second awakening signal is generated; and in the character matching awakening and the threshold awakening, the compared data frame format positions are data bits.
Specifically, the wake-up mode in the embodiment of the present application is specifically as follows:
when the MCU is asleep, the low-power UART can support various wake-up modes, including N character receiving/transmitting wake-up, start bit receiving/transmitting wake-up, N character matching receiving/transmitting wake-up, and threshold receiving/transmitting wake-up.
Based on the functions of the receiving module and the sending module, the mode of waking up the MCU in the data transmission device provided by the embodiment of the application is specifically as follows:
the wake-up modes can be divided into two main types, namely a reception wake-up mode and a transmission wake-up mode, wherein each type can be divided into four types of wake-up modes. Before the UART goes to sleep, a specific wake-up mode should be set.
The start bit wakes up, and the end bit is fixed to 1 and the start bit is fixed to 0 as known in the data frame format. The wake-up mode can set low level wake-up or falling edge wake-up, namely, when the start bit is detected to be 0 or the falling edge occurs in the process of receiving or transmitting data, a wake-up signal is generated.
The N characters wake up, and when N characters are received or transmitted, a wake-up signal is generated.
N characters are matched and awakened, and when N characters are received or transmitted and the character sequence is the same as the character sequence to be compared, an awakening signal is generated. When the mode is a reception wake-up mode, it may be set whether characters that have not been successfully matched are stored in the reception storage module.
Threshold wake-up is divided into high threshold wake-up and low threshold wake-up, and when a certain character received or transmitted is higher or lower than a threshold, a wake-up signal is generated.
In N character matching awakening and threshold awakening, only data bits are compared, and other bits do not participate in comparison.
For example, 5 bytes of data are sent, and then these 5 bytes of data are identical to the 5 bytes of data to be compared, i.e. a wake-up signal is generated. When the MCU is asleep, the UART can realize full duplex communication depending on a low-frequency clock, and the data frame format, transmission mode and baud rate of the transmission and the reception can be different. In order to meet various complex demands in the field of power system communication, there are also various ways of generating wake-up sources. For example, when UART is used to receive data of some complex protocols, the following data can be guaranteed to be meaningful only when a correct message header is received, and then an N-character matching wake-up mode can be adopted.
Optionally, forwarding the data received by the receiving module to the transmitting module through the forwarding module in step S408 includes: under the condition that the data frame formats of the receiving module and the sending module are different, the data frame format of the data is converted from the data frame format of the receiving group to the data frame format of the sending module according to the data frame format set in the parameter configuration.
Optionally, the method for data transmission provided in the embodiment of the present application further includes: and according to the baud rate set in the parameter configuration, respectively corresponding baud rates of the receiving module and the sending module, so that the receiving module and the sending module execute full duplex communication according to the corresponding baud rates.
Optionally, the method for data transmission provided in the embodiment of the present application further includes: after the MCU wakes up, the frequency of a UART preset frequency clock is adjusted, wherein the frequency of the preset frequency clock is a first frequency, the adjusted frequency is a second frequency, and the second frequency is larger than the first frequency.
To sum up, fig. 6 is a flowchart of another data transmission method according to the second embodiment of the present invention; as shown in fig. 6, before the MCU enters the sleep mode, related configurations of the UART with low power consumption, such as data frame format, baud rate, wake mode, etc., need to be set through the peripheral bus module. When the MCU is asleep, the peripheral bus module stops working, and the UART works by means of a low-frequency clock. The UART then starts full duplex reception of the transmit data and detects whether the wake-up condition is met. When the wake-up condition is met, the UART generates a wake-up signal, the MCU enters a normal working mode, and the peripheral bus module resumes working. After reconfiguring the relevant configuration of the UART, the MCU may enter the sleep mode again.
The embodiment of the invention provides a data transmission method. When the MCU enters a sleep mode, the peripheral bus module stops running, the UART runs according to a preset frequency clock, and data is received through a preset pin in the UART; selecting a corresponding wake-up mode according to the preset parameter configuration, wherein the wake-up mode comprises: receiving an awake mode or transmitting an awake mode; when the wake-up mode is a receive wake-up mode, generating a first wake-up signal through the receiving module, sending the first wake-up signal to the MCU, waking up the MCU, and sending data to the sending module through the peripheral bus module; when the wake-up mode is a transmitting wake-up mode, forwarding data to a transmitting module through a forwarding module, generating a second wake-up signal through preset parameter configuration, transmitting the second wake-up signal to the MCU, waking up the MCU, and transmitting the data through the transmitting module; under the sleep mode condition, the forwarding module forwards the data received by the receiving module to the sending module, so that when the MCU sleeps, the UART can rely on the low-frequency clock to realize full duplex communication and support multiple wake-up types, and the technical effect applicable to the power system communication diversified scene is met.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the present invention.

Claims (11)

1. An apparatus for data transmission, comprising:
a peripheral bus module, a forwarding module, an adaptive baud rate module, a receiving module and a transmitting module, wherein,
the peripheral bus module is used for carrying out parameter configuration on the UART before the MCU enters a sleep mode;
when the MCU enters the sleep mode, the peripheral bus module stops running, the UART runs according to a preset frequency clock, the receiving module is used for receiving data through a preset pin in the UART, judging the received data according to the parameter configuration, determining whether to wake up the MCU, generating a first wake-up signal under the condition that the judging result is yes, and sending the first wake-up signal to the MCU;
One end of the forwarding module is connected with the output end of the receiving module, the other end of the forwarding module is respectively connected with the input end of the peripheral bus module and the input end of the sending module, and is used for determining that the data received by the receiving module is sent to the peripheral bus module or the sending module, and converting the data frame format of the data from the data frame format of the receiving group to the data frame format of the sending module according to the parameter configuration under the condition that the data frame formats of the receiving module and the sending module are different;
the sending module is used for receiving the data output by the forwarding module or the peripheral bus module, judging whether to wake up the MCU according to the data, generating a second wake-up signal if the judgment result is yes, and sending the second wake-up signal to the MCU;
the self-adaptive baud rate module is respectively connected with the receiving module and the sending module and is used for respectively generating corresponding baud rates for the receiving module and the sending module so that the receiving module and the sending module execute full duplex communication according to the corresponding baud rates.
2. The apparatus for data transmission according to claim 1, wherein the receiving module comprises: the device comprises a data receiving module, a received data processing module, a received wake-up signal generating module and a received storage module, wherein,
the data receiving module is respectively connected with the adaptive baud rate module and the received data processing module, and is used for receiving the data through a preset pin in the UART, storing the data into a register, generating a baud rate frequency division coefficient by carrying out data frame detection on the data, and sending the baud rate frequency division coefficient to the adaptive baud rate module;
the received data processing module is respectively connected with the received wake-up signal generating module and the received storage module and is used for receiving the data received by the data receiving module, decoding and checking the data;
the received wake-up signal generating module is used for judging whether the data wake-up the MCU according to the decoding result of the received data processing module on the data, and generating the first wake-up signal and sending the first wake-up signal to the MCU if the judging result is yes;
The receiving and storing module is used for receiving the data decoded and checked by the received data processing module and storing the decoded and checked data.
3. The apparatus for data transmission according to claim 1, wherein the transmitting module comprises: a transmission storage module, a transmission data processing module, a transmission wake-up signal generating module and a data transmission module, wherein,
the transmitting storage module is respectively connected with the forwarding module and the peripheral bus module and is used for receiving the data forwarded by the forwarding module or receiving the data transmitted by the peripheral bus module before the MCU sleeps or after the MCU wakes;
one end of the transmission data processing module is connected with the output end of the transmission storage module, and the other end of the transmission data processing module is respectively connected with the data transmission module and the transmission wake-up signal generation module and is used for packaging data in the transmission storage module to obtain a data frame and transmitting the data frame to the data transmission module;
the sending wake-up signal generating module is used for judging whether to wake up the MCU according to the data frame, and generating the second wake-up signal and sending the second wake-up signal to the MCU under the condition that the judging result is yes;
The data transmitting module is used for transmitting the data frame output by the data processing module.
4. The device for data transmission according to claim 1, wherein an input end of the peripheral bus module is connected with the forwarding module, and an output end of the peripheral bus module is connected with the transmitting module, and is configured to transmit the data forwarded by the forwarding module to the transmitting module before or after the MCU sleeps or wakes; and the output end of the peripheral bus module is connected with the adaptive baud rate module and is used for sending the received configuration instruction to the adaptive baud rate module so that the adaptive baud rate module generates the baud rate according to the configuration instruction.
5. A method of data transmission, characterized by an apparatus for data transmission, the method comprising:
when the MCU enters a sleep mode, the peripheral bus module stops running, the UART runs according to a preset frequency clock, and data is received through a preset pin in the UART;
selecting a corresponding wake-up mode according to the received data, wherein the wake-up mode comprises: receiving an awake mode or transmitting an awake mode;
When the wake-up mode is a receive wake-up mode, generating a first wake-up signal through a receiving module, sending the first wake-up signal to the MCU, waking up the MCU, and sending the data to a sending module through the peripheral bus module; or, the data is sent to the sending module through a forwarding module;
when the wake-up mode is a transmission wake-up mode, forwarding the data to a transmission module through a forwarding module, generating a second wake-up signal through the preset parameter configuration, transmitting the second wake-up signal to the MCU, waking up the MCU, and transmitting the data through the transmission module;
and under the condition of the sleep mode, forwarding the data received by the receiving module to the sending module through a forwarding module.
6. The method of data transmission according to claim 5, wherein before the MCU enters sleep mode, the method further comprises:
and carrying out parameter configuration on the UART through the peripheral bus module, wherein the parameter configuration comprises the following steps: data frame format, baud rate, and awake mode.
7. The method of data transmission according to claim 6, wherein the data frame format comprises: a start bit, a data bit, a parity bit, and an end bit, wherein the start bit is fixed to 0; the data bit length is 6-8 bits, the check bit is 1 bit, and the end bit is fixed to be 1.
8. The method of data transmission of claim 7, wherein the wake-up mode comprises: the reception wake-up mode or the transmission wake-up mode, wherein the reception wake-up mode and the transmission wake-up mode include at least one of:
the starting bit wakes up by setting low level wake up or falling edge wake up, and in the process of receiving or transmitting the data, if the starting bit is detected to be the low level or the falling edge appears, the first wake up signal or the second wake up signal is generated;
character wake-up, when a preset number of characters are received or transmitted, generating the first wake-up signal or the second wake-up signal;
character matching awakening, wherein when a preset number of characters are received or transmitted, and the character sequence content is the same as the preset character sequence content, the first awakening signal or the second awakening signal is generated; when the character is matched and awakened into the receiving and awakening mode, screening whether characters which are not successfully matched are stored in a receiving and storing module or not;
a threshold wake-up, wherein the threshold wake-up comprises a first threshold wake-up or a second threshold wake-up, and the threshold in the first threshold wake-up is larger than the threshold in the second threshold wake-up, and the first wake-up signal or the second wake-up signal is generated when the received or transmitted designated character is larger than the first threshold wake-up or smaller than the second threshold wake-up;
And in the character matching awakening and the threshold awakening, the compared position of the data frame format is the data bit.
9. The method according to claim 5, wherein forwarding the data received by the receiving module to the transmitting module by a forwarding module comprises:
and under the condition that the data frame formats of the receiving module and the sending module are different, converting the data frame format of the data from the data frame format of the receiving group to the data frame format of the sending module according to the data frame format set in the parameter configuration.
10. The method of data transmission of claim 6, further comprising:
and respectively carrying out full duplex communication on the baud rates corresponding to the receiving module and the sending module according to the baud rates set in the parameter configuration, so that the receiving module and the sending module execute full duplex communication according to the corresponding baud rates.
11. The method of data transmission of claim 5, further comprising:
after the MCU wakes up, the frequency of the preset frequency clock of the UART is adjusted, wherein the frequency of the preset frequency clock is a first frequency, the adjusted frequency is a second frequency, and the second frequency is larger than the first frequency.
CN202211570515.6A 2022-12-08 2022-12-08 Apparatus and method for data transmission Pending CN116204479A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211570515.6A CN116204479A (en) 2022-12-08 2022-12-08 Apparatus and method for data transmission

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211570515.6A CN116204479A (en) 2022-12-08 2022-12-08 Apparatus and method for data transmission

Publications (1)

Publication Number Publication Date
CN116204479A true CN116204479A (en) 2023-06-02

Family

ID=86508426

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211570515.6A Pending CN116204479A (en) 2022-12-08 2022-12-08 Apparatus and method for data transmission

Country Status (1)

Country Link
CN (1) CN116204479A (en)

Similar Documents

Publication Publication Date Title
US20170255588A1 (en) Multiprotocol i3c common command codes
JP3955568B2 (en) Method and apparatus for extending battery life of communication devices
US6728892B1 (en) Method for conserving power in a can microcontroller and a can microcontroller that implements this method
US7877117B2 (en) Method for maintaining wireless network response time while saving wireless adapter power
US20160364350A1 (en) Methods and apparatus for synchronizing uplink and downlink transactions on an inter-device communication link
US20180285292A1 (en) System and method of sending data via additional secondary data lines on a bus
EP1650669B1 (en) Method and system for reducing power consumption of handsets through uart auto flow control
CN105227215A (en) A kind of power carrier communication device and control method thereof
CN106658686B (en) Data forwarding method and access device
CN111352887B (en) PCI bus-to-configurable frame length serial bus adaptation and transmission method
US7373134B2 (en) Multiple-CPU portable terminal with communication function and control method
CN116204479A (en) Apparatus and method for data transmission
US20050144488A1 (en) Method and apparatus of lowering I/O bus power consumption
CN111600785A (en) M-BUS intelligent water meter low-power-consumption communication method
KR0154180B1 (en) Power supply control for a receiver
US7334040B2 (en) Method of transmission between two processors of a radio communication unit
CN221202583U (en) Gateway for protocol communication conversion
CN219181725U (en) CAN data frame synchronization structure and atmosphere lamp light stream frame synchronization control system
JPH11127165A (en) Radio lan system and battery save method
CN113747551B (en) Discontinuous receiving method for wireless communication
CN109426526B (en) Interface wake-up synchronization method, interface device and computer readable medium
CN109309935B (en) Communication method and device of wireless local area network, access point equipment and site equipment
CN108227893B (en) Serial port controller, micro control system and awakening method in micro control system
JP3454264B2 (en) Wireless communication system and wireless communication method
JP2000101677A (en) Half-duplex communication system and communication terminal device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination