CN110401522A - A kind of data communication apparatus, controller and its data communication method - Google Patents

A kind of data communication apparatus, controller and its data communication method Download PDF

Info

Publication number
CN110401522A
CN110401522A CN201910786640.2A CN201910786640A CN110401522A CN 110401522 A CN110401522 A CN 110401522A CN 201910786640 A CN201910786640 A CN 201910786640A CN 110401522 A CN110401522 A CN 110401522A
Authority
CN
China
Prior art keywords
uart
module
data
sent
sending
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.)
Granted
Application number
CN201910786640.2A
Other languages
Chinese (zh)
Other versions
CN110401522B (en
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.)
Gree Electric Appliances Inc of Zhuhai
Original Assignee
Gree Electric Appliances Inc of Zhuhai
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 Gree Electric Appliances Inc of Zhuhai filed Critical Gree Electric Appliances Inc of Zhuhai
Priority to CN201910786640.2A priority Critical patent/CN110401522B/en
Publication of CN110401522A publication Critical patent/CN110401522A/en
Application granted granted Critical
Publication of CN110401522B publication Critical patent/CN110401522B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04BTRANSMISSION
    • H04B1/00Details of transmission systems, not covered by a single one of groups H04B3/00 - H04B13/00; Details of transmission systems not characterised by the medium used for transmission
    • H04B1/38Transceivers, i.e. devices in which transmitter and receiver form a structural unit and in which at least one part is used for functions of transmitting and receiving
    • H04B1/40Circuits
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L5/00Arrangements affording multiple use of the transmission path
    • H04L5/14Two-way operation using the same type of signal, i.e. duplex
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L5/00Arrangements affording multiple use of the transmission path
    • H04L5/14Two-way operation using the same type of signal, i.e. duplex
    • H04L5/16Half-duplex systems; Simplex/duplex switching; Transmission of break signals non-automatically inverting the direction of transmission

Abstract

The invention discloses a kind of data communication apparatus, controller and its data communication method, which includes: UART receiving module, comprising: a UART module realizes that the UART of data is received for the UART receive capabilities based on UART module itself;UART sending module, comprising: the resource module of the controller of pending data communication itself simulates UART module, and simulation UART module realizes that the UART of data is sent for simulating the UART transmission timing of UART module;Or another UART module, another UART module realize that the UART of data is sent for the UART sending function based on UART module itself.The solution of the present invention can solve the main MCU by using full duplex communication to improve the problem of communication speed will lead to increased costs, achieve the effect that reduce cost.

Description

A kind of data communication apparatus, controller and its data communication method
Technical field
The invention belongs to communication technique fields, and in particular to a kind of data communication apparatus, controller and its data communication side Method, more particularly to one kind pass through timer and simulate UART (Universal Asynchronous Receiver/ Transmitter, universal asynchronous receiving-transmitting transmitter) send data-selected scheme realization device, controller and its data communication method.
Background technique
At this stage with internet of things technology be constantly progressive and user's being gradually increased for communication speed requirement, household electric It is imperative that device increases internet of things technology.Also there are more and more household electrical appliance to increase WIFI function at present, user can be allowed straight It connects with mobile phone come household electrical appliance such as operating air conditioners, but it is still the main complaint point of the discontented WIFI function of user that communication speed is excessively slow.
To improve communication speed, in the selection of most master chips, selection supports the main MCU of full duplex communication to mention High communication speed;And upgrade and use full duplex communication chip, then it will lead to increased costs.
Above content is only used to facilitate the understanding of the technical scheme, and is not represented and is recognized that above content is existing skill Art.
Summary of the invention
It is an object of the present invention in view of the foregoing drawbacks, a kind of data communication apparatus, controller and its data communication are provided Method reaches drop to solve the problems, such as that the main MCU by using full duplex communication will lead to increased costs to improve communication speed The effect of low cost.
The present invention provides a kind of data communication apparatus, comprising: UART receiving module and UART sending module;Wherein, described UART receiving module realizes that the UART of data is received for the UART receive capabilities based on UART module itself;The UART hair Module is sent, for simulating the UART transmission timing of UART module or the UART sending function based on UART module itself, realizes number According to UART send;Wherein, the UART sending module, comprising: the resource module of the controller of pending data communication itself, Simulation UART module realizes that the UART of data is sent for simulating the UART transmission timing of UART module;Or another UART mould Block, another UART module realize that the UART of data is sent for the UART sending function based on UART module itself.
Optionally, the simulation UART module, comprising: output module, counting module and control module;Wherein, described defeated Module out realizes that data are sent for simulating the UART sending function of the UART module;Counting module, for according to setting Baud rate scope carries out timing, obtains timing time;Control module, for controlling the output module according to the timing time Transmission timing, realize that the output module simulates the UART sending function of the UART module.
Optionally, wherein the UART module, comprising: the UART communication resources module of half-duplex chip;And/or it is described Output module, comprising: the I/O port of controller;And/or the counting module, comprising: the internal timing interrupt resources mould of controller Block.
Optionally, the control module controls the transmission timing of the output module according to the timing time, comprising: control The controller power-on initialization is made, the port level that the output module is arranged is the first signal, and is wanted by preset interruption Seek the configuration counting module;It determines the need for sending data;If desired data are sent, then store data to be sent, are calculated The check bit of the data to be sent, and start the tally function of the counting module;In the timer interrupt control of the counting module Under system, the output module is controlled according to preset baud rate and sends next data bit in the case where timing time arrives, Realize that the UART of data is sent with the transmission timing by simulation UART.
Optionally, the control module controls the feelings that the output module arrives according to preset baud rate in timing time Next data bit is sent under condition, comprising: determine the data bit number of data to be sent in default value range present position; After being adjusted according to port level of the position to the output module or send the corresponding data of corresponding data position, control The data bit number increases automatically or closes after sending stop bits the tally function of the counting module.
Optionally, the control module is adjusted or sends according to port level of the position to the output module The corresponding data of corresponding data position, comprising: if the data bit number is the lower limit of default value range, start bit is sent, The port level of the output module is set to second signal;If the data bit number is greater than under default value range Limit and the upper limit for being less than default value range, then the size order according to the data bit number successively sends data to be sent Each data bit;If the data bit number is equal to the upper limit of default value range, check bit is sent;If the data bit Number is greater than the upper limit of default value range, then sends stop bits, and the port level of the output module is set to the first letter Number.
Match with above-mentioned apparatus, further aspect of the present invention provides a kind of controller, comprising: above-described data communication Device.
Match with above controller, further aspect of the present invention provides a kind of data communication method of controller, comprising: logical A UART module is crossed as UART receiving module, based on the UART receive capabilities of UART module itself, realizes that the UART of data connects It receives;By UART sending module, simulates the UART transmission timing of UART module or the UART based on UART module itself sends function Can, realize that the UART of data is sent;Wherein, the UART sending module, comprising: the controller of pending data communication itself Resource module, simulation UART module realize that the UART of data is sent for simulating the UART transmission timing of UART module;Or Another UART module, another UART module realize the UART of data for the UART sending function based on UART module itself It sends.
Optionally, pass through the UART transmission timing of simulation UART module simulation UART module, comprising: by output module, The UART sending function of the UART module is simulated, realizes that data are sent;By counting module, according to setting baud rate scope into Row timing, obtains timing time;By control module, the transmission timing of the output module is controlled according to the timing time, Realize that the output module simulates the UART sending function of the UART module.
Optionally, the transmission timing of the output module is controlled according to the timing time by control module, comprising: control The controller power-on initialization is made, the port level that the output module is arranged is the first signal, and is wanted by preset interruption Seek the configuration counting module;It determines the need for sending data;If desired data are sent, then store data to be sent, are calculated The check bit of the data to be sent, and start the tally function of the counting module;In the timer interrupt control of the counting module Under system, the output module is controlled according to preset baud rate and sends next data bit in the case where timing time arrives, Realize that the UART of data is sent with the transmission timing by simulation UART.
Optionally, the feelings that the output module arrives according to preset baud rate in timing time are controlled by control module Next data bit is sent under condition, comprising: determine the data bit number of data to be sent in default value range present position; After being adjusted according to port level of the position to the output module or send the corresponding data of corresponding data position, control The data bit number increases automatically or closes after sending stop bits the tally function of the counting module.
Optionally, it is adjusted or sends according to port level of the position to the output module by control module The corresponding data of corresponding data position, comprising: if the data bit number is the lower limit of default value range, start bit is sent, The port level of the output module is set to second signal;If the data bit number is greater than under default value range Limit and the upper limit for being less than default value range, then the size order according to the data bit number successively sends data to be sent Each data bit;If the data bit number is equal to the upper limit of default value range, check bit is sent;If the data bit Number is greater than the upper limit of default value range, then sends stop bits, and the port level of the output module is set to the first letter Number.
The solution of the present invention can be with save the cost by realizing full duplex communication function using half-duplex chip;May be used also To improve the communication speed of household electrical appliance, user's usage comfort is promoted.
Further, the solution of the present invention can by using the timer internal resource that can only support half duplex communication chip To realize the communication function of chip full duplex, guarantee that full duplex communication function is normal, while reducing into product cost.
Further, the solution of the present invention is interrupted by the UART communication resources and internal timing that utilize half-duplex chip As the resource distribution for completing full duplex communication, and using internal counter according to different baud rate timing different times, control Common output mouth level simulates UART sending function, realizes full duplex on the chip platform for only supporting half duplex communication Communication modes, it is at low cost, user experience is good.
The solution of the present invention as a result, realizes full duplex communication function by using the chip of half duplex communication is only supported, It solves the problems, such as to will lead to increased costs by using the main MCU of full duplex communication to improve communication speed, reaching reduces cost Effect.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification It obtains it is clear that understand through the implementation of the invention.
Below by drawings and examples, technical scheme of the present invention will be described in further detail.
Detailed description of the invention
Fig. 1 is the structural schematic diagram of an embodiment of data communication apparatus of the invention;
Fig. 2 is the flow diagram of an embodiment of data communication method of the invention;
Fig. 3 is an implementation of the UART transmission timing in method of the invention by simulation UART module simulation UART module The flow diagram of example;
Fig. 4 is the implementation for controlling the transmission timing of the output module in method of the invention according to the timing time The flow diagram of example;
Fig. 5 is to send next number in the case where timing time arrives according to preset baud rate in method of the invention According to the flow diagram of an embodiment of position;
Fig. 6 is the flow diagram of the transmission simulation process of an embodiment of controller of the invention, wherein (a) is hair Mathematical logic flow diagram is sent, (b) flow diagram to send digital simulation processing mode;
Fig. 7 is the use circuit theory schematic diagram of the resources of chip of an embodiment of controller of the invention.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with the specific embodiment of the invention and Technical solution of the present invention is clearly and completely described in corresponding attached drawing.Obviously, described embodiment is only the present invention one Section Example, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art are not doing Every other embodiment obtained under the premise of creative work out, shall fall within the protection scope of the present invention.
According to an embodiment of the invention, providing a kind of data communication apparatus.The one of the device of the invention shown in Figure 1 The structural schematic diagram of embodiment.The data communication apparatus may include: UART receiving module and UART sending module.
Specifically, the UART receiving module may include: a UART module, for based on UART module itself UART receive capabilities realize that the UART of data is received.
Optionally, the UART module may include: the UART communication resources module of half-duplex chip.
Such as: it is interrupted using the UART communication resources and internal timing of half-duplex chip as completion full duplex communication Resource distribution, and a kind of corresponding software algorithm is provided, full duplex is realized on the chip platform for only supporting half duplex communication Communication modes.
Such as: data are sended and received using two groups of difference UART ports of the chip for supporting half duplex communication, or are used One group of UART port and external interrupt simulation UART are received.
It is at low cost as a result, by using the UART communication resources module of half-duplex chip as UART module, and can Receive capabilities by realizing data.
Specifically, the UART sending module can be used for simulating the UART transmission timing of UART module or based on UART The UART sending function of module itself realizes that the UART of data is sent.Preferably, the UART sending module, can be used for leading to It crosses the UART transmission timing for simulating UART module using counter and I/O port or the UART based on UART module itself sends function Can, realize that the UART of data is sent.That is, the simulation UART module, can be used for the internal counter by using controller With O mouthfuls of exterior I, the UART transmission timing or UART sending function based on UART module itself for simulating UART module realize number According to UART send.
Such as: on function logic, using UART receive capabilities, without the use of its sending function;Sending function is by making UART timing is simulated with internal counter and common I/O port, reaches and realizes UART sending function.
Wherein, the UART sending module may include: the resource module of the controller itself of pending data communication, Simulation UART module realizes that the UART of data is sent for simulating the UART transmission timing of UART module;Or another UART mould Block, another UART module realize that the UART of data is sent for the UART sending function based on UART module itself.
Such as: it is a kind of that data-selected scheme is sent by timer simulation UART (i.e. universal asynchronous receiving-transmitting transmitter), utilize half Duplexing chip realizes full duplex communication function, save the cost;The communication speed of household electrical appliance can also be improved, promoting user makes With comfort level, customer complaint is reduced.
Such as: using that can only support other resources of the inside of half duplex communication chip, realize the communication function of chip full duplex Can, guarantee that full duplex communication function is normal, while reducing into product cost.In this way, the solution of the present invention, may be implemented using only The chip of half duplex communication is supported to realize full duplex communication function.With this solution, the half-duplex core of low cost can be used Piece reaches the requirement of full duplex communication function, and development is low in cost, improves product competitiveness in the market.
As a result, by making UART module realize receive capabilities, and keep the transmission timing for simulating UART module simulation UART real Existing sending function, not only realizes the reliable communicating of data, but also reduce costs.
Optionally, the simulation UART module, may include: output module, counting module and control module.
That is, the data communication apparatus, may include: UART module, output module, counting module and control mould Block.Wherein, output module, counting module and control module are the internal resource modules of controller itself.
Such as: UART is simulated using one group of UART (i.e. universal asynchronous receiving-transmitting transmitter)+common output mouth+internal counter Scheme.Such as because when resources of chip is limited or practice is needed using multiple groups UART port, and it is unable to satisfy while uses two UART port is organized to realize full duplex communication, then it is contemplated that using internal counter according to different baud rate timing different times, control Common output mouth level processed simulates UART sending function, to realize full duplex communication requirement.
Specifically, the output module can be used for simulating the UART sending function of the UART module, realize data hair It send.
More optionally, the output module may include: the I/O port of controller.
As a result, by using the I/O port of controller as output module, it is not required to increase cost, and can reliably realize data Transmission.
Specifically, counting module can be used for carrying out timing according to setting baud rate scope, obtain timing time.
More optionally, the counting module may include: the internal timing interrupt resources module of controller.
As a result, by using the internal timing interrupt resources of controller as counting module, it is not required to increase cost, and can be with Realize that reliable timer interrupt is controlled when simulating UART sending function using I/O port.
Specifically, control module can be used for controlling the transmission timing of the output module according to the timing time, real The existing output module simulates the UART sending function of the UART module.
Such as: control module can use the control section of controller such as MCU.
As a result, by using the cooperation of output module, counting module and control module, the transmission of simulation UART module is realized Function, structure is simple, at low cost, and the available guarantee of reliability that data are sent.
Still optionally further, the control module controls the transmission timing of the output module according to the timing time, May include:
The control module specifically can be also used for controlling the controller power-on initialization, the output module be arranged Port level be the first signal, and configure the counting module by preset interrupt request.Such as: first signal can be High level.
Such as: power-up initializing is set using the common I/O port (i.e. transmission I/O port) of the sending port of simulation UART function For high level, the counter that need to be used is initialized.
The control module specifically can be also used for determining the need for sending data;If desired data are sent, then are stored Data to be sent, calculate the check bit of the data to be sent, and start the tally function of the counting module;And described Counting module timer interrupt control under, control the output module according to preset baud rate timing time arrive the case where It is lower to send next data bit, realize that the UART of data is sent with the transmission timing by simulation UART;If no need to send numbers According to then continuing waiting for.
Such as: judge whether to need to send data, if not, with no treatment;If so, then depositing data to be sent When entering variables A, and calculate check bit, and starting counter counts.The data that judgement is sent set timer according to baud rate Time, timing time arrive, and send next data bit, simulate UART sending function.
It is arranged as a result, by the timing of the configuration counting module in power-up initializing, and the starting when needing to send data Timer interrupt interrupts and then simulates the sending function realization data transmission of UART, and realization makes control module according to timing time control The transmission timing of output module processed, so that the simulation to UART sending function is precisely and reliable.
More optionally, the control module controls what the output module arrived according to preset baud rate in timing time In the case of send next data bit, may include:
The control module, the data bit number that specifically can be also used for determining data to be sent is in default value range Present position.
The control module specifically can be also used for being adjusted according to port level of the position to the output module After corresponding data that is whole or sending corresponding data position, controls the data bit number and increase automatically or closed after sending stop bits Close the tally function of the counting module.Such as: after being sent completely, variable B adds 1 certainly.If a frame data are sent completely, then reset Variable is closed timer and is interrupted, is transferred to step b;It such as the not sent completion of a frame data, then waits, the tape timer time arrives, and continues Send data.
Such as: it is clocked into device interruption, then judges the position number (such as variable B) of data to be sent, and according to judging result It is handled.
As a result, by the data bit number based on data to be sent in default value range present position to corresponding positions data Corresponding transmission processing is carried out, so that sending to the data of corresponding data position reliable and accurate.
Further optionally, the control module is adjusted according to port level of the position to the output module Corresponding data that is whole or sending corresponding data position is (that is, the control module is according to the data bit number of data to be sent pre- If numberical range present position, the port level of the output module is adjusted or is sent the correspondence number of corresponding data position According to), it may include following any transmission situation.
The first sends situation: the control module, if specifically can be also used for the data bit number is default value The lower limit of range then sends start bit, i.e., the port level of the output module is set to second signal.Such as: second signal It can be low level signal.
Such as: if variable B is zero, then it represents that start bit need to be sent, I/O port is sent and set low level.
Second of transmission situation: the control module, if specifically can be also used for the data bit number greater than present count It is worth the lower limit of range and is less than the upper limit of default value range, then the size order according to the data bit number is successively sent Each data bit of data to be sent.
Such as: if variable B is not zero and less than 9, then it represents that (such as variables A) position (variables A size herein of data to be sent Just it is 1-8 for a byte i.e. 8 bit, variable B, therefore can successively sends each data bit of variables A using this relationship).
The third sends situation: the control module, if specifically can be also used for the data bit number equal to present count It is worth the upper limit of range, then sends check bit.
Such as: if variable B is 9, then it represents that send check bit.
4th kind of transmission situation: the control module, if specifically can be also used for the data bit number greater than present count It is worth the upper limit of range, then sends stop bits, and the port level of the output module is set to the first signal.
Such as: if variable B is greater than 9, stop bits is sent, transmission I/O port sets high level, and (stop bits is advised according to communications protocol It is fixed, send it is primary this example illustrates by taking a stop bits as an example still twice, two stop bits be a multiple stop bits and ), stop bits is sent.
As a result, by ensure that each data bits according to hair to the different transmissions of each data bits evidence and processing mode The accuracy and reliability sent.
Through a large amount of verification experimental verification, using technical solution of the present invention, by realizing full duplex using half-duplex chip Communication function, can be with save the cost.The communication speed of household electrical appliance can also be improved, user's usage comfort is promoted.
According to an embodiment of the invention, additionally providing a kind of controller corresponding to data communication apparatus.The controller can To include: above-described data communication apparatus.
In an optional example, the solution of the present invention is provided a kind of by timer simulation UART (i.e. universal asynchronous receipts Send out transmitter) data-selected scheme is sent, full duplex communication function, save the cost are realized using half-duplex chip;It can also improve The communication speed of household electrical appliance promotes user's usage comfort, reduces customer complaint.
Wherein, half-duplex (Half Duplex) data transmission index evidence can be in the both direction of a signal vehicle Transmission, but it is unable to simultaneous transmission.For example, using the technology with half-duplex transmission, a work station on a local area network Data can be sent on line, receive data on line immediately after, these data are from the direction that data have just been transmitted.As complete Duplex transmission is the same, and half-duplex includes a bidirectional line (route can transmit data in two directions).
In an optional example, the solution of the present invention, use can only support other moneys of the inside of half duplex communication chip The communication function of chip full duplex is realized in source such as internal timing interrupt resources etc., is guaranteed that full duplex communication function is normal, is dropped simultaneously It is low at product cost.
In this way, the solution of the present invention, may be implemented to realize full duplex communication using the chip of half duplex communication is only supported Function.With this solution, the half-duplex chip that low cost can be used reaches the requirement of full duplex communication function, development at This is cheap, improves product competitiveness in the market.
In an optional specific embodiment, Fig. 6 and example shown in Fig. 7 may refer to, to the solution of the present invention Specific implementation process illustrates.
The solution of the present invention is interrupted complete double as completing using the UART communication resources and internal timing of half-duplex chip The resource distribution of work communication, and a kind of corresponding software algorithm is provided, come on the chip platform for only supporting half duplex communication real The communication modes of existing full duplex.
Wherein, in the solution of the present invention, because only supporting the chip of half duplex communication, most of is all because sending caching (i.e. UART transmitting-receiving is slow for the general same address buffer (buffer register, buffer register) and reception caching buffer It deposits).When full duplex communication, chip sends and receives data simultaneously, caches because UART is received and dispatched, the same address buffer can not be simultaneously Two data are stored, (that is: when carrying out data transmission, while being received, data are not so as to cause data collision is sended and received It is sent completely and receives and be completed, then receives data deposit UART transmitting-receiving caching buffer and cause to send loss of data), cause Communication function is chaotic, therefore in the internal resource of half-duplex chip, solve the problems, such as this.
In an optional specific example, one group of UART (i.e. universal asynchronous receiving-transmitting transmitter)+common output mouth+interior is used Portion's counter simulates UART scheme.
Such as because when resources of chip is limited or practice is needed using multiple groups UART port, and it is unable to satisfy while makes Realize full duplex communication with two groups of UART ports, then it is contemplated that using internal counter according to different baud rate timing differences when Between, common output mouth level is controlled to simulate UART sending function, to realize full duplex communication requirement.
Wherein, on function logic, using UART receive capabilities, without the use of its sending function;Sending function is by making UART timing is simulated with internal counter and common I/O port, reaches and realizes UART sending function.
Specifically, the algorithm steps that external interrupt simulation UART is sent can be such that
Step a, it is powered on and initialized, is set using the common I/O port (i.e. transmission I/O port) of the sending port of simulation UART function For high level, the counter that initializing need to use (is opened to interrupt and be enabled, counter interrupts entry time, is with 4800bps Example, then the entry time of counter is 1/4800=0.208ms).
Wherein, open and interrupt enabled, refer to: chip has many resources, during timer, UART are received and UART transmission is all Disconnected operation;By taking timer as an example, if necessary to use chip timer resource, then needs to open interruption and enable, indicate to open this A resources of chip signal, chip, which can enter this timer, to interrupt.
Counter interrupts entry time, and refer to: timer is a kind of interruption, after setting, every setting time, into meter When device interrupt function, handle function in program.
Step b, judge whether to need to send data, if not, with no treatment;If so, then by data to be sent When being stored in variables A, and calculate check bit, and starting counter counts.
Such as: whether need to send data, can be and provided according to both sides' communications protocol, as user grasps air-conditioning Make, then operational mode change (may be windscreen change be also likely to be mode change), then need synchronized update communication module air-conditioning Operational mode, then need to send data at this time.
Wherein, this check bit felt according to the communications protocol of communication two party Module Specification odd, even parity check or It does not verify, this example is to have check bit, this step is skipped if communications protocol does not have check bit and directly transmits stop bits.
Step c, it is clocked into device interruption, then judges the position number (such as variable B) of data to be sent, and according to judging result It is handled.That is, it is judged that the data sent set the timer time according to baud rate, timing time is arrived, and is sent next Data bit simulates UART sending function.
Wherein, it is all a byte that UART, which sends data, for sending data 0x55 (this data is variables A), UART The data of transmission, data format are as follows: start bit (bit0)+data (0x55)+check bit (bit1 or bit0)+stop bits (bit1).Here, according to bilateral agreement difference, stop bits can make a bit, be also possible to two bit.
Optionally, if variable B is zero, then it represents that start bit need to be sent, I/O port is sent and set low level.
Optionally, if variable B is not zero and less than 9, then it represents that (variables A is big herein for (such as variables A) position of data to be sent Small be a byte i.e. 8 bit, variable B is just 1-8, therefore each data bit of variables A can be successively sent using this relationship).
Optionally, if variable B is 9, then it represents that send check bit.
Optionally, if variable B is greater than 9, stop bits is sent, transmission I/O port sets high level, and (stop bits is according to communications protocol Regulation, send it is primary this example illustrates by taking a stop bits as an example still twice, two stop bits be a multiple stop bits and ), stop bits is sent.
Wherein, after being sent completely, variable B adds 1 certainly.
Step d, such as a frame data are sent completely, then reset variable, are closed timer and are interrupted, are transferred to step b;Such as a frame number It according to not sent completion, then waits, the tape timer time arrives, and is transferred to step c, continues to send data.
In the solution of the present invention, number is sended and received using two groups of difference UART ports of the chip for supporting half duplex communication According to, or using one group of UART port and external interrupt simulation UART reception.
The processing and function realized by the controller of the present embodiment essentially correspond to the reality of aforementioned device shown in FIG. 1 Example, principle and example are applied, therefore not detailed place in the description of the present embodiment, it may refer to the related description in previous embodiment, This will not be repeated here.
Through a large amount of verification experimental verification, using technical solution of the present invention, by using can only support half duplex communication chip Timer internal resource, may be implemented the communication function of chip full duplex, guarantee that full duplex communication function is normal, reduce simultaneously At product cost.
According to an embodiment of the invention, additionally providing a kind of data communication method of controller corresponding to controller, such as The flow diagram of one embodiment of method of the invention shown in Fig. 2.The data communication method of the controller may include: step S110 and step S120.
At step S110, data are realized based on the UART receive capabilities of UART module itself by UART receiving module UART receive.
Optionally, the UART module may include: the UART communication resources module of half-duplex chip.
Such as: it is interrupted using the UART communication resources and internal timing of half-duplex chip as completion full duplex communication Resource distribution, and a kind of corresponding software algorithm is provided, full duplex is realized on the chip platform for only supporting half duplex communication Communication modes.
Such as: data are sended and received using two groups of difference UART ports of the chip for supporting half duplex communication, or are used One group of UART port and external interrupt simulation UART are received.
It is at low cost as a result, by using the UART communication resources module of half-duplex chip as UART module, and can Receive capabilities by realizing data.
At step S120, by a UART module as UART sending module, when simulating the UART transmission of UART module Sequence or UART sending function based on UART module itself realize that the UART of data is sent.Preferably, the UART sends mould Block can be used for being simulated the UART transmission timing of UART module by using counter and I/O port or be based on UART module itself UART sending function, realize data UART send.That is, the simulation UART module, can be used for by using controller Internal counter and O mouthfuls of exterior I, simulate UART module UART transmission timing or based on UART module itself UART hair Function is sent, realizes that the UART of data is sent.
Such as: on function logic, using UART receive capabilities, without the use of its sending function;Sending function is by making UART timing is simulated with internal counter and common I/O port, reaches and realizes UART sending function.
Wherein, the UART sending module may include: the resource module of the controller itself of pending data communication, Simulation UART module realizes that the UART of data is sent for simulating the UART transmission timing of UART module;Or another UART mould Block, another UART module realize that the UART of data is sent for the UART sending function based on UART module itself.
Such as: it is a kind of that data-selected scheme is sent by timer simulation UART (i.e. universal asynchronous receiving-transmitting transmitter), utilize half Duplexing chip realizes full duplex communication function, save the cost;The communication speed of household electrical appliance can also be improved, promoting user makes With comfort level, customer complaint is reduced.
Such as: using that can only support other resources of the inside of half duplex communication chip, realize the communication function of chip full duplex Can, guarantee that full duplex communication function is normal, while reducing into product cost.In this way, the solution of the present invention, may be implemented using only The chip of half duplex communication is supported to realize full duplex communication function.With this solution, the half-duplex core of low cost can be used Piece reaches the requirement of full duplex communication function, and development is low in cost, improves product competitiveness in the market.
As a result, by making UART module realize receive capabilities, and keep the transmission timing for simulating UART module simulation UART real Existing sending function, not only realizes the reliable communicating of data, but also reduce costs.
It is alternatively possible to pass through simulation UART module simulation UART module in method of the invention as shown in connection with fig. 3 One embodiment flow diagram of UART transmission timing further illustrates in step S120 through simulation UART module simulation UART The detailed process of the UART transmission timing of module may include: step S210 to step S230.
Step S210 simulates the UART sending function of the UART module by output module, realizes that data are sent.
Step S220 carries out timing according to setting baud rate scope, obtains timing time by counting module.
Step S230 controls the transmission timing of the output module according to the timing time by control module, realizes The output module simulates the UART sending function of the UART module.
That is, the realization device of the data communication method, may include: UART module, output module, counting module And control module.Wherein, output module, counting module and control module are the internal resource modules of controller itself.
As a result, by using the cooperation of output module, counting module and control module, the transmission of simulation UART module is realized Function, structure is simple, at low cost, and the available guarantee of reliability that data are sent.
Still optionally further, it can be controlled as shown in connection with fig. 4 according to the timing time in method of the invention described defeated An embodiment flow diagram of the transmission timing of module out further illustrates and controls the output mould according to the timing time The transmission timing of block (controls the hair of the output module by control module according to the timing time in specifically step S230 Send timing) detailed process, may include: step S310 to step S340.
Step S310 controls the controller power-on initialization, and the port level that the output module is arranged is the first letter Number, and the counting module is configured by preset interrupt request.Such as: first signal can be high level.
Such as: power-up initializing is set using the common I/O port (i.e. transmission I/O port) of the sending port of simulation UART function For high level, the counter that need to be used is initialized.
Step S320, it is determined whether need to send data.
Step S330, if desired sends data, then stores data to be sent, calculates the check bit of the data to be sent, and Start the tally function of the counting module.
Step S340 controls the output module according to preset wave under the timer interrupt control of the counting module Special rate sends next data bit in the case where timing time arrives, and realizes data with the transmission timing by simulation UART UART is sent;If being continued waiting for no need to send data.
Such as: judge whether to need to send data, if not, with no treatment;If so, then depositing data to be sent When entering variables A, and calculate check bit, and starting counter counts.The data that judgement is sent set timer according to baud rate Time, timing time arrive, and send next data bit, simulate UART sending function.
It is arranged as a result, by the timing of the configuration counting module in power-up initializing, and the starting when needing to send data Timer interrupt interrupts and then simulates the sending function realization data transmission of UART, and realization makes control module according to timing time control The transmission timing of output module processed, so that the simulation to UART sending function is precisely and reliable.
More it is alternatively possible to be arrived as shown in connection with fig. 5 according to preset baud rate in timing time in method of the invention In the case where send an embodiment flow diagram of next data bit, further illustrate according to preset baud rate in timing Next data bit, which is sent, in the case where time arrival (output module is controlled by control module in specifically step S340 According to preset baud rate timing time arrive in the case where send next data bit) detailed process, may include: step Rapid S410 and step S420.
Step S410 determines the data bit number of data to be sent in default value range present position.
Step S420 is adjusted or sends corresponding data position according to port level of the position to the output module Corresponding data after, control the meter that the data bit number increases automatically or closes the counting module after sending stop bits Number function.Such as: after being sent completely, variable B adds 1 certainly.If a frame data are sent completely, then variable is reset, closed in timer It is disconnected, it is transferred to step b;It such as the not sent completion of a frame data, then waits, the tape timer time arrives, and continues to send data.
Such as: it is clocked into device interruption, then judges the position number (such as variable B) of data to be sent, and according to judging result It is handled.
As a result, by the data bit number based on data to be sent in default value range present position to corresponding positions data Corresponding transmission processing is carried out, so that sending to the data of corresponding data position reliable and accurate.
Further optionally, pass through control module in step S420 according to the position to the port of the output module Level is adjusted or sends the corresponding data of corresponding data position (that is, data of the control module according to data to be sent Position number is adjusted or sends corresponding data position to the port level of the output module in default value range present position Corresponding data), may include following any transmission situation.
The first sends situation: if the data bit number is the lower limit of default value range, sending start bit, i.e., will The port level of the output module is set to second signal.Such as: second signal can be low level signal.
Such as: if variable B is zero, then it represents that start bit need to be sent, I/O port is sent and set low level.
Second of transmission situation: if the data bit number is greater than the lower limit of default value range and is less than default value The upper limit of range, then the size order according to the data bit number successively sends each data bit of data to be sent.
Such as: if variable B is not zero and less than 9, then it represents that (such as variables A) position (variables A size herein of data to be sent Just it is 1-8 for a byte i.e. 8 bit, variable B, therefore can successively sends each data bit of variables A using this relationship).
The third sends situation: if the data bit number is equal to the upper limit of default value range, sending check bit.
Such as: if variable B is 9, then it represents that send check bit.
4th kind of transmission situation: if the data bit number is greater than the upper limit of default value range, sending stop bits, and The port level of the output module is set to the first signal.
Such as: if variable B is greater than 9, stop bits is sent, transmission I/O port sets high level, and (stop bits is advised according to communications protocol It is fixed, send it is primary this example illustrates by taking a stop bits as an example still twice, two stop bits be a multiple stop bits and ), stop bits is sent.
As a result, by ensure that each data bits according to hair to the different transmissions of each data bits evidence and processing mode The accuracy and reliability sent.
The processing and function realized by the method for the present embodiment essentially correspond to the embodiment of aforementioned controllers, principle And example, therefore not detailed place in the description of the present embodiment, it may refer to the related description in previous embodiment, do not do herein superfluous It states.
Through a large amount of verification experimental verification, using the technical solution of the present embodiment, by being communicated using the UART of half-duplex chip Resource and internal timing are interrupted as the resource distribution for completing full duplex communication, and using internal counter according to different bauds Rate timing different time controls common output mouth level to simulate UART sending function, in the chip for only supporting half duplex communication Realize the communication modes of full duplex on platform, it is at low cost, user experience is good.
To sum up, it will be readily appreciated by those skilled in the art that under the premise of not conflicting, above-mentioned each advantageous manner can be certainly It combined, be superimposed by ground.
The above description is only an embodiment of the present invention, is not intended to restrict the invention, for those skilled in the art For member, the invention may be variously modified and varied.All within the spirits and principles of the present invention, it is made it is any modification, Equivalent replacement, improvement etc., should be included within scope of the presently claimed invention.

Claims (12)

1. a kind of data communication apparatus characterized by comprising UART receiving module and UART sending module;Wherein,
The UART receiving module, comprising: a UART module is realized for the UART receive capabilities based on UART module itself The UART of data is received;
The UART sending module, for simulating the UART transmission timing of UART module or the UART based on UART module itself Sending function realizes that the UART of data is sent;
Wherein, the UART sending module, comprising: the resource module of the controller of pending data communication itself simulates UART Module, simulation UART module realize that the UART of data is sent for simulating the UART transmission timing of UART module;Or it is another UART module, another UART module realize the UART hair of data for the UART sending function based on UART module itself It send.
2. the apparatus according to claim 1, which is characterized in that the simulation UART module, comprising: output module, counting Module and control module;Wherein,
The output module realizes that data are sent for simulating the UART sending function of the UART module;
Counting module obtains timing time for carrying out timing according to setting baud rate scope;
Control module realizes the output module for controlling the transmission timing of the output module according to the timing time Simulate the UART sending function of the UART module.
3. the apparatus of claim 2, which is characterized in that wherein,
The UART module, comprising: the UART communication resources module of half-duplex chip;And/or
The output module, comprising: the I/O port of controller;And/or
The counting module, comprising: the internal timing interrupt resources module of controller.
4. device according to claim 2 or 3, which is characterized in that the control module is controlled according to the timing time The transmission timing of the output module, comprising:
The controller power-on initialization is controlled, the port level that the output module is arranged is the first signal, and by preset Interrupt request configures the counting module;
It determines the need for sending data;
If desired data are sent, then store data to be sent, calculate the check bit of the data to be sent, and start the count module The tally function of block;
Under the timer interrupt control of the counting module, the output module is controlled according to preset baud rate in timing time Next data bit is sent in the case where arrival, realizes that the UART of data is sent with the transmission timing by simulation UART.
5. device according to claim 4, which is characterized in that the control module controls the output module according to default Baud rate timing time arrive in the case where send next data bit, comprising:
Determine the data bit number of data to be sent in default value range present position;
After being adjusted according to port level of the position to the output module or send the corresponding data of corresponding data position, Control the tally function that the data bit number increases automatically or closes the counting module after sending stop bits.
6. device according to claim 5, which is characterized in that the control module is according to the position to the output mould The port level of block is adjusted or sends the corresponding data of corresponding data position, comprising:
If the data bit number is the lower limit of default value range, start bit is sent, i.e., by the port of the output module Level is set to second signal;
If the data bit number is greater than the lower limit of default value range and is less than the upper limit of default value range, according to institute The size order for stating data bit number successively sends each data bit of data to be sent;
If the data bit number is equal to the upper limit of default value range, check bit is sent;
If the data bit number is greater than the upper limit of default value range, stop bits is sent, and by the end of the output module Mouth level is set to the first signal.
7. a kind of controller characterized by comprising the data communication apparatus as described in claim 1-6 is any.
8. a kind of data communication method of controller as claimed in claim 7 characterized by comprising
Data are realized based on the UART receive capabilities of UART module itself as UART receiving module by a UART module UART is received;
By UART sending module, simulates the UART transmission timing of UART module or the UART based on UART module itself is sent Function realizes that the UART of data is sent;
Wherein, the UART sending module, comprising: the resource module of the controller of pending data communication itself, the simulation UART module realizes that the UART of data is sent for simulating the UART transmission timing of UART module;Or another UART module, it should Another UART module realizes that the UART of data is sent for the UART sending function based on UART module itself.
9. according to the method described in claim 8, it is characterized in that, the UART hair for passing through simulation UART module simulation UART module Send timing, comprising:
By output module, the UART sending function of the UART module is simulated, realizes that data are sent;
By counting module, timing is carried out according to setting baud rate scope, obtains timing time;
By control module, the transmission timing of the output module is controlled according to the timing time, realizes the output module Simulate the UART sending function of the UART module.
10. according to the method described in claim 9, it is characterized in that, controlling institute according to the timing time by control module State the transmission timing of output module, comprising:
The controller power-on initialization is controlled, the port level that the output module is arranged is the first signal, and by preset Interrupt request configures the counting module;
It determines the need for sending data;
If desired data are sent, then store data to be sent, calculate the check bit of the data to be sent, and start the count module The tally function of block;
Under the timer interrupt control of the counting module, the output module is controlled according to preset baud rate in timing time Next data bit is sent in the case where arrival, realizes that the UART of data is sent with the transmission timing by simulation UART.
11. according to the method described in claim 10, it is characterized in that, controlling the output module according to pre- by control module If baud rate timing time arrive in the case where send next data bit, comprising:
Determine the data bit number of data to be sent in default value range present position;
After being adjusted according to port level of the position to the output module or send the corresponding data of corresponding data position, Control the tally function that the data bit number increases automatically or closes the counting module after sending stop bits.
12. according to the method for claim 11, which is characterized in that by control module according to the position to the output The port level of module is adjusted or sends the corresponding data of corresponding data position, comprising:
If the data bit number is the lower limit of default value range, start bit is sent, i.e., by the port of the output module Level is set to second signal;
If the data bit number is greater than the lower limit of default value range and is less than the upper limit of default value range, according to institute The size order for stating data bit number successively sends each data bit of data to be sent;
If the data bit number is equal to the upper limit of default value range, check bit is sent;
If the data bit number is greater than the upper limit of default value range, stop bits is sent, and by the end of the output module Mouth level is set to the first signal.
CN201910786640.2A 2019-08-23 2019-08-23 Data communication device, controller and data communication method thereof Active CN110401522B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910786640.2A CN110401522B (en) 2019-08-23 2019-08-23 Data communication device, controller and data communication method thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910786640.2A CN110401522B (en) 2019-08-23 2019-08-23 Data communication device, controller and data communication method thereof

Publications (2)

Publication Number Publication Date
CN110401522A true CN110401522A (en) 2019-11-01
CN110401522B CN110401522B (en) 2020-11-24

Family

ID=68329189

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910786640.2A Active CN110401522B (en) 2019-08-23 2019-08-23 Data communication device, controller and data communication method thereof

Country Status (1)

Country Link
CN (1) CN110401522B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112460748A (en) * 2020-11-23 2021-03-09 珠海格力电器股份有限公司 Communication device and method for internal and external machines and direct-current power supply variable frequency air conditioner
CN112751719A (en) * 2021-02-07 2021-05-04 深圳合芯谷微电子有限公司 Multi-stage series data communication method, system, terminal and storage medium
CN114726494A (en) * 2022-03-04 2022-07-08 深圳拓邦股份有限公司 uart interface circuit, uart communication method and apparatus

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1225212A (en) * 1996-05-08 1999-08-04 艾利森公司 Half duplex uart control for single channel bi-directional wireless communications
US6167078A (en) * 1998-03-30 2000-12-26 Motorola Conservation of power in a serial modem
US20060141946A1 (en) * 2004-12-29 2006-06-29 Rush Frederick A Communication apparatus having a standard serial communication interface compatible with radio isolation
CN104156335A (en) * 2014-08-08 2014-11-19 成都联星微电子有限公司 Method for multiplexing multiple UART interfaces
CN108040059A (en) * 2017-12-18 2018-05-15 唐山松下产业机器有限公司 Data transmission method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1225212A (en) * 1996-05-08 1999-08-04 艾利森公司 Half duplex uart control for single channel bi-directional wireless communications
US6167078A (en) * 1998-03-30 2000-12-26 Motorola Conservation of power in a serial modem
US20060141946A1 (en) * 2004-12-29 2006-06-29 Rush Frederick A Communication apparatus having a standard serial communication interface compatible with radio isolation
CN104156335A (en) * 2014-08-08 2014-11-19 成都联星微电子有限公司 Method for multiplexing multiple UART interfaces
CN108040059A (en) * 2017-12-18 2018-05-15 唐山松下产业机器有限公司 Data transmission method and device

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112460748A (en) * 2020-11-23 2021-03-09 珠海格力电器股份有限公司 Communication device and method for internal and external machines and direct-current power supply variable frequency air conditioner
CN112460748B (en) * 2020-11-23 2021-12-07 珠海格力电器股份有限公司 Communication device and method for internal and external machines and direct-current power supply variable frequency air conditioner
CN112751719A (en) * 2021-02-07 2021-05-04 深圳合芯谷微电子有限公司 Multi-stage series data communication method, system, terminal and storage medium
CN114726494A (en) * 2022-03-04 2022-07-08 深圳拓邦股份有限公司 uart interface circuit, uart communication method and apparatus
CN114726494B (en) * 2022-03-04 2024-03-29 深圳拓邦股份有限公司 UART interface circuit, UART communication method and device

Also Published As

Publication number Publication date
CN110401522B (en) 2020-11-24

Similar Documents

Publication Publication Date Title
CN110401522A (en) A kind of data communication apparatus, controller and its data communication method
CN104566865B (en) Multi-gang air-conditioner and its control method
US6839345B2 (en) MAC/PHY interface
US6356962B1 (en) Network device and method of controlling flow of data arranged in frames in a data-based network
CN104023257B (en) Mobile terminal controls the method and system of television terminal
US20020013821A1 (en) Method and network device for creating buffer structures in shared memory
CN107222777B (en) A kind of set-top box WiFi and Bluetooth coexistence optimization method and device
US20060212633A1 (en) Method and system of routing network-based data using frame address notification
CN104378161B (en) A kind of FCoE agreement accelerating engine IP kernel based on AXI4 bus architecture
EP1014649A2 (en) Method and system of data transfer control
CN108292990A (en) Communication system and communication means
CN103078871A (en) Serial port Ethernet protocol conversion method
CN103885840B (en) FCoE protocol acceleration engine IP core based on AXI4 bus
CN105975424A (en) Master-slave serial communication protocol
CN102053935A (en) MODBUS serial communication protocol-based communication method
CN109684246A (en) The method and system carried out data transmission between the equipment of distinct interface agreement
CN104104412A (en) Direct memory access (DMA) based power line network system and communication method thereof
CN110134421A (en) Electric energy meter managing chip upgrade method, system and electronic equipment and storage medium
CN105094037B (en) Expansion module for the programmable logic controller (PLC) using universal serial bus communications
CN106130856A (en) A kind of self adaptation baud rate RS485 communications protocol
CN103618681A (en) Elastic network bandwidth control method and system thereof
JP4624464B2 (en) System and method for transmitting data
CN106851611A (en) A kind of data is activation and the method and device for receiving
CN209044590U (en) Multiple serial communication switching device
CN109981425A (en) Information transferring method, device, system, terminal, intelligent control end and medium

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
GR01 Patent grant
GR01 Patent grant