CN108304335A - A method of the indefinite long message of serial ports is received by DMA - Google Patents
A method of the indefinite long message of serial ports is received by DMA Download PDFInfo
- Publication number
- CN108304335A CN108304335A CN201810119917.1A CN201810119917A CN108304335A CN 108304335 A CN108304335 A CN 108304335A CN 201810119917 A CN201810119917 A CN 201810119917A CN 108304335 A CN108304335 A CN 108304335A
- Authority
- CN
- China
- Prior art keywords
- dma
- serial ports
- timer
- message
- event
- 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.)
- Pending
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/32—Handling requests for interconnection or transfer for access to input/output bus using combination of interrupt and burst mode transfer
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 present invention provides a kind of methods receiving the indefinite long message of high-speed communication serial ports by DMA, belong to communication and technical field of data transmission.Include the following steps:1) setting serial ports is DMA reception patterns;2) it is external interrupt pattern a GPIO pin to be arranged, and this pin is connected with the reception pin RXD of serial ports;3) configuration external pin is failing edge pattern, i.e. failing edge generates external pin and interrupts, and timer TC0 is enabled when generating first failing edge;4) setting external interrupt generates EVENT events, this event is associated with timer TC0;5) incoming event of setting TC0 is associated with the event that external pin generates, and TC0 is set as Retrigger patterns;6) the timer expiry time is set, and then Off Timer after timer expiry carries out Message processing, and enable DMA again and receive to wait for next frame message.By the mutual cooperation of timer and DMA, a kind of method that Serial Communication at High Speed on MS receives indefinite long message is realized.
Description
Technical field
The invention belongs to automated communication technical fields, provide a kind of side receiving the indefinite long message of serial ports by DMA
Method.
Background technology
Message reception is carried out using interrupt mode when serial ports is in high rate communication pattern, CPU can be caused to frequently enter string
Mouth receives interrupt service routine, does not only take up a large amount of CPU processing times in this way, and be very easy to cause the loss of message.And
DMA (Direct Memory Access) is a kind of high-speed data switch mode, allow between external equipment and memory into
Intervention of the direct read-write operation of row without CPU.Under the operation mode of DMA, CPU directly controls DMA by instruction and controls
Device processed allows dma controller to control the transmission of message, enters DMA transfer end interrupt service routine after the completion of message transmissions, this
Sample largely alleviates the load of CPU.Therefore it carries out message using DMA to receive compared with interrupt mode, have following excellent
Point:First:When carrying out message reception using serial ports interrupt mode, often receives 1 byte data and just will produce a serial ports reception
Interrupt service routine, and under dma mode, it is desirable that the data block of transmission just will produce primary interruption after all transmitting, to
Reduce the number that CPU carries out interrupt processing;Second:When carrying out message reception using serial ports interrupt mode, in the reception of serial ports
Disconnected service routine is to be controlled to complete by CPU, occupies the processing time of CPU, and DMA transfer has been controlled by dma controller
At.But when carrying out message reception using dma mode, the operation of DMA message transmissions is indefinite transfer, i.e. sender is by transmission
Message is sent according to the regular length that sender and recipient appoint, insufficient regular length just needs to fill invalid data
To regular length.When carrying out message reception using dma mode, need first to need to receive byte number to dma controller is specified, when
Dma controller generates DMA transfer interruption after receiving specified bytes.And in practical application, serial ports receives the byte of message
Number is often unfixed, therefore DMA can not directly be used to carry out message reception, how to utilize dma mode reception random length report
Text becomes urgent problem to be solved.
Invention content
The purpose of the present invention is to provide a kind of methods receiving the indefinite long message of serial ports by DMA, can only to solve DMA
The limitation of fixed length message is received, realizes that Serial Communication at High Speed on MS receives indefinite long message
.To achieve the above object, the present invention adopts the following technical scheme that:One kind receiving the indefinite long message of serial ports by DMA
Method, described method includes following steps:
1) setting serial ports is DMA reception patterns, and DMA initial values are arranged;
2) it is external interrupt pattern a GPIO pin to be arranged, and this pin is connected with the reception pin RXD of serial ports
It connects;
3) it is failing edge pattern to configure the GPIO pin, i.e. failing edge generates the GPIO pin external interrupt, works as production
Enabled timer TC0 when raw first failing edge;
4) setting external interrupt generates EVENT events, this event is associated with timer TC0;
5) incoming event of setting timer TC0 is associated with the event that the GPIO pin external interrupt generates, and handle
TC0 is set as Retrigger patterns, that is, after receiving external EVENT events, the cumulative time of timer is reset;
6) timer TC0 time-out times are set, and when serial ports does not have data message, RXD pins not will produce failing edge and touch
It sends out timer TC0 to reset the cumulative time, timer TC0 time-out generates interruption;Serial ports report is carried out in overtime interrupt service routine
Text processing, and DMA receiving channels are enabled again to wait for next frame message.
Further, the source address that initial value described in step 1) refers specifically to setting DMA receiving channels is what serial ports received
Register address, destination address are to store the buffering area array first address of serial data, and it is from increasing mould that destination address, which is arranged,
Formula.
Further, the size of the buffering area of the storage serial data is consistent with maximum message size.
Beneficial effects of the present invention:DMA, which can effectively be solved, can only receive the limitation of fixed length message, extend DMA and going here and there
The application of indefinite long message is received in port communications.
Description of the drawings
Fig. 1 present system structural schematic diagrams;
Sequence diagram between Fig. 2 serial ports RXD pins of the present invention, external interrupt, EVENT and timer.
Specific implementation mode
It is understandable to enable the above of the present invention, feature and advantage to be more clear, below in conjunction with the accompanying drawings to the present invention
Detailed implementation steps do specific description.It should be appreciated that described herein, specific examples are only used to explain the present invention, and
It is not used to limit the present invention.
The present invention provides a kind of method receiving the indefinite long message of serial ports by DMA, comprises the following steps:
(1) setting serial ports first is received as DMA mode, and DMA initial values are arranged.The initial value is that setting DMA is received
The source address in channel is the register address that serial ports receives, and destination address is the buffering area array first address for receiving serial data,
And setting destination address is from increasing pattern, the reception length of DMA is consistent with data receiver buffer size.In order to ensure maximum
Length message normally receives, this size for receiving buffering area must be consistent with maximum message size.
(2) GPIO pin associated with serial ports RXD pins is set after for external interrupt pattern, in the present embodiment
Setting PC14 pins are external interrupt pattern.
(3) it is failing edge pattern to configure the GPIO pin, i.e. failing edge generates the GPIO pin external interrupt, works as production
Enabled timer TC0 when raw first failing edge.
(4) setting external interrupt generates EVENT events, this event is associated with timer TC0.
(5) the EVENT events that the EVENT incoming events of setting timer TC0 are generated with the GPIO pin external interrupt
It is associated, and TC0 is set as Retrigger patterns, that is, after receiving external EVENT events, the cumulative time of timer
It resets.Since serial ports start of message (SOM) position is the low level of a bit, so centainly will produce one when starting transmission byte
A failing edge.RXD pin failing edges trigger external interrupt, and external interrupt generates EVENT events, and EVENT events Retrigger is fixed
When device TC0.When serial ports has message to be transmitted, timer TC0 would not overflow generation overtime interrupt.RXD pins, EVENT
The logic chart of event and TC0 timers is as shown in Figure 2.
(6) timer TC0 time-out times are set, and when serial ports does not have message transmissions, RXD pins not will produce failing edge and go
It triggers timer TC0 and resets the cumulative time, then TC0 will time-out generation interruption.It is gone here and there in overtime interrupt service routine
Mouth Message processing, and DMA receiving channels are enabled again to wait for next frame message.
Above example is merely illustrative of the invention's technical idea, and protection scope of the present invention cannot be limited with this, every
According to technological thought proposed by the present invention, any change done on the basis of technical solution each falls within the scope of the present invention
Within.
Claims (3)
1. a kind of method receiving the indefinite long message of high speed communication serial ports by DMA, which is characterized in that the method includes as follows
Step:
1) setting serial ports is DMA reception patterns, and DMA initial values are arranged;
2) it is external interrupt pattern a GPIO pin to be arranged, and this pin is connected with the reception pin RXD of serial ports;
3) it is failing edge pattern to configure the GPIO pin, i.e. failing edge generates the GPIO pin external interrupt, when generating the
Timer TC0 is enabled when one failing edge;
4) setting external interrupt generates EVENT events, this event is associated with timer TC0;
5) incoming event of setting timer TC0 is associated with the event that the GPIO pin external interrupt generates, and TC0 is set
Retrigger patterns are set to, that is, after receiving external EVENT events, the cumulative time of timer is reset;
6) timer TC0 time-out times are set, and when serial ports does not have data message, it is fixed that RXD pins not will produce failing edge triggering
When device TC0 reset the cumulative time, timer TC0 time-out generates interruption;It is carried out at serial ports message in overtime interrupt service routine
Reason, and DMA receiving channels are enabled again to wait for next frame message.
2. a kind of method receiving the indefinite long message of high speed communication serial ports by DMA as described in claim 1, feature exist
In:The source address that initial value described in step 1) refers specifically to setting DMA receiving channels is the register address that serial ports receives, purpose
Address is to store the buffering area array first address of serial data, and it is from increasing pattern that destination address, which is arranged,.
3. a kind of method receiving the indefinite long message of high speed communication serial ports by DMA as claimed in claim 2, feature exist
In:The size of the buffering area of the storage serial data is consistent with maximum message size.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810119917.1A CN108304335A (en) | 2018-02-07 | 2018-02-07 | A method of the indefinite long message of serial ports is received by DMA |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810119917.1A CN108304335A (en) | 2018-02-07 | 2018-02-07 | A method of the indefinite long message of serial ports is received by DMA |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108304335A true CN108304335A (en) | 2018-07-20 |
Family
ID=62864447
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810119917.1A Pending CN108304335A (en) | 2018-02-07 | 2018-02-07 | A method of the indefinite long message of serial ports is received by DMA |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108304335A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110995598A (en) * | 2019-11-12 | 2020-04-10 | 芯创智(北京)微电子有限公司 | Variable-length message data processing method and scheduling device |
CN111324567A (en) * | 2020-02-10 | 2020-06-23 | 华大半导体有限公司 | Method for realizing serial port communication and single chip microcomputer system |
CN111352888A (en) * | 2020-02-28 | 2020-06-30 | 北京铁科英迈技术有限公司 | Interrupt signal generating method and device for asynchronous transceiver |
CN111666237A (en) * | 2020-06-08 | 2020-09-15 | 王斌 | DMA controller with cache management function |
CN115292398A (en) * | 2022-08-02 | 2022-11-04 | 中国自然资源航空物探遥感中心 | Data format conversion method and device, electronic equipment and storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010044862A1 (en) * | 1998-12-10 | 2001-11-22 | James O. Mergard | Serializing and deserialing parallel information for communication between devices for communicating with peripheral buses |
CN201500188U (en) * | 2009-09-30 | 2010-06-09 | 浙江大学 | Hospital patient outdoor wireless monitoring system |
CN101989249A (en) * | 2009-08-07 | 2011-03-23 | 深圳达实智能股份有限公司 | Serial port data receiving method of single chip microcomputer |
CN102573113A (en) * | 2010-12-27 | 2012-07-11 | 北京中电华大电子设计有限责任公司 | SoC (system-on-chip) chip structure of wireless local area network |
CN104486247A (en) * | 2014-12-16 | 2015-04-01 | 北京东土科技股份有限公司 | Data transmission method and device based on serial server |
CN204423111U (en) * | 2015-01-26 | 2015-06-24 | 北京神州龙芯集成电路设计有限公司 | A kind of SOC (system on a chip) be applied in intelligent grid concentrator |
CN106326157A (en) * | 2015-06-30 | 2017-01-11 | 深圳市科陆电子科技股份有限公司 | Method and device for receiving variable-length data of serial port |
-
2018
- 2018-02-07 CN CN201810119917.1A patent/CN108304335A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010044862A1 (en) * | 1998-12-10 | 2001-11-22 | James O. Mergard | Serializing and deserialing parallel information for communication between devices for communicating with peripheral buses |
CN101989249A (en) * | 2009-08-07 | 2011-03-23 | 深圳达实智能股份有限公司 | Serial port data receiving method of single chip microcomputer |
CN201500188U (en) * | 2009-09-30 | 2010-06-09 | 浙江大学 | Hospital patient outdoor wireless monitoring system |
CN102573113A (en) * | 2010-12-27 | 2012-07-11 | 北京中电华大电子设计有限责任公司 | SoC (system-on-chip) chip structure of wireless local area network |
CN104486247A (en) * | 2014-12-16 | 2015-04-01 | 北京东土科技股份有限公司 | Data transmission method and device based on serial server |
CN204423111U (en) * | 2015-01-26 | 2015-06-24 | 北京神州龙芯集成电路设计有限公司 | A kind of SOC (system on a chip) be applied in intelligent grid concentrator |
CN106326157A (en) * | 2015-06-30 | 2017-01-11 | 深圳市科陆电子科技股份有限公司 | Method and device for receiving variable-length data of serial port |
Non-Patent Citations (2)
Title |
---|
JUNLIYANG: "《http://bbs.eeworld.com.cn/thread-118976-1-1.html》", 21 December 2009 * |
WEYMIN: "《https://blog.csdn.net/u013053268/article/details/54767057》", 28 January 2017 * |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110995598A (en) * | 2019-11-12 | 2020-04-10 | 芯创智(北京)微电子有限公司 | Variable-length message data processing method and scheduling device |
CN110995598B (en) * | 2019-11-12 | 2022-03-04 | 芯创智(北京)微电子有限公司 | Variable-length message data processing method and scheduling device |
CN111324567A (en) * | 2020-02-10 | 2020-06-23 | 华大半导体有限公司 | Method for realizing serial port communication and single chip microcomputer system |
CN111324567B (en) * | 2020-02-10 | 2022-05-27 | 华大半导体有限公司 | Method for realizing serial port communication and single chip microcomputer system |
CN111352888A (en) * | 2020-02-28 | 2020-06-30 | 北京铁科英迈技术有限公司 | Interrupt signal generating method and device for asynchronous transceiver |
CN111666237A (en) * | 2020-06-08 | 2020-09-15 | 王斌 | DMA controller with cache management function |
CN111666237B (en) * | 2020-06-08 | 2022-06-28 | 王斌 | DMA controller with cache management function |
CN115292398A (en) * | 2022-08-02 | 2022-11-04 | 中国自然资源航空物探遥感中心 | Data format conversion method and device, electronic equipment and storage medium |
CN115292398B (en) * | 2022-08-02 | 2023-07-25 | 中国自然资源航空物探遥感中心 | Data format conversion method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108304335A (en) | A method of the indefinite long message of serial ports is received by DMA | |
US10552352B2 (en) | Methods and apparatus for synchronizing uplink and downlink transactions on an inter-device communication link | |
CN202870808U (en) | FPGA realization device of SPI serial port module | |
CN106155960B (en) | It is shaken hands the UART serial port communication method with EDMA based on GPIO | |
US8310934B2 (en) | Method and device for controlling information channel flow | |
BR112016013935B1 (en) | ENERGY SAVING TECHNIQUES IN COMPUTER DEVICES | |
CN102801744A (en) | Communication bus protocol and system comprising same | |
CN105117319A (en) | Method for realizing real-time monitoring of multi-channel MDIO (Management Data Input Output) devices based on FPGA | |
US20160373238A1 (en) | Independent UART BRK Detection | |
CN101146090B (en) | A method and device for transmitting and receiving data based on USART bus | |
WO2014004188A1 (en) | Providing a serial protocol for a bidirectional serial interconnect | |
CN103107862A (en) | Logic device and management data input/output (MDIO) data transmission method thereof | |
CN104144137B (en) | A kind of high speed LVDS serial synchronous communication controllers | |
CN102299861A (en) | Message traffic control method | |
CN104679715A (en) | Simple inter-chip communication method and simple inter-chip communication device | |
US11646971B2 (en) | Limiting backpressure with bad actors | |
CN108111428B (en) | Congestion control method and device | |
CN108509365B (en) | DBI data transmission method and system | |
CN110865954A (en) | Method for automatically defining variable-length frame end based on DMA (direct memory access) SPI (serial peripheral interface) inter-device communication | |
CN111352893B (en) | Communication method of FPGA and STM32 singlechip | |
CN113485957B (en) | Multi-protocol system control device and multi-protocol system control method for physical layer suitable for industrial-level application scene | |
CN117997857A (en) | LoRaWAN device-based data processing method, device, equipment and storage medium | |
CN110096461A (en) | A kind of real-time and high-speed data transmission method and system based on USB3.0 aided protocol | |
CN112637027B (en) | Frame boundary defining device based on UART (universal asynchronous receiver/transmitter), transmitting method and receiving method | |
KR101420306B1 (en) | Method for processing pachet and device thereof |
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 | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20180720 |