CN102163967A - Method for sampling pulse data - Google Patents

Method for sampling pulse data Download PDF

Info

Publication number
CN102163967A
CN102163967A CN 201110009685 CN201110009685A CN102163967A CN 102163967 A CN102163967 A CN 102163967A CN 201110009685 CN201110009685 CN 201110009685 CN 201110009685 A CN201110009685 A CN 201110009685A CN 102163967 A CN102163967 A CN 102163967A
Authority
CN
China
Prior art keywords
data
sampling
pulse
spi
value
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
Application number
CN 201110009685
Other languages
Chinese (zh)
Other versions
CN102163967B (en
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.)
FUJIAN XINNUO COMMUNICATION TECHNOLOGY Co Ltd
Original Assignee
FUJIAN XINNUO COMMUNICATION TECHNOLOGY 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 FUJIAN XINNUO COMMUNICATION TECHNOLOGY Co Ltd filed Critical FUJIAN XINNUO COMMUNICATION TECHNOLOGY Co Ltd
Priority to CN201110009685A priority Critical patent/CN102163967B/en
Publication of CN102163967A publication Critical patent/CN102163967A/en
Application granted granted Critical
Publication of CN102163967B publication Critical patent/CN102163967B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Synchronisation In Digital Transmission Systems (AREA)
  • Bus Control (AREA)

Abstract

The invention discloses a method for sampling pulse data, which is characterized in that a GPIO (general purpose input/output) for generating pulses is directly connected to an MISO (multiple input single output) pin of a CPU SPI (synchronous parallel interface) interface, the CPU is replaced with the existing SPI interface of the CPU (central processing unit) for carrying out pulse data sampling, and the sampled data are stored by a DMA (direct memory access). When the pulse is a low power pulse, the value of continuous bit of data sampled by the SPI is 0, and when the pulse is a high power pulse, the value of continuous bit of the data sampled by the SPI is 1. So, according to the sampling accuracy, the time width of pulses can be calculated just by calculating the number of continuous bits with a value of 0 or 1. By using the method disclosed by the invention, high-precision and high-performance pulse data sampling can be realized without adding additional hardware, therefore, the method has a good implementation effect and low cost.

Description

A kind of number of pulses is according to the method for sampling
[technical field]
The invention belongs to a kind of number of pulses according to the method for sampling, be applicable to end product with pulse data sampling function.
[background technology]
Along with the generation of Internet of Things industry, require increasing end product to have the function of pulse data sampling, for example to the black and white camera, the pulse data of one dimension laser head output is done sampling and is handled.Traditional number of pulses mainly contains two kinds according to the way of sampling.
First method: as shown in Figure 1, the GPIO pin that produces pulse is connected on the external interrupt pin of CPU.And be this outside interrupt configuration that dual edge triggers, as long as the state of pulse one changes, will trigger interruption like this, the time interval of in interrupt handling routine, calculating and preserving two edges of a pulse.
Second method: interfaces such as shown in Figure 2, expand a chip of being responsible for pulse data sampling specially, chip is by serial ports, USB and CPU are interconnected.
First method does not need additionally to add hardware just can finish the sampling function.The realization cost is low, but can cause sampling precision not high owing to there is time-delay in Interrupt Process, and sampling process needs the participation of CPU can cause system loading to increase.So but this is not a kind of method of commercialization, it is used to be used for being familiar with principle.A kind of at last perfect method of second method, but this need add extra hardware, can cause the increase of product cost.
[summary of the invention]
Technical problem to be solved by this invention is to provide a kind of low cost, the high-precision pulse data method of sampling, and this method need not to add additional hardware, and has higher sampling precision and sampling performance.
The present invention solves the problems of the technologies described above by the following technical solutions:
A kind of number of pulses comprises the steps: according to the method for sampling
Step 1: the GPIO pin of the corresponding SPI interface of initialization at first;
Step 2: the clock of spi bus is set, i.e. the sampling clock of pulse data;
Step 3: the initialization dma controller, and the preservation address of sampled data is set;
Step 4: in the time will beginning to gather, just enable the SPI interface, MISO is gone up the pulse of input and do sampling;
Step 5:SPI whenever samples the data of 4 bytes and just initiates a DMA request, and dma controller can be saved in data the core position of appointment;
Step 6: after sampling finished, all data that sample were kept at step 3 appointed positions;
Step 7: the sampling clock according to step 2 is provided with can calculate the every sampling one digit number of SPI according to the time that is spent;
Step 8: the data that escape samples, step-by-step come data are resolved; If continuously the value of position is 0, what this part sampled data correspondence just was described is low pulse, being that 0 the figure place and the value of step 7 can calculate the time width that hangs down pulse mutually at convenience continuously; If continuously the value of position is 1, what this part sampled data correspondence just was described is high impulse, and the value that is 1 figure place and step 7 is continuously multiplied each other can calculate the time width of high impulse.
The invention has the advantages that: the GPIO that produces pulse is directly linked on the MISO pin of CPU SPI interface, utilize the existing SPI interface of CPU to come replaced C PU to carry out the sampling of pulse data, the data that sample replace being responsible for preservation by DMA.Need not to add extra hardware and just can realize high accuracy, high performance pulse data sampling.Have good realization effect and lower realization cost.
[description of drawings]
The invention will be further described in conjunction with the embodiments with reference to the accompanying drawings.
Fig. 1 is that the logic of one of prior art connects block diagram.
Fig. 2 is that two logic of prior art connects block diagram.
Fig. 3 is that logic of the present invention connects block diagram.
Fig. 4 is a hardware elementary diagram of the present invention.
Fig. 5 is a software control flow process of the present invention.
[embodiment]
Please consult Fig. 3 to Fig. 5 simultaneously, a kind of number of pulses comprises the steps: according to the method for sampling
Step 1: the GPIO pin of the corresponding SPI interface of initialization at first;
Step 2: the clock of spi bus is set, i.e. the sampling clock of pulse data;
Step 3: the initialization dma controller, and the preservation address of sampled data is set;
Step 4: in the time will beginning to gather, just enable the SPI interface, MISO is gone up the pulse of input and do sampling;
Step 5:SPI whenever samples the data of 4 bytes and just initiates a DMA request, and dma controller can be saved in data the core position of appointment;
Step 6: after sampling finished, all data that sample were kept at step 3 appointed positions;
Step 7: the sampling clock according to step 2 is provided with can calculate the every sampling one digit number of SPI according to the time that is spent;
Step 8: the data that escape samples, step-by-step come data are resolved; If continuously the value of position is 0, what this part sampled data correspondence just was described is low pulse, being that 0 the figure place and the value of step 7 can calculate the time width that hangs down pulse mutually at convenience continuously; If continuously the value of position is 1, what this part sampled data correspondence just was described is high impulse, and the value that is 1 figure place and step 7 is continuously multiplied each other can calculate the time width of high impulse.
The whole impulse waveform of like this, just denumerable value input.
Among the present invention, the GPIO pin of output pulse is connected to the MISO pin of CPU SPI interface, just the input data of pulse as the SPI interface, when pulse when low, the data that SPI samples just are 0, and when pulse when being high, the data that SPI samples just are 1.As long as be 0 continuously or be 1 figure place so obtain, just can obtain the time width of pulse again according to sampling precision.
Because the FIFO size of SPI controller is limited, so must in time take the data that sample away.Overflow otherwise FIFO will take place, cause losing of sampled data.
So for the load that prevents that Interrupt Process from delaying time and causing FIFO to overflow and reduce system in the sampling process, the present invention adopts the mode of DMA that sampled data is in time shifted and directs at fixed core position.
The present invention directly links the GPIO that produces pulse on the MISO pin of CPU SPI interface, utilizes the existing SPI interface of CPU to come replaced C PU to carry out the sampling of pulse data, and the data that sample replace being responsible for preservation by DMA.Need not to add extra hardware and just can realize high accuracy, high performance pulse data sampling.Have good realization effect and lower realization cost.

Claims (1)

1. a number of pulses is characterized in that: comprise the steps: according to the method for sampling
Step 1: the GPIO pin of the corresponding SPI interface of initialization at first;
Step 2: the clock of spi bus is set, i.e. the sampling clock of pulse data;
Step 3: the initialization dma controller, and the preservation address of sampled data is set;
Step 4: in the time will beginning to gather, just enable the SPI interface, MISO is gone up the pulse of input and do sampling;
Step 5:SPI whenever samples the data of 4 bytes and just initiates a DMA request, and dma controller can be saved in data the core position of appointment;
Step 6: after sampling finished, all data that sample were kept at step 3 appointed positions;
Step 7: the sampling clock according to step 2 is provided with can calculate the every sampling one digit number of SPI according to the time that is spent;
Step 8: the data that escape samples, step-by-step come data are resolved; If continuously the value of position is 0, what this part sampled data correspondence just was described is low pulse, being that 0 the figure place and the value of step 7 can calculate the time width that hangs down pulse mutually at convenience continuously; If continuously the value of position is 1, what this part sampled data correspondence just was described is high impulse, and the value that is 1 figure place and step 7 is continuously multiplied each other can calculate the time width of high impulse.
CN201110009685A 2011-01-17 2011-01-17 Method for sampling pulse data Expired - Fee Related CN102163967B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201110009685A CN102163967B (en) 2011-01-17 2011-01-17 Method for sampling pulse data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201110009685A CN102163967B (en) 2011-01-17 2011-01-17 Method for sampling pulse data

Publications (2)

Publication Number Publication Date
CN102163967A true CN102163967A (en) 2011-08-24
CN102163967B CN102163967B (en) 2012-10-03

Family

ID=44464981

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201110009685A Expired - Fee Related CN102163967B (en) 2011-01-17 2011-01-17 Method for sampling pulse data

Country Status (1)

Country Link
CN (1) CN102163967B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103036567A (en) * 2012-12-24 2013-04-10 长沙威胜能源产业技术有限公司 Sampling method for analog-digital conversion chip
CN109739782A (en) * 2018-12-27 2019-05-10 国电南瑞科技股份有限公司 A kind of continuous sampling system and its continuous sampling method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1188346A (en) * 1996-12-10 1998-07-22 三星电子株式会社 Universal input data sampling circuit and method thereof
CN2595082Y (en) * 2002-12-03 2003-12-24 上海贝岭股份有限公司 Multiplex pulse counter
CN101587535A (en) * 2003-04-01 2009-11-25 武汉矽感科技有限公司 The method of linear scanning data wireless transmitting-receiving

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1188346A (en) * 1996-12-10 1998-07-22 三星电子株式会社 Universal input data sampling circuit and method thereof
CN2595082Y (en) * 2002-12-03 2003-12-24 上海贝岭股份有限公司 Multiplex pulse counter
CN101587535A (en) * 2003-04-01 2009-11-25 武汉矽感科技有限公司 The method of linear scanning data wireless transmitting-receiving

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103036567A (en) * 2012-12-24 2013-04-10 长沙威胜能源产业技术有限公司 Sampling method for analog-digital conversion chip
CN103036567B (en) * 2012-12-24 2015-11-11 威胜能源产业技术有限公司 For the method for sampling of modulus conversion chip
CN109739782A (en) * 2018-12-27 2019-05-10 国电南瑞科技股份有限公司 A kind of continuous sampling system and its continuous sampling method
CN109739782B (en) * 2018-12-27 2020-10-30 国电南瑞科技股份有限公司 Continuous sampling method

Also Published As

Publication number Publication date
CN102163967B (en) 2012-10-03

Similar Documents

Publication Publication Date Title
WO2017016178A1 (en) Interface signal remapping method based on fpga
CN105468547A (en) AXI bus based convenient configurable frame data access control system
CN102931994B (en) Be applied to high speed signal sampling and synchronous framework and the method for signal processing chip
CN102004711B (en) Single-interrupt real-time data transmission method based on FPGA (Field Programmable Gate Array)
CN104503931A (en) Multi-channel analog signal acquisition method
CN105404598A (en) Real-time data acquisition system and method
CN104714907B (en) A kind of pci bus is converted to ISA and APB bus design methods
CN104617926A (en) Pulse swallowing type clock synchronization circuit
CN104077492A (en) Sample data interpolation method based on FPGA
CN103268299B (en) A kind of generic data compression IP kernel being applied to PXI Express bus testing system
CN115080494A (en) SPI slave circuit, SPI communication method, interface and chip
CN102163967B (en) Method for sampling pulse data
WO2014081641A2 (en) Timing optimized implementation of algorithm to reduce switching rate on high throughput wide buses
CN112398877B (en) Control signal conversion circuit, intellectual property core and system-level chip
US8443129B1 (en) Method and apparatus for implementing a data bus interface
CN104239084A (en) Implementing method for automatically loading DSP (digital signal processor) procedures
CN111078605A (en) Comprehensive processing system for multi-communication interface interruption
Jusoh et al. An FPGA implementation of shift converter block technique on FIFO for RS232 to universal serial bus converter
CN102508798B (en) CPU (Central Processing Unit) and FPGA (Field Programmable Gate Array) interface method based on BURST and flow line
JP2007293845A (en) Method and device for reading data from serial data source in parallel format
CN103593312A (en) Time sequence control method and NAND FLASH controller
Jin et al. Design of spaceborne SAR imaging processing and fast Verification Based on FPGA
CN203233375U (en) FPGA-based multichannel pulse controller with high precision
CN104331385A (en) High-speed semi-hardware realization method for serial peripheral interface
Jusoh et al. An FPGA implementation of shift converter block technique on FIFO for UART

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
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: Method for sampling pulse data

Effective date of registration: 20131011

Granted publication date: 20121003

Pledgee: Fujian Straits bank Limited by Share Ltd. Fuzhou science and Technology Branch

Pledgor: Fujian Xino Communication Technology Co.,Ltd.

Registration number: 2013350000034

PLDC Enforcement, change and cancellation of contracts on pledge of patent right or utility model
PC01 Cancellation of the registration of the contract for pledge of patent right

Date of cancellation: 20150210

Granted publication date: 20121003

Pledgee: Fujian Straits bank Limited by Share Ltd. Fuzhou science and Technology Branch

Pledgor: Fujian Xino Communication Technology Co.,Ltd.

Registration number: 2013350000034

PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: Method for sampling pulse data

Effective date of registration: 20150216

Granted publication date: 20121003

Pledgee: Fujian Straits bank Limited by Share Ltd. Fuzhou science and Technology Branch

Pledgor: Fujian Xino Communication Technology Co.,Ltd.

Registration number: 2015350000009

PC01 Cancellation of the registration of the contract for pledge of patent right

Date of cancellation: 20160420

Granted publication date: 20121003

Pledgee: Fujian Straits bank Limited by Share Ltd. Fuzhou science and Technology Branch

Pledgor: Fujian Xino Communication Technology Co.,Ltd.

Registration number: 2015350000009

PLDC Enforcement, change and cancellation of contracts on pledge of patent right or utility model
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20121003