CN102117254B - Embedded-system-based asynchronous data receiving method - Google Patents
Embedded-system-based asynchronous data receiving method Download PDFInfo
- Publication number
- CN102117254B CN102117254B CN201110009056XA CN201110009056A CN102117254B CN 102117254 B CN102117254 B CN 102117254B CN 201110009056X A CN201110009056X A CN 201110009056XA CN 201110009056 A CN201110009056 A CN 201110009056A CN 102117254 B CN102117254 B CN 102117254B
- Authority
- CN
- China
- Prior art keywords
- external interrupt
- port
- data
- timer
- host computer
- 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.)
- Active
Links
Images
Landscapes
- Communication Control (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention relates to an embedded-system-based asynchronous data receiving method, which belongs to the field of electronic equipment control. The method comprises the following steps that: a timing interval of a timer is set according to the baud rate of an upper computer; an external interrupt port of a system serves as a data receiver connected with the upper computer, and triggers the external interrupt of the system when receiving a data start bit from the upper computer, the system uses the external interrupt port as an ordinary input/output (I/O) port, and simultaneously the timer starts timing; the system performs sampling on the external interrupt port at a certain time interval, and stores obtained data; and when a data stop bit is obtained from the upper computer in the sampling, the system finishes the external interrupt, the timer stops timing, and the system stops using the external interrupt port as the ordinary I/O port. In the method, asynchronous data reception can be realized simply only by the external interrupt port and the timer.
Description
Technical field:
The present invention relates to a kind of method that realizes the asynchronous reception of data, relate to a kind of method specifically, belong to electronic equipment control field based on the asynchronous reception of Implementation of Embedded System data.
Background technology:
The asynchronous reception of data is a kind of communication mode that is in daily use.Asynchronous communication is when sending signal, and the time interval between the signal that is sent can be arbitrarily.Certainly, receiving end must be carried out the preparation of reception constantly, if the power supply of receiving end main frame does not add that all it is just nonsensical that transmitting terminal sends character so, because receiving end can't receive at all.Transmitting terminal is the proceed-to-send signal character at any time, therefore must add marked at the beginning and the end position of each character, promptly adds start bit and position of rest, so that receiving end can correctly be received each character.The benefit of asynchronous communication is that communication facilities is simple, cheap.
Existing embedded system mainly is the SCI serial communication module that utilizes system's master chip in order to realize the asynchronous reception of data, carries out some simple parameters and sets and realize.But SCI module that this design demand is special or RXD port if system just can't not carry out, receive the restriction ratio of hardware condition bigger.
Summary of the invention:
Technical matters to be solved by this invention overcomes the deficiency of above-mentioned prior art exactly, and a kind of method that realizes the asynchronous reception of data based on the external interrupt port of embedded system is provided.
In order to solve the problems of the technologies described above, the present invention adopts following technical scheme:
A kind of method based on the asynchronous reception of Implementation of Embedded System data comprises the steps,
(1) according to the baud rate of host computer, the timing interval of delta t of setting timer is the inverse of host computer baud rate;
(2) with the external interrupt port of system as the data receiver that is connected with host computer; When it receives the data start bit that host computer sends; The external interrupt of triggering system, system uses the external interrupt port as universaling I/O port, and timer picks up counting simultaneously;
(3) system is every took a sample once from the external interrupt port at a distance from the Δ t time, and the data that obtain was done preservation handle;
(4) when sampling obtains data position of rest that host computer sends, the system finishing external interrupt, timer stops timing, and stops the external interrupt port is used as universaling I/O port.
The invention has the beneficial effects as follows: after using the inventive method,,, just can realize the asynchronous reception of data as long as 1 external interrupt port and 1 timer are arranged even embedded system does not have special SCI module or RXD port.Not only easy, stable, and cost is low, and real-time is good.
Description of drawings:
Fig. 1 is the FB(flow block) of the embodiment of the invention 1;
Fig. 2 is the procedure chart that the inventive method receives 1 frame data.
Embodiment:
(1) according to the baud rate of host computer, the timing interval of delta t of setting timer is the inverse of host computer baud rate, is 9600Hz such as the baud rate of this routine host computer, and Δ t is exactly 1/9600=104 μ s so.
(2) with the external interrupt port of system as the data receiver that is connected with host computer, when it receives the data-signal that host computer sends, the external interrupt of triggering system; System uses the external interrupt port as universaling I/O port; This moment, system carried out analysis and judgement to data-signal, if the data start bit, timer picks up counting so; Otherwise the system finishing external interrupt is external interrupt ports-settings waiting signal.
(3) if the data start bit, system every at a distance from the Δ t time from the sampling of external interrupt port once, and the data that obtain are done to preserve handle.When sampling obtained data position of rest that host computer sends, timer stopped timing, stops the external interrupt port is used as universaling I/O port, and is external interrupt ports-settings waiting signal; When sampling obtain be not host computer send the data position of rest time, timer continues timing.
The process that wherein specifically receives 1 frame data is as shown in Figure 2, supposes totally 11 of frame data, 1 start bit+8 bit data positions+1 bit parity check position+1 position of rest; When the external interrupt port received the data start bit, timer picked up counting, and used the external interrupt port as universaling I/O port; Utilize system delay and use timer every at a distance from 104 μ s timing samplings; Can be accurately take a sample to the high-low level (1 or 0) of input, when sampling obtained data position of rest that host computer sends, timer stopped timing; Stop the external interrupt port is used as universaling I/O port, thus the asynchronous reception of realization data.
Claims (1)
1. method based on the asynchronous reception of Implementation of Embedded System data is characterized in that: comprises the steps,
(1) according to the baud rate of host computer, the timing interval of delta t of setting timer is the inverse of host computer baud rate;
(2) with the external interrupt port of system as the data receiver that is connected with host computer; When it receives the data start bit that host computer sends; The external interrupt of triggering system, system uses the external interrupt port as universaling I/O port, and timer picks up counting simultaneously;
(3) system is every took a sample once from the external interrupt port at a distance from the Δ t time, and the data that obtain was done preservation handle;
(4) when sampling obtains data position of rest that host computer sends, the system finishing external interrupt, timer stops timing, and stops the external interrupt port is used as universaling I/O port.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201110009056XA CN102117254B (en) | 2011-01-17 | 2011-01-17 | Embedded-system-based asynchronous data receiving method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201110009056XA CN102117254B (en) | 2011-01-17 | 2011-01-17 | Embedded-system-based asynchronous data receiving method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102117254A CN102117254A (en) | 2011-07-06 |
CN102117254B true CN102117254B (en) | 2012-11-21 |
Family
ID=44216031
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201110009056XA Active CN102117254B (en) | 2011-01-17 | 2011-01-17 | Embedded-system-based asynchronous data receiving method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102117254B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102521183B (en) * | 2011-12-02 | 2018-01-26 | 深圳市科陆电子科技股份有限公司 | Serial port simulating method for embedded system |
CN113392055B (en) * | 2020-03-13 | 2024-01-30 | 北京小米移动软件有限公司 | File transmission method, file transmission device and storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1762100A (en) * | 2003-03-21 | 2006-04-19 | 汤姆森许可贸易公司 | Oversampling technique to reduce jitter |
CN101371234A (en) * | 2006-01-30 | 2009-02-18 | 汤姆森特许公司 | Data bus interface with interruptible clock |
CN101739376A (en) * | 2008-11-19 | 2010-06-16 | 龙旗科技(上海)有限公司 | General input/output port-based method for realizing USB function of mobile phone |
-
2011
- 2011-01-17 CN CN201110009056XA patent/CN102117254B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1762100A (en) * | 2003-03-21 | 2006-04-19 | 汤姆森许可贸易公司 | Oversampling technique to reduce jitter |
CN101371234A (en) * | 2006-01-30 | 2009-02-18 | 汤姆森特许公司 | Data bus interface with interruptible clock |
CN101739376A (en) * | 2008-11-19 | 2010-06-16 | 龙旗科技(上海)有限公司 | General input/output port-based method for realizing USB function of mobile phone |
Also Published As
Publication number | Publication date |
---|---|
CN102117254A (en) | 2011-07-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN202870808U (en) | FPGA realization device of SPI serial port module | |
CN111277478B (en) | RS485 bus multiplexing control method based on slave devices with different baud rates | |
EP2194460A3 (en) | Information-processing apparatus, information-processing method, and program | |
CN102279248A (en) | Automatic water quality monitoring device | |
CN102117254B (en) | Embedded-system-based asynchronous data receiving method | |
CA2872449A1 (en) | Flow computers having wireless communication protocol interfaces and related methods | |
EP2219308A3 (en) | Method and systems to facilitate reducing interference betweeen rf signals | |
WO2012082816A3 (en) | Fast access asynchronous repeater wakeup protocol | |
CN101902394B (en) | Signal deep-sea long-distance transmission method based on serial communication | |
CN103746789B (en) | Method for realizing high-precision time scales in IEEE-1588 protocol based on CPU universal timer | |
CN201047989Y (en) | Two-wire control device of transmission power source and signal | |
CN101827290B (en) | PCM time slot interchange method capable of directly carrying out voice interchange with voice codec | |
MY184196A (en) | Smart chip and method for smart chip data communications | |
CN104679715A (en) | Simple inter-chip communication method and simple inter-chip communication device | |
CN202372494U (en) | Monitoring system for wirelessly transmitting corrosion data | |
CN105811983A (en) | Multi-loop analog quantity synchronization sampling circuit and sampling method for metering devices | |
CN112597081A (en) | UART software implementation method based on low-voltage Internet of things sensing terminal | |
CN204993338U (en) | Data buffering device based on carrier communication | |
CN201910801U (en) | Circuit for realizing hot-swapping function of optical fiber passage port | |
CN105988541A (en) | Communication resetting method and system for electric energy metering chip | |
CN202956882U (en) | Data acquisition system based on radio frequency communication | |
CN207799427U (en) | Digitized compound operation room remote maintenance system | |
EP2498062A3 (en) | System and Method for Communicating Device Specific Data Over an Advanced Metering Infrastructure (AMI) Network | |
CN205384605U (en) | Meteorological conversion of message ware of civil aviation | |
CN110190868A (en) | Wake-up circuit and IoT device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |