CN109542811A - A kind of data communication processing method - Google Patents
A kind of data communication processing method Download PDFInfo
- Publication number
- CN109542811A CN109542811A CN201811193759.0A CN201811193759A CN109542811A CN 109542811 A CN109542811 A CN 109542811A CN 201811193759 A CN201811193759 A CN 201811193759A CN 109542811 A CN109542811 A CN 109542811A
- Authority
- CN
- China
- Prior art keywords
- dma
- traps
- data
- buffering area
- cpu
- 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
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/14—Handling requests for interconnection or transfer
- G06F13/20—Handling requests for interconnection or transfer for access to input/output bus
- G06F13/28—Handling requests for interconnection or transfer for access to input/output bus using burst mode transfer, e.g. direct memory access DMA, cycle steal
- G06F13/285—Halt processor DMA
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Communication Control (AREA)
- Information Transfer Systems (AREA)
- Bus Control (AREA)
Abstract
Technical solution of the present invention includes a kind of data communication processing method, a large amount of, real-time data communication is realized based on DMA double buffering combination traps, in program of breaking in the dma, it only executes the destination address of switching DMA channel and triggers the operation of traps, carry out the carrying operation of data again in traps program, and DMA interruption just will lead to CPU interruption, traps not will lead to CPU interruption, therefore it is smaller to interrupt expense by DMA, lesser cpu resource can be occupied when CPU has a lot of work to do as far as possible, has stronger advantage in resource scarcity, the system having a lot of work to do.
Description
Technical field
The present invention relates to a kind of data communication processing methods, belong to data communication technology field.
Background technique
Now, in embedded systems, the task that MCU undertakes is more and more, and the speed of communication data interface is getting faster,
Therefore communication bring burden is also increasingly heavier.It is more to occupy processor in the case where full load communicates for the communication interface of MCU
Resource and be easy to cause communication data to lose.
The problem of although traditional DMA double-buffered data is able to solve loss of data, but when the amount of data is large, DMA
It is more that data time-consuming is carried when interruption, it will occupy the more resource of processor, make it difficult to meet that system resource is in short supply, task is numerous
More data communication requirements.
Summary of the invention
To solve the above problems, this method is based on DMA the purpose of the present invention is to provide a kind of data communication processing method
Double buffering combination traps realize a large amount of, real-time data communication, in program of breaking in the dma, only switch the destination address of DMA channel
And triggering traps, carry out the carrying of data again in traps program, and DMA interruption just will lead to CPU interruption, traps
It not will lead to CPU interruption, therefore DMA interruption expense is smaller, can occupy lesser cpu resource when CPU has a lot of work to do as far as possible,
There is stronger advantage in resource scarcity, the system having a lot of work to do.
Technical solution used by the present invention solves the problems, such as it is: a kind of data communication processing method, is based on DMA double buffering
In conjunction with traps realize MCU and peripheral hardware data communication, the MCU include serial ports, FIFO memory, dma controller, memory and
CPU;Include the following steps:
S1, serial ports DMA reception pattern is opened, configure FIFO memory and its reception threshold value is set;
S2, two receptions buffer areas, respectively first buffering area and second buffering area are opened up in memory;
S3, initialization dma controller, configure the DMA channel between peripheral hardware and memory, the source address that DMA channel is arranged is
The address data memory of peripheral hardware;
S4, the address that the destination address that DMA channel is arranged is first buffering area, and enabled DMA channel receives data;
S5, DMA interruption is generated when the received data capacity of first buffering area reaches buffer pool size threshold value, CPU is executed
The destination address of DMA channel is switched to the address of second buffering area by DMA interrupt routine, and enabled DMA channel receives data,
The first traps are triggered simultaneously;
S6, in the first traps program, the data of first buffering area are transferred to it in FIFO memory by dma controller
Backed off after random the first traps program simultaneously returns to main program, handles the data in FIFO memory by CPU;
S7, DMA interruption is generated when the received data capacity of second buffering area reaches buffer pool size threshold value, CPU is executed
The destination address of DMA channel is switched to the address of first buffering area by DMA interrupt routine, and enabled DMA channel receives data,
The second traps are triggered simultaneously;
S8, in the second traps program, the data of second buffering area are transferred to it in FIFO memory by dma controller
Backed off after random the second traps program simultaneously returns to main program, handles the data in FIFO memory by CPU;
S9, circulation execute step S5-S8, until communication terminates.
Further, the buffer pool size threshold value of the first buffering area and second buffering area is equal.
Further, the DMA interrupts the hard break generated for peripheral hardware, and first traps and the second traps are MCU
The traps that process generates.
Further, the priority that the DMA is interrupted is higher than the priority of first traps and the second traps.
Further, the FIFO memory include a fifo controller, the fifo controller have a reading pointer and
One write-in pointer, when dma controller is read out FIFO memory or when write activity, fifo controller accordingly changes this
The value of reading pointer or the write-in pointer.
Further, the fifo controller reads or is written every time the data that FIFO memory receives threshold value.
The beneficial effects of the present invention are: a kind of data communication processing method that the present invention uses, is combined based on DMA double buffering
Traps realize a large amount of, real-time data communication, in program of breaking in the dma, only execute destination address and the touching of switching DMA channel
Feel like jelly the operation of interruption, carries out the carrying operation of data again in traps program, and DMA interruption just will lead to CPU and interrupt, it is soft
Interruption not will lead to CPU interruption, therefore DMA interruption expense is smaller, can occupy lesser CPU when CPU has a lot of work to do as far as possible
Resource has stronger advantage in resource scarcity, the system having a lot of work to do.
Detailed description of the invention
Fig. 1 is the data flow block diagram of embodiment of the disclosure;
Fig. 2 is the basic steps flow chart of embodiment of the disclosure;
Fig. 3 is a kind of specific implementation block diagram of embodiment of the disclosure.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, right in the following with reference to the drawings and specific embodiments
The present invention is described in detail.Data communication processing method of the invention is suitable for the number of resource scarcity, the system having a lot of work to do
According to real-time communication.
- Fig. 3 referring to Fig.1, a kind of data communication processing method of the invention are realized based on DMA double buffering combination traps
The data communication of MCU and peripheral hardware, MCU therein include serial ports, FIFO memory, dma controller, memory and CPU, data flow
To as shown in Figure 1, passing through data bus transmission data between the memory and peripheral hardware of MCU;As shown in Fig. 2, including the following steps:
S1, serial ports DMA reception pattern is opened, configure FIFO memory and its reception threshold value is set;
S2, two receptions buffer areas, respectively first buffering area and second buffering area are opened up in memory;
S3, initialization dma controller, configure the DMA channel between peripheral hardware and memory, the source address that DMA channel is arranged is
The address data memory of peripheral hardware;
S4, the address that the destination address that DMA channel is arranged is first buffering area, and enabled DMA channel receives data;
S5, DMA interruption is generated when the received data capacity of first buffering area reaches buffer pool size threshold value, CPU is executed
The destination address of DMA channel is switched to the address of second buffering area by DMA interrupt routine, and enabled DMA channel receives data,
The first traps are triggered simultaneously;
S6, in the first traps program, the data of first buffering area are transferred to it in FIFO memory by dma controller
Backed off after random the first traps program simultaneously returns to main program, handles the data in FIFO memory by CPU;
S7, DMA interruption is generated when the received data capacity of second buffering area reaches buffer pool size threshold value, CPU is executed
The destination address of DMA channel is switched to the address of first buffering area by DMA interrupt routine, and enabled DMA channel receives data,
The second traps are triggered simultaneously;
S8, in the second traps program, the data of second buffering area are transferred to it in FIFO memory by dma controller
Backed off after random the second traps program simultaneously returns to main program, handles the data in FIFO memory by CPU;
S9, circulation execute step S5-S8, until communication terminates.
Further, the buffer pool size threshold value of first buffering area and second buffering area therein is equal.
Further, DMA therein interrupts the hard break generated for peripheral hardware, and the first traps and the second traps therein are
The traps that MCU process generates.
Further, the priority that DMA therein is interrupted is higher than the priority of the first traps and the second traps therein.
First traps and the second traps can be interrupted by other DMA and be interrupted, so that system is to receive requirement of real-time higher
It is handled in time when transactions requests.
Further, FIFO memory therein includes a fifo controller, and there is fifo controller therein a reading to refer to
Needle and a write-in pointer, when dma controller is read out FIFO memory or when write activity, fifo controller accordingly changes
Become the value of the reading pointer or the write-in pointer.
Further, fifo controller therein reads or is written every time the data that FIFO memory receives threshold value.
It not up to receives threshold value when FIFO memory receives data and does not receive new data within a preset period of time,
Fifo controller reads or is written existing total data.
As shown in figure 3, serial ports is configured to DMA reception pattern, the first buffering of setting by taking STM32F103RCT6 chip as an example
Area and second buffering area capacity threshold are 512 bytes, and DMA interrupt routine executes destination address and the triggering of switching DMA channel
Traps, traps program, which is executed, carries data from first buffering area or second buffering area to FIFO memory.
The above, only presently preferred embodiments of the present invention, the invention is not limited to above embodiment, as long as
It reaches technical effect of the invention with identical means, all should belong to protection scope of the present invention.In protection model of the invention
Its technical solution and/or embodiment can have a variety of different modifications and variations in enclosing.
Claims (6)
1. a kind of data communication processing method realizes the data communication of MCU and peripheral hardware, institute based on DMA double buffering combination traps
Stating MCU includes serial ports, FIFO memory, dma controller, memory and CPU;It is characterized by comprising the following steps:
S1, serial ports DMA reception pattern is opened, configure FIFO memory and its reception threshold value is set;
S2, two receptions buffer areas, respectively first buffering area and second buffering area are opened up in memory;
S3, initialization dma controller, configure the DMA channel between peripheral hardware and memory, and the source address that DMA channel is arranged is peripheral hardware
Address data memory;
S4, the address that the destination address that DMA channel is arranged is first buffering area, and enabled DMA channel receives data;
S5, DMA interruption is generated when the received data capacity of first buffering area reaches buffer pool size threshold value, CPU is executed in DMA
The destination address of DMA channel is switched to the address of second buffering area by disconnected program, and enabled DMA channel receives data, touches simultaneously
Send out the first traps;
S6, in the first traps program, the data of first buffering area are transferred to the retrogressing in FIFO memory by dma controller
The first traps program and main program is returned to out, passes through CPU and handle data in FIFO memory;
S7, DMA interruption is generated when the received data capacity of second buffering area reaches buffer pool size threshold value, CPU is executed in DMA
The destination address of DMA channel is switched to the address of first buffering area by disconnected program, and enabled DMA channel receives data, touches simultaneously
Send out the second traps;
S8, in the second traps program, the data of second buffering area are transferred to the retrogressing in FIFO memory by dma controller
The second traps program and main program is returned to out, passes through CPU and handle data in FIFO memory;
S9, circulation execute step S5-S8, until communication terminates.
2. data communication processing method according to claim 1, it is characterised in that: the first buffering area and the second buffering
The buffer pool size threshold value in area is equal.
3. data communication processing method according to claim 1, it is characterised in that: it is what peripheral hardware generated that the DMA, which is interrupted,
Hard break, first traps and the second traps are the traps that MCU process generates.
4. data communication processing method according to claim 1, it is characterised in that: the priority that the DMA is interrupted is higher than
The priority of first traps and the second traps.
5. data communication processing method according to claim 1, it is characterised in that: the FIFO memory includes a FIFO
Controller, the fifo controller has a reading pointer and a write-in pointer, when dma controller reads FIFO memory
It takes or when write activity, fifo controller accordingly changes the value of the reading pointer or the write-in pointer.
6. data communication processing method according to claim 5, it is characterised in that: the fifo controller read every time or
The data that FIFO memory receives threshold value are written.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811193759.0A CN109542811B (en) | 2018-10-15 | 2018-10-15 | Data communication processing method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811193759.0A CN109542811B (en) | 2018-10-15 | 2018-10-15 | Data communication processing method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109542811A true CN109542811A (en) | 2019-03-29 |
CN109542811B CN109542811B (en) | 2021-12-07 |
Family
ID=65843772
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811193759.0A Active CN109542811B (en) | 2018-10-15 | 2018-10-15 | Data communication processing method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109542811B (en) |
Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040187122A1 (en) * | 2003-02-18 | 2004-09-23 | Microsoft Corporation | Systems and methods for enhancing performance of a coprocessor |
CN101441271A (en) * | 2008-12-05 | 2009-05-27 | 航天恒星科技有限公司 | SAR real time imaging processing device based on GPU |
US20120159015A1 (en) * | 2010-12-15 | 2012-06-21 | Electronic And Telecommunications Research Institute | Direct memory access controller and operating method thereof |
CN102541780A (en) * | 2011-12-15 | 2012-07-04 | 苏州国芯科技有限公司 | Multi-data stream channel DMA (Direct Memory Access) system |
US20120246352A1 (en) * | 2011-03-24 | 2012-09-27 | Kil-Yeon Lim | Data processing systems for audio signals and methods of operating same |
CN102831091A (en) * | 2012-07-31 | 2012-12-19 | 宁波成电泰克电子信息技术发展有限公司 | Serial port-based ship radar echo data collecting method |
CN102866971A (en) * | 2012-08-28 | 2013-01-09 | 华为技术有限公司 | Data transmission device, system and method |
CN103049336A (en) * | 2013-01-06 | 2013-04-17 | 浪潮电子信息产业股份有限公司 | Hash-based network card soft interrupt and load balancing method |
WO2017212524A1 (en) * | 2016-06-06 | 2017-12-14 | オリンパス株式会社 | Data transfer device, image processing device, and image pickup device |
CN108227572A (en) * | 2017-12-21 | 2018-06-29 | 中国船舶重工集团公司第七0七研究所 | A kind of serial data recording device based on FATFS32 file system |
-
2018
- 2018-10-15 CN CN201811193759.0A patent/CN109542811B/en active Active
Patent Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040187122A1 (en) * | 2003-02-18 | 2004-09-23 | Microsoft Corporation | Systems and methods for enhancing performance of a coprocessor |
CN101441271A (en) * | 2008-12-05 | 2009-05-27 | 航天恒星科技有限公司 | SAR real time imaging processing device based on GPU |
US20120159015A1 (en) * | 2010-12-15 | 2012-06-21 | Electronic And Telecommunications Research Institute | Direct memory access controller and operating method thereof |
US20120246352A1 (en) * | 2011-03-24 | 2012-09-27 | Kil-Yeon Lim | Data processing systems for audio signals and methods of operating same |
CN102541780A (en) * | 2011-12-15 | 2012-07-04 | 苏州国芯科技有限公司 | Multi-data stream channel DMA (Direct Memory Access) system |
CN102831091A (en) * | 2012-07-31 | 2012-12-19 | 宁波成电泰克电子信息技术发展有限公司 | Serial port-based ship radar echo data collecting method |
CN102866971A (en) * | 2012-08-28 | 2013-01-09 | 华为技术有限公司 | Data transmission device, system and method |
CN103049336A (en) * | 2013-01-06 | 2013-04-17 | 浪潮电子信息产业股份有限公司 | Hash-based network card soft interrupt and load balancing method |
WO2017212524A1 (en) * | 2016-06-06 | 2017-12-14 | オリンパス株式会社 | Data transfer device, image processing device, and image pickup device |
CN108227572A (en) * | 2017-12-21 | 2018-06-29 | 中国船舶重工集团公司第七0七研究所 | A kind of serial data recording device based on FATFS32 file system |
Non-Patent Citations (1)
Title |
---|
LGV: "DMA双缓冲模式", 《HTTPS://BLOG.CSDN.NET/QQ_19999465/ARTICLE/DETAILS/81054680》 * |
Also Published As
Publication number | Publication date |
---|---|
CN109542811B (en) | 2021-12-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107992436B (en) | NVMe data read-write method and NVMe equipment | |
US9223734B2 (en) | Switch with synthetic device capability | |
WO2023185035A1 (en) | Direct memory access architecture, system and method, and electronic device and medium | |
EP2097828B1 (en) | Dmac to handle transfers of unknown lengths | |
WO2016127552A1 (en) | Direct memory access (dma) controller and data transmission method | |
US9965412B2 (en) | Method for application-aware interrupts management | |
CN102724035B (en) | Encryption and decryption method for encrypt card | |
US9400760B2 (en) | Information processor with tightly coupled smart memory unit | |
EP1645968A1 (en) | Multi-threaded DMA | |
US9684613B2 (en) | Methods and systems for reducing spurious interrupts in a data storage system | |
US9715403B2 (en) | Optimized extended context management for virtual machines | |
JPH077374B2 (en) | Interface circuit | |
US10437748B1 (en) | Core-to-core communication | |
JPS58501923A (en) | Interface circuit for subsystem controller | |
CN104714918B (en) | The reception of high speed FC bus datas and way to play for time under hosted environment | |
JP2016512361A (en) | Dual Host Embedded Shared Device Controller | |
TWI612473B (en) | Methods for garbage collection and apparatuses using the same | |
US9069741B2 (en) | Emulating level triggered interrupts of physical devices assigned to virtual machine | |
US8972624B2 (en) | USB virtualization | |
US9239804B2 (en) | Back-off mechanism for a peripheral page request log | |
CN113056729A (en) | Programming and control of computational cells in an integrated circuit | |
CN109343981A (en) | A kind of Dual-core system on chip and its virtual serial port communication means | |
CN109542811A (en) | A kind of data communication processing method | |
CN104836710B (en) | A kind of method and apparatus based on the communication of distributed system one master and multiple slaves | |
CN106909523B (en) | Large-scale data transmission 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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |