CN112597081A - UART software implementation method based on low-voltage Internet of things sensing terminal - Google Patents

UART software implementation method based on low-voltage Internet of things sensing terminal Download PDF

Info

Publication number
CN112597081A
CN112597081A CN202011528247.2A CN202011528247A CN112597081A CN 112597081 A CN112597081 A CN 112597081A CN 202011528247 A CN202011528247 A CN 202011528247A CN 112597081 A CN112597081 A CN 112597081A
Authority
CN
China
Prior art keywords
data
timer
receiving
bit
interrupt
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.)
Withdrawn
Application number
CN202011528247.2A
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.)
Qingdao Topscomm Communication Co Ltd
Original Assignee
Qingdao Topscomm Communication Co Ltd
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 Qingdao Topscomm Communication Co Ltd filed Critical Qingdao Topscomm Communication Co Ltd
Priority to CN202011528247.2A priority Critical patent/CN112597081A/en
Publication of CN112597081A publication Critical patent/CN112597081A/en
Withdrawn 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/14Handling requests for interconnection or transfer
    • G06F13/20Handling requests for interconnection or transfer for access to input/output bus
    • G06F13/24Handling requests for interconnection or transfer for access to input/output bus using interrupt
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0002Serial port, e.g. RS232C

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Communication Control (AREA)

Abstract

The invention discloses a UART software implementation method based on a low-voltage Internet of things sensing terminal, and provides a method for judging sampling grouping for multiple times, wherein sampling analysis is carried out on irregular waveform grouping through different weight coefficients distributed to each group of sampling data, so that the acquisition accuracy of irregular serial port waveforms is greatly improved; the UART communication interface defined by software only needs one timer and two I/O pins, and can complete the receiving and sending of data under the control of the same timer, thereby realizing the full-duplex asynchronous serial port communication mode. The method solves the problems of long transition time and short maintenance time of the waveform change of the serial port of the interactive device in practical application and high error rate of data received by adopting a hardware UART serial port, and has strong engineering practicability.

Description

UART software implementation method based on low-voltage Internet of things sensing terminal
Technical Field
The invention relates to the technical field of serial port communication, in particular to a UART software implementation method based on a low-voltage Internet of things sensing terminal.
Background
The low-voltage internet of things sensing terminal is collection equipment integrating functions of collecting various environmental quantities, collecting switching values, collecting data of an electric energy meter and the like. The product is installed in JP cabinet/join in marriage electrical room, feeder pillar and table case end, mainly undertakes communication function, uploads the data of gathering to intelligent terminal with wireless or carrier wave mode, realizes that the low pressure joins in marriage net (environmental quantity) data real-time supervision.
The invention is applied to the field of low-voltage distribution line automation, and the problems of large error rate and invalid data receiving of universal hardware serial port sampling (twice sampling) are caused by the phenomena of numerous products, uneven quality, long transition time of serial port waveform change and short maintenance time of sampled equipment. Therefore, based on the programmability of the software UART data receiving sampling point, the soft serial port has more flexibility and applicability than the hard serial port in the face of uncontrollable factors of serial port waveforms of the interactive device. A corresponding serial port sampling scheme can be customized according to the serial port waveform of the special mounting equipment; on the other hand, the hardware UART of the main control chip currently used for the low-voltage internet of things sensing terminal is respectively used for realizing bluetooth communication, 485 maintenance, alternate acquisition, carrier communication, TCBUS bus communication, FLASH and communication with an embedded security control module (ESAM), and hard serial port resources are very deficient along with the requirements of expanded products and new functions of services. In view of the above, it is necessary to define the UART serial port by software.
At present, software implementation methods of UART can be roughly divided into two ways: one is to adopt software time delay to carry out bit-by-bit input and output of data frames; the second method is to use MCU internal timer to input and output data frame bit. The software delay mode has high occupancy rate to the MCU in the transmitting or receiving process and low data interaction efficiency, and is not suitable for the field with high real-time requirement of low-voltage distribution line automation; the efficiency is relatively high when the timer mode is used for receiving in interruption, but the overall communication efficiency is still insufficient when the timer mode is used for transmitting (the timer overflow flag bit is continuously judged), and both modes can only carry out half-duplex communication.
Disclosure of Invention
Aiming at the problems, the invention provides a UART software implementation method based on a low-voltage Internet of things sensing terminal, which can realize directional area acquisition on the serial port waveform of the known interactive equipment and improve the accuracy of receiving the non-ideal serial port waveform; the method completely transmits and receives the data in the timer interrupt service, can simultaneously receive and transmit the data, realizes a full-duplex asynchronous serial port communication mode, improves the communication rate and reduces the actual occupancy rate of the MCU.
In order to solve the above problems, an object of the present invention is to provide a software-defined UART implementation method based on a low-voltage internet of things sensing terminal.
The technical scheme adopted by the invention is as follows:
the UART software implementation method based on the low-voltage Internet of things sensing terminal is characterized in that data receiving and sending are carried out in a Timer0, and the Timer0 is responsible for processing two types of interrupts: the method comprises the steps that a timer captures an interrupt and a timer overflow interrupt, wherein the timer captures the interrupt and the timer overflow interrupt, the former is mainly used for starting a data receiving function, the latter is used for receiving and sending data, when a start bit is detected, a timer capture interrupt processing function is entered, a data receiving enabling function and a timer overflow interrupt enabling function are started, the timer overflows and enters a data receiving flow; when data are sent, starting data sending enabling, and entering a data receiving process after a timer to be determined overflows; if neither enable is available, no data is transmitted and received, the no-data transmitting and receiving counter is incremented by one, whether the no-data transmitting and receiving counter is larger than the no-data transmitting and receiving threshold is judged, if yes, the Timer0 is closed and the interruption is quitted, otherwise, the interruption is directly quitted, and if the no-data transmitting and receiving counter is transmitted and received, the counter is reset, so that the effectiveness of the no-data transmitting and receiving counter is ensured.
Further, the method for implementing the UART software based on the low-voltage internet of things sensing terminal includes the following steps:
starting a timer capture function of a receiving pin RXD of a main control chip of the low-voltage Internet of things sensing terminal, configuring the timer capture function into digital level falling edge trigger, and starting a timer to capture interrupt enable;
when the received communication data start bit is at a low level, entering a timer to capture an interrupt processing function; if the initial bit of the received data is high level, continuing monitoring;
after entering a timer capture interrupt processing function, configuring an RXD pin as a general I/O input mode, closing a timer capture interrupt enable, configuring a timer initial value, starting a timer overflow interrupt enable, configuring the RXD pin as an input mode, starting a receiving enable, entering the timer interrupt processing function when the timer overflows, carrying out sampling recording on a serial port level, and completing the receiving of one byte of data after 8n timer interrupts;
and judging the validity of the byte through the check bit, further triggering software interrupt if the valid byte is received, exiting the timer interrupt, and otherwise waiting for the receiving pin RXD to capture the low level again.
Further, in the data receiving method, the interrupt frequency of the timer is n times of the UART communication baud rate, wherein n is a multiple of 3.
Further, the method for determining the timer interrupt received data comprises: the method comprises the steps of sampling a bit length n times, taking 3 times of sampling as 1 group, dividing sampling points into n/3 groups for analysis, and distributing actual waveforms received by a serial port to different groups of weights (i is 0,1, …, n/3-1), wherein in the n times of sampling, if the number of acquired high levels is more than or equal to 2n/3, the current receiving level is determined to be high level, otherwise, if the number of acquired low levels is more than or equal to 2n/3, the current receiving level is determined to be low level.
Further, the specific way of judging the validity of the byte through the check bit is as follows: and realizing an even check function at the UART serial port, comparing the even check output of the data with the even check output of the previous 8-bit data when the data receives the 10 th bit, if the even check output is consistent with the even check output, continuously receiving the next bit, otherwise, discarding the data and restarting the reception of the next frame.
Further, the method for implementing the UART software based on the low-voltage internet of things sensing terminal includes the following steps:
configuring a transmitting pin TXD of a main control chip of the low-voltage Internet of things sensing terminal as an output mode;
storing data to be sent into a sending FIFO buffer queue, and triggering software interruption;
and starting a timer, entering a timer sending interrupt processing function when the timer overflows, and finishing sending one byte of data after 8n interrupts.
Furthermore, the initial value of the timer in the data transmission method is consistent with that of data reception, namely, the timer needs to be started to interrupt for n times when one bit of data is transmitted, wherein n is a multiple of 3, the level is pulled down or pulled up according to a transmission FIFO cache queue when the timing interruption is started for the first time, and meanwhile, the bit transmission counter bit _ tx _ count is assigned to be 0; when the interrupt is entered again, the bit _ tx _ count is added together to keep the level of the serial port unchanged, when the bit _ tx _ count is equal to n, the transmission of one bit of data is completed, and after 8n interrupts, the transmission of one byte of data is completed.
Further, the software interrupt processing specifically includes: firstly, judging whether the current UART is in a transmitting state or a receiving state, and if the UART is in the receiving state, storing received effective byte data into a receiving FIFO buffer queue; if the FIFO buffer queue is in the sending state, judging whether data still exist in the FIFO buffer queue to be sent, if not, directly interrupting the return, and if so, acquiring byte data in the FIFO buffer queue.
The invention has the following beneficial technical effects:
1. the invention also has accurate sampling capability for nonstandard waveforms output by the serial port of the interactive equipment: the invention adopts a method of sampling for many times and judging in groups to judge the current receiving level, thereby improving the accuracy of serial port data receiving in a complex field environment.
2. The data receiving process of the invention judges the initial bit more accurately: after the I/O pin enters the falling edge of the timer to capture interruption, data sampling is further carried out on the start bit, the initial value of the timer is configured to be n times of the serial port baud rate, namely n times of sampling is carried out on the start bit, and the accuracy of start bit identification is ensured through double detection of the falling edge interruption of the timer and the interruption of the timer on the start bit.
3. The data receiving and transmitting processes are carried out in the timer interruption process, one bit of data is transmitted/received according to the n times of timer overflow interruption, so that full duplex communication is realized, the data receiving and transmitting efficiency is improved, the occupancy rate of a low-voltage Internet of things sensing terminal MCU is reduced, and the timer is closed when the data receiving and transmitting cannot be detected within a period of time, so that the waste of system resources under the condition of no data interaction is avoided.
Drawings
FIG. 1 is a general flow diagram of the present invention;
FIG. 2 is a flow chart of data reception in the present invention;
FIG. 3 is a flow chart of data transmission in the present invention;
FIG. 4 is a data receiving flow in the timer interrupt processing flow according to the present invention;
FIG. 5 is a data transmission flow in the timer interrupt processing flow according to the present invention;
FIG. 6 illustrates the software interrupt handling steps of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the invention.
As shown in FIG. 1, the UART software implementation method based on the low-voltage IOT sensing terminal only needs one timer, two I/O pins and one software interrupt.
The interrupt processing of the Timer0 includes a Timer capture interrupt mainly used for starting a data receiving function and a Timer overflow interrupt used for receiving and transmitting data. In the timer capture interrupt processing, an RXD pin is configured into a falling edge trigger mode, and the receiving of a start bit is monitored in real time; in the timer overflow interruption process, if the data sending function is enabled, entering a data sending process; if the data receiving function is enabled, entering a data receiving flow; if neither enable is available, the data receiving and sending is not available, the no-data receiving and sending counter is increased by one, whether the no-data receiving and sending counter is larger than the no-data receiving and sending threshold value or not is judged, if yes, the timer is closed, the interruption is quitted, and if not, the interruption is directly quitted. If data are received and transmitted in the counting process of the no-data receiving and transmitting counter, the counter is reset, and the effectiveness of the no-data receiving and transmitting counter is guaranteed.
The data receiving process is shown in fig. 2, and includes the following steps:
configuring a timer capture function of a low-voltage Internet of things sensing terminal main control chip for receiving a pin RXD, starting interrupt enabling of the pin, detecting a start bit when data exist, and immediately generating interrupt when the start bit is at a low level;
entering timer capture interrupt processing, firstly closing the timer capture interrupt enable, configuring an RXD pin to be in a common I/O receiving mode, enabling the timer to overflow and interrupt, starting the data receiving enable, starting the timer to wait for the timer to overflow, and starting data receiving;
entering timer overflow interrupt processing, storing received data into byte data, further judging the validity of a start bit, a check bit and a stop bit, if a valid byte is received, setting a receiving flag bit to be valid, further triggering software to interrupt and exit the timer interrupt, otherwise, configuring a receiving pin of a main control chip of the low-voltage IOT sensing terminal;
and entering software interrupt processing, firstly judging whether the receiving flag bit is valid, if so, clearing the valid state flag, and storing the received byte data into a receiving FIFO (first in first out) buffer queue.
The data transmission method is shown in fig. 3, and includes the following steps:
configuring a transmitting pin TXD of a main control chip of the low-voltage Internet of things sensing terminal into a common I/O output mode, wherein the TXD pin must keep a high level in an idle state;
when data is transmitted, storing the data to be transmitted into a transmission FIFO buffer queue, setting a transmission flag bit to be in an effective state, and triggering software interruption;
and entering software interrupt processing, judging whether the sending flag bit is valid, if so, clearing the sending valid state flag, and acquiring byte data in the sending FIFO buffer queue.
Enabling the timer to overflow and interrupt, starting the timer, entering the timer overflow interrupt processing when the timer to be overflowed, sending byte data according to the position, setting a sending mark to be in an effective state after the byte sending is finished, and triggering software interrupt.
Specifically, as shown in fig. 4, the flow of data reception in the timer overflow interrupt processing step is as follows:
step 1:
entering a data receiving flow, resetting the no-data transceiving counter, judging whether the timer overflows or not, and jumping to the step 2 if the timer overflows;
step 2:
the timer overflows, the current receiving step is judged through a receiving counter, if the receiving counter is equal to 0, the receiving counter is in a receiving initial position link, and the step 3 is skipped; if the receiving counter is equal to 1, the step is in a data bit receiving link, and the step 4 is skipped; if the receiving counter is equal to 2, the receiving counter is in a receiving check bit link, and the step 5 is skipped; if the receiving counter is equal to 3, the receiving stop bit link is positioned, and the step 6 is skipped;
and step 3:
receiving a start bit, reading the current state of an RXD pin, setting the initial value of a timer to be one bit length (the reciprocal of a baud rate) to enter the level of the start bit for n times of interrupt acquisition, wherein n is an integral multiple of 3, sampling the serial port level once in each interrupt, and judging the proportion of low level to total sampling times in n times of sampling to judge whether the start bit is effective (low level is effective and high level is ineffective); for the situation that a serial port nonstandard waveform appears in practical application, for example, the jump from low level to high level (rising edge) and the jump from slow high level to low level (falling edge) are normal, the effective high and low levels may only occupy 1/3 with one bit duration, so that the error rate is extremely high by adopting the same judgment method of sampling for 3 times and sampling for 2 times universally; the invention provides a method for judging multiple sampling groups on the premise of known serial port waveforms, which solves the problems, assigns n according to the actual serial port waveforms on site, samples a bit length for n times, analyzes the bit length into n/3 groups by taking 3 times of sampling as 1 group, and distributes the bit length to n/3 groups of different weights (i is 0,1, …, n/3-1) according to the actual waveforms received by the serial port, wherein the level is judged to be the current receiving level when the sampling times of the same level in the n times of sampling is more than 2/3 of the total number of effective samples, and the samples with the weight of 1 are marked as effective samples.
If the start bit is valid, assigning the value of a receiving counter as 1, skipping to the step 4, resetting a data receiving variable, preparing for storing the data bit in the step 4, and exiting;
if the start bit is invalid, jumping to step 7;
and 4, step 4:
receiving data bits, interrupting acquisition of the current RXD pin state according to timer overflow without changing an initial value of a timer, realizing acquisition of one bit data through n times of interruption as same as the acquisition of the initial bit in the step 3, storing the data bits into data receiving variables according to the bits, adding one to the number of the data bit bits acquired each time, and judging whether the number of the data bit receiving numbers is equal to 8 or not;
the data bit receiving number is equal to 8, the data bit receiving is finished, then the check bit is ready to be received, the receiving counter is assigned to be 2, and the process is exited;
the data bit receiving number is not equal to 8, which indicates that the data bit is not received completely, the next data bit is continuously received, and the operation is exited;
and 5:
receiving a check bit, acquiring the current RXD pin state, storing the current RXD pin state into a received check bit variable according to bits, comparing the received check bit variable with the output result of the even check function input by the data receiving variable, if the received check bit variable and the data receiving variable are consistent, the check bit is valid, and assigning the value of a receiving counter to be 3 and exiting;
if the check bit is invalid, discarding the data, and skipping to the step 7;
step 6:
receiving a stop bit, acquiring the current RXD pin state, storing the current RXD pin state into a receiving stop bit variable according to bits, and judging whether the stop bit is effective or not;
if the stop bit is effective, the receiving flag bit is set to be effective, a timer capture function of an RXD pin is started, a falling edge is configured to trigger starting of an interrupt enable, data receiving is continuously monitored, software interrupt is triggered, and exit is carried out;
if the stop bit is invalid, jumping to step 7;
and 7:
and exiting the data receiving process, starting a timer capturing function of an RXD pin, configuring to trigger a falling edge to start interrupt enabling, monitoring the received data again, and exiting.
Specifically, as shown in fig. 5, the flow of data transmission in the timer interrupt processing step is as follows:
step 1:
entering a data sending flow, resetting the no-data transceiving counter, judging whether the timer overflows or not, and jumping to the step 2 if the timer overflows;
step 2:
the timer overflows, the current receiving step is judged through a sending counter, if the sending counter is equal to 0, the receiving step is in a sending start bit link, and the step 3 is skipped; if the sending counter is equal to 1, the step is in a data bit sending link, and the step 4 is skipped; if the sending counter is equal to 2, the step is in a check bit sending link, and the step 5 is skipped; if the sending counter is equal to 3, the step is in a sending stop bit link, and the step 6 is skipped;
and step 3:
sending a start bit, controlling a TXD pin to output a low level, keeping the initial value of the timer consistent with that of data receiving during data sending, namely, entering the timer to interrupt for n times when sending one bit of data, wherein n is a multiple of 3, pulling the level down or high according to a sending FIFO buffer queue when the data enters the interrupt for the first time, and simultaneously assigning a bit sending counter bit _ tx _ count to be 0; when the interrupt is entered again, adding the bit _ tx _ count and keeping the level of the serial port unchanged, finishing sending one bit of data when the bit _ tx _ count is equal to n, assigning a sending counter to be 1, clearing the bit _ tx _ count, and exiting;
and 4, step 4:
sending data bits, wherein the configuration of the data bits is the same as that of a sending start bit, a timer needs to be started for interruption for n times when one bit of data is sent, the sending number of the data bits is reset by adding one bit _ tx _ count when one data bit of data is sent according to the corresponding high and low levels in the TXD base pin output data sending variable, and whether the sending number of the data bits is equal to 8 is judged;
the data bit sending number is equal to 8, the data bit sending is finished, then the check bit is ready to be sent, the sending counter is assigned to be 2, and the operation is quitted;
the data bit sending number is not equal to 8, which indicates that the data bit is not sent completely, the next data bit is sent continuously, and the operation is exited;
and 5:
transmitting a check bit, inputting a data transmission variable into the even check function to obtain an output result, taking the output result as the transmission check bit, controlling the TXD pin to output a corresponding high level and a corresponding low level, and resetting the bit _ tx _ count after the transmission is finished (after the timer is interrupted for n times);
step 6:
and sending a stop bit, outputting a high level according to a TXD pin of the timer interrupt control, clearing a bit _ tx _ count (after n times of interrupt of the timer) after sending is finished, setting a sending completion flag bit to be effective, triggering software interrupt, and exiting.
Specifically, the software interrupt processing, as shown in fig. 6, performs the following steps:
judging whether the receiving flag bit is valid, if the receiving flag bit is valid, indicating that the data of the complete byte is received, clearing the receiving flag bit, and storing the value of the data receiving variable in a receiving FIFO buffer queue;
judging whether the sending zone bit is effective, if the sending zone bit is effective, indicating that one byte of data is sent, clearing the sending zone bit, and judging whether the sending FIFO buffer queue has data to send;
sending data to be sent in a FIFO (first in first out) buffer queue, acquiring byte data in the FIFO buffer queue to be assigned to a data sending variable, judging whether a timer is started or not, starting the timer if the timer is not started, clearing 0 of a data-free receiving and sending counter, and starting a data sending process step 3 to send a start bit;
and no data is to be sent in the transmission FIFO buffer queue, and the interruption exits.
The above-mentioned embodiments are illustrative of the specific embodiments of the present invention, and are not restrictive, and those skilled in the relevant art can make various changes and modifications to obtain corresponding equivalent technical solutions without departing from the spirit and scope of the present invention, so that all equivalent technical solutions should be included in the scope of the present invention.

Claims (8)

1. The UART software implementation method based on the low-voltage Internet of things sensing terminal is characterized in that data receiving and sending are carried out in a Timer0, and the Timer0 is responsible for processing two types of interrupts: the method comprises the steps that a timer captures an interrupt and a timer overflow interrupt, wherein the timer captures the interrupt and the timer overflow interrupt, the former is mainly used for starting a data receiving function, the latter is used for receiving and sending data, when a start bit is detected, a timer capture interrupt processing function is entered, a data receiving enabling function and a timer overflow interrupt enabling function are started, the timer overflows and enters a data receiving flow; when data are sent, starting data sending enabling, and entering a data receiving process after a timer to be determined overflows; if neither enable is available, no data is transmitted and received, the no-data transmitting and receiving counter is incremented by one, whether the no-data transmitting and receiving counter is larger than the no-data transmitting and receiving threshold is judged, if yes, the Timer0 is closed and the interruption is quitted, otherwise, the interruption is directly quitted, and if the no-data transmitting and receiving counter is transmitted and received, the counter is reset, so that the effectiveness of the no-data transmitting and receiving counter is ensured.
2. The UART software implementation method based on the low-voltage IOT sensing terminal according to claim 1, wherein the data receiving method comprises the following steps:
starting a timer capture function of a receiving pin RXD of a main control chip of the low-voltage Internet of things sensing terminal, configuring the timer capture function into digital level falling edge trigger, and starting a timer to capture interrupt enable;
when the received communication data start bit is at a low level, entering a timer to capture an interrupt processing function; if the initial bit of the received data is high level, continuing monitoring;
after entering a timer capture interrupt processing function, configuring an RXD pin as a general I/O input mode, closing a timer capture interrupt enable, configuring a timer initial value, starting a timer overflow interrupt enable, configuring the RXD pin as an input mode, starting a receiving enable, entering the timer interrupt processing function when the timer overflows, carrying out sampling recording on a serial port level, and completing the receiving of one byte of data after 8n timer interrupts;
and judging the validity of the byte through the check bit, further triggering software interrupt if the valid byte is received, exiting the timer interrupt, and otherwise waiting for the receiving pin RXD to capture the low level again.
3. The UART software implementation method based on the low-voltage IOT sensing terminal as claimed in claim 2, wherein the interrupt frequency of the timer in the data receiving method is n times of the UART communication baud rate, wherein n is a multiple of 3.
4. The UART software implementation method based on the low-voltage IOT sensing terminal as claimed in claim 2, wherein the level determination method for the timed interrupt received data is as follows: n times sampling is carried out on one bit length, 3 times sampling is taken as 1 group, sampling points are divided into n/3 groups for analysis, and different weight omega are distributed to each group according to actual waveforms received by the serial porti(i ═ 0,1, …, n/3-1), where ω isi∈[0,1]In the n times of sampling, if the acquired number of times of the high level is greater than or equal to 2n/3, the current receiving level is determined to be the high level, and if the acquired number of times of the low level is greater than or equal to 2n/3, the current receiving level is determined to be the low level.
5. The UART software implementation method based on the low-voltage IOT sensing terminal as claimed in claim 2, wherein the specific way of judging the validity of the bytes by the check bits is as follows: and realizing an even check function at the UART serial port, comparing the even check output of the data with the even check output of the previous 8-bit data when the data receives the 10 th bit, if the even check output is consistent with the even check output, continuously receiving the next bit, otherwise, discarding the data and restarting the reception of the next frame.
6. The UART software implementation method based on the low-voltage IOT sensing terminal according to claim 1, wherein the data transmission method comprises the following steps:
configuring a transmitting pin TXD of a main control chip of the low-voltage Internet of things sensing terminal as an output mode;
storing data to be sent into a sending FIFO buffer queue, and triggering software interruption;
and starting a timer, entering a timer sending interrupt processing function when the timer overflows, and finishing sending one byte of data after 8n interrupts.
7. The UART software implementation method based on the low-voltage IOT sensing terminal according to claim 6, characterized in that the initial value of the timer in the data transmission method is kept consistent with that of the data reception, i.e. the timer needs to be started to interrupt for n times when transmitting one bit of data, wherein n is a multiple of 3, the level is pulled down or pulled up according to the transmission FIFO buffer queue when the timer interrupt is started for the first time, and meanwhile, the bit transmission counter bit _ tx _ count is assigned to 0; when the interrupt is entered again, the bit _ tx _ count is added together to keep the level of the serial port unchanged, when the bit _ tx _ count is equal to n, the transmission of one bit of data is completed, and after 8n interrupts, the transmission of one byte of data is completed.
8. The UART software implementation method based on the low-voltage IOT sensing terminal according to claim 2 or 6, wherein the software interrupt processing specifically comprises: firstly, judging whether the current UART is in a transmitting state or a receiving state, and if the UART is in the receiving state, storing received effective byte data into a receiving FIFO buffer queue; if the FIFO buffer queue is in the sending state, judging whether data still exist in the FIFO buffer queue to be sent, if not, directly interrupting the return, and if so, acquiring byte data in the FIFO buffer queue.
CN202011528247.2A 2020-12-22 2020-12-22 UART software implementation method based on low-voltage Internet of things sensing terminal Withdrawn CN112597081A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011528247.2A CN112597081A (en) 2020-12-22 2020-12-22 UART software implementation method based on low-voltage Internet of things sensing terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011528247.2A CN112597081A (en) 2020-12-22 2020-12-22 UART software implementation method based on low-voltage Internet of things sensing terminal

Publications (1)

Publication Number Publication Date
CN112597081A true CN112597081A (en) 2021-04-02

Family

ID=75200093

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011528247.2A Withdrawn CN112597081A (en) 2020-12-22 2020-12-22 UART software implementation method based on low-voltage Internet of things sensing terminal

Country Status (1)

Country Link
CN (1) CN112597081A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113064845A (en) * 2021-04-28 2021-07-02 晶澄微电子(宁波)有限公司 Method for realizing single-wire communication with anti-counterfeiting security chip

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101471787A (en) * 2007-12-25 2009-07-01 希姆通信息技术(上海)有限公司 Method for software simulation UART based on wireless communication module
CN102521183A (en) * 2011-12-02 2012-06-27 深圳市科陆电子科技股份有限公司 Serial port simulating method for embedded system
CN102546843A (en) * 2012-01-17 2012-07-04 厦门雅迅网络股份有限公司 Method for achieving UART (universal asynchronous receiver/transmitter) communication interfaces through software simulation
CN103699509A (en) * 2014-01-03 2014-04-02 烟台东方威思顿电气有限公司 Timer waveform recording based serial communication method
CN109101453A (en) * 2018-06-29 2018-12-28 北京广利核系统工程有限公司 asynchronous serial communication sampling system and method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101471787A (en) * 2007-12-25 2009-07-01 希姆通信息技术(上海)有限公司 Method for software simulation UART based on wireless communication module
CN102521183A (en) * 2011-12-02 2012-06-27 深圳市科陆电子科技股份有限公司 Serial port simulating method for embedded system
CN102546843A (en) * 2012-01-17 2012-07-04 厦门雅迅网络股份有限公司 Method for achieving UART (universal asynchronous receiver/transmitter) communication interfaces through software simulation
CN103699509A (en) * 2014-01-03 2014-04-02 烟台东方威思顿电气有限公司 Timer waveform recording based serial communication method
CN109101453A (en) * 2018-06-29 2018-12-28 北京广利核系统工程有限公司 asynchronous serial communication sampling system and method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113064845A (en) * 2021-04-28 2021-07-02 晶澄微电子(宁波)有限公司 Method for realizing single-wire communication with anti-counterfeiting security chip

Similar Documents

Publication Publication Date Title
CN101620551B (en) Network card interrupt control method for a plurality of virtual machines
CN104461972B (en) A kind of method and apparatus of data signal samples
JPWO2011040006A1 (en) Transmission device, reception device, transmission / reception system, and transmission / reception method
CN110910629B (en) Infrared remote control signal decoding method and system based on single chip microcomputer and metering device
CN105959093B (en) A kind of serial communication baud rate real-time adaptive method
CN102811176B (en) A kind of data flow control method and device
CN111585836A (en) Network testing method and device
CN109062847A (en) System on chip, IP kernel and its control method for RS485 serial communication
CN112597081A (en) UART software implementation method based on low-voltage Internet of things sensing terminal
CN104035901A (en) TTCAN bus timing and data transmitting method
CN108833366B (en) Control frame compression method based on AS6802 protocol
CN110798386B (en) Configurable CAN bus protocol transceiving test method and system
CN102164077B (en) Bandwidth control method, device and router
CN102368729B (en) Accurate network speed limit method at non-realtime system
CN203574663U (en) Automatic baud rate detection module
CN106352911B (en) Realize that the single of multichannel low frequency pick-up signal acquisition interrupts CPU verification systems and calibrating acquisition method
CN113032320A (en) Asynchronous serial port communication baud rate self-adaption method
CN112118083A (en) Single-wire half-duplex communication method, communication device and equipment
CN103036804B (en) The method and system of net control uploading speed
Boggs et al. Measured capacity of an ethernet: myths and reality
CN102355376B (en) Traffic monitoring method and device
CN107332682B (en) A kind of measurement method and device of service rate
CN103986622A (en) Network throughput rate parallelized measuring method based on multi-core technology
CN103455461B (en) For the method improving RS485 bus communication reliability
CN103973582A (en) Testing data stream transmission flow control method and system

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
WW01 Invention patent application withdrawn after publication

Application publication date: 20210402

WW01 Invention patent application withdrawn after publication