CN102117254A - Embedded-system-based asynchronous data receiving method - Google Patents
Embedded-system-based asynchronous data receiving method Download PDFInfo
- Publication number
- CN102117254A CN102117254A CN 201110009056 CN201110009056A CN102117254A CN 102117254 A CN102117254 A CN 102117254A CN 201110009056 CN201110009056 CN 201110009056 CN 201110009056 A CN201110009056 A CN 201110009056A CN 102117254 A CN102117254 A CN 102117254A
- Authority
- CN
- China
- Prior art keywords
- external interrupt
- data
- port
- 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.)
- Granted
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 mark 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 this design needs special SCI module or RXD port, if system just can't not carry out, is subjected to 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 common I/O mouth, and timer picks up counting simultaneously;
(3) system took a sample once from the external interrupt port every the Δ t time, and the data that obtain are done to preserve processing;
(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 common I/O mouth.
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:
Embodiment 1, and referring to Fig. 1, 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, 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 common I/O mouth, 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 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 common I/O mouth, 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 as shown in Figure 2, suppose 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 receives the data start bit, timer picks up counting, and the external interrupt port used as common I/O mouth, utilize system delay and use timer every 104 μ s timing samplings, can accurately take a sample to the high-low level (1 or 0) of input, when sampling obtains data position of rest that host computer sends, timer stops timing, stops the external interrupt port is used as common I/O mouth, 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 common I/O mouth, and timer picks up counting simultaneously;
(3) system took a sample once from the external interrupt port every the Δ t time, and the data that obtain are done to preserve processing;
(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 common I/O mouth.
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 true CN102117254A (en) | 2011-07-06 |
CN102117254B 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) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102521183A (en) * | 2011-12-02 | 2012-06-27 | 深圳市科陆电子科技股份有限公司 | Serial port simulating method for embedded system |
CN113392055A (en) * | 2020-03-13 | 2021-09-14 | 北京小米移动软件有限公司 | File transfer method, file transfer 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 |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102521183A (en) * | 2011-12-02 | 2012-06-27 | 深圳市科陆电子科技股份有限公司 | Serial port simulating method for embedded system |
CN102521183B (en) * | 2011-12-02 | 2018-01-26 | 深圳市科陆电子科技股份有限公司 | Serial port simulating method for embedded system |
CN113392055A (en) * | 2020-03-13 | 2021-09-14 | 北京小米移动软件有限公司 | File transfer method, file transfer device, and storage medium |
CN113392055B (en) * | 2020-03-13 | 2024-01-30 | 北京小米移动软件有限公司 | File transmission method, file transmission device and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN102117254B (en) | 2012-11-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN202870808U (en) | FPGA realization device of SPI serial port module | |
CN104978291B (en) | One-wire interface Bus Transmit-receive System system and I2C single-wire communication method based on I2C bus protocol | |
CN104978301B (en) | Two-wire differential bus receive-transmit system and I2C two-wire differential communication method based on I2C bus protocol | |
MX2016000500A (en) | Method and device for waking up mcu. | |
TW200715129A (en) | Method and apparatus for data transmission in a wireless communication system and data transmission method | |
CN102722462A (en) | Synchronous communication device and control method thereof | |
CN103678211A (en) | Signal transmission method and device for USB interface | |
CN102117254B (en) | Embedded-system-based asynchronous data receiving method | |
CN101937416A (en) | PS2 (Personal System 2) protocol logic analyzer realized based on FPGA (Field Programmable Gate Array) | |
CN105656591B (en) | The method of data collection synchronous when serial encoder in servo-drive system communicates | |
CN102929830A (en) | Software simulation rapid communication protocol | |
CN201047989Y (en) | Two-wire control device of transmission power source and signal | |
TW201427349A (en) | Synchronizing sequence data transmission method and circuit apparatus | |
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 | |
CN205725785U (en) | A kind of parallel data synchronous acquisition device | |
CN205375789U (en) | Two -way wireless control system is used to low voltage apparatus | |
CN103023610A (en) | Data transmission method and apparatus of 485 interface | |
CN109144937B (en) | High-reliability transmission method for multi-path serial port | |
CN202372494U (en) | Monitoring system for wirelessly transmitting corrosion data | |
CN106375077A (en) | Method of SI4463 chip for realizing data transmission by adopting GPIO mode | |
CN112597081A (en) | UART software implementation method based on low-voltage Internet of things sensing terminal | |
CN105389155A (en) | Method and system for receiving TDM audio data by using SPI interface | |
CN106027192B (en) | A kind of parallel data synchronous acquisition 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 |