CN103077144A - Serial peripheral interface (SPI) communication interface for ensuring data integrity, and communication method thereof - Google Patents

Serial peripheral interface (SPI) communication interface for ensuring data integrity, and communication method thereof Download PDF

Info

Publication number
CN103077144A
CN103077144A CN2012105806975A CN201210580697A CN103077144A CN 103077144 A CN103077144 A CN 103077144A CN 2012105806975 A CN2012105806975 A CN 2012105806975A CN 201210580697 A CN201210580697 A CN 201210580697A CN 103077144 A CN103077144 A CN 103077144A
Authority
CN
China
Prior art keywords
communication
slave
line
spi
main frame
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
Application number
CN2012105806975A
Other languages
Chinese (zh)
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.)
Shanghai instrument and meter for automation company limited
Original Assignee
Shanghai Automation Instrumentation 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 Shanghai Automation Instrumentation Co Ltd filed Critical Shanghai Automation Instrumentation Co Ltd
Priority to CN2012105806975A priority Critical patent/CN103077144A/en
Publication of CN103077144A publication Critical patent/CN103077144A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Communication Control (AREA)

Abstract

The invention belongs to the technical field of a distributed control system, and relates to a serial peripheral interface (SPI) communication interface for ensuring data integrity, and a communication method thereof. The SPI communication interface comprises a host computer for SPI communication, at least one slave, an SPI bus master output/slave output (MISO) line, an SPI bus master output/slave input (MOSI) line, an SCK line and a CS line. The SPI communication interface is characterized in that each slave comprises a Ready line to be connected with the host computer for ensuring the data integrality of SPI communication. By using the SPI communication interface, the data integrity of SPI communication is ensured by providing two communication methods. The Ready line is added between the host computer for SPI communication and the slave, so that the breaking effect on a current operation when the slave passively receives a communication instruction in the existing SPI communication is eliminated, and the data integrity of the SPI communication is ensured.

Description

A kind of SPI communication interface and means of communication thereof of guaranteeing data integrity
Technical field
The invention belongs to the DCS(scattered control system) technical field, be specifically related to a kind ofly be applied between fastener inside and the fastener chip SPI communication interface and guarantee the method that the SPI communication data is complete.
Background technology
Scattered control system (DCS) is widely used in the industry-by-industries such as electric power, metallurgy, petrochemical complex.Along with the development of DCS, the situation of single module double mcu even multiple single chip microcomputer is more and more, or single module has a plurality of programmable chips.The SPI communications protocol is flexible, degree of controllability is high, and a lot of SPI communication of tenaculum DMA of cpu chip, makes the SPI communication become more simple and convenient, and the time that takies CPU still less, so the communication mode of SPI agreement is all adopted in the communication of a lot of chip chambers.
The both sides of SPI communication are divided into main frame and one or more from equipment, 4 lines of normal operation: the slave of serial time clock line (SCK), main frame input/slave output data line MISO, main frame output/slave input data line MOSI and Low level effective is selected line CS.
During general SPI communication, the status that main frame has the initiative and dominates, slave can only passive receive.But the chip as slave generally also needs to carry out other orders and task, and the communication command of accepting passively main frame inevitably will interrupt and affect the task of current execution, if especially both sides' Content of communciation is the data of constantly updating, slave is accepted passively the SPI communication command and may be interrupted current data acquisition or interrupt the data field assignment, the problems such as the unreliable and data dislocation of the data that cause slave to collect, even might cause very serious fault.
Summary of the invention
The technical problem to be solved in the present invention provides a kind of SPI communication interface and utilizes it to guarantee the means of communication of the data integrity of the SPI communication between single-chip microcomputer or between other programmable chips, the current task of avoiding being in the SPI communication programmable chip of slave status is interrupted, also avoid the data of communication transfer that the problems such as dislocation occur, improved the operation efficiency of transfer efficiency and processor.
For achieving the above object, the technical scheme that adopts is: a kind of SPI communication interface of guaranteeing data integrity, main frame and at least one slave, MISO line, MOSI line, SCK line and CS line of comprising the SPI communication, it is characterized in that: every described slave has a Ready line to be connected with described main frame, is used for guaranteeing the data integrity of SPI communication.
Use above-mentioned SPI communication interface, the first is guaranteed the means of communication of data integrity, it is characterized in that, may further comprise the steps:
(1) the slave data acquisition is complete and data are put into SPI send the buff district, when being ready for the SPI communication, drags down the Ready line;
When (2) Host Detection is low to certain slave Ready line, drag down CS line corresponding to this slave;
(3) main frame and this slave carry out the SPI communication;
(4) communication is complete, and main frame is drawn high the CS line, and slave is drawn high the Ready line.
Use above-mentioned SPI communication interface, the second is guaranteed the means of communication of data integrity, it is characterized in that, may further comprise the steps:
(1) the slave data acquisition is complete and data are put into SPI send the buff district, when being ready for the SPI communication, drags down the Ready line;
When (2) Host Detection is low to certain slave Ready line, drag down CS line corresponding to this slave;
(3) this slave and main frame begin the SPI communication, transmit a byte;
(4) judge whether data transmission is complete, end of transmission then goes to step (7), the not complete step (5) that then goes to;
(5) slave is put into the SPI data register with next byte, and the level of the Ready line that overturns;
(6) main frame judges according to the byte number that transmits whether Ready line level is correct, correctly then goes to step (3), the incorrect step (7) that then goes to;
(7) main frame is drawn high the CS line, and slave is drawn high the Ready line, and communication finishes.
Good effect of the present invention is: by set up a Ready line between the main frame of SPI communication and every slave, make slave have initiative to communication, interrupted the impact of current operation when having eliminated slave passive receive communication instruction in the existing SPI communication.Simultaneously because the existence of CS line, the main frame of SPI communication is not lost the control to communication yet, main frame and slave can not interrupt other tasks of oneself because of the passive communication command of accepting, thereby the quality of SPI communication is significantly improved, guarantee the data integrity of SPI communication, also improved the work efficiency of the CPU of the main frame of SPI communication and slave.
Description of drawings
Fig. 1 is the hardware principle block diagram of existing SPI communication;
Fig. 2 is the hardware principle block diagram of SPI communication of the present invention;
Fig. 3 is the byte sequential chart of the SPI means of communication of the present invention;
Sequential chart when Fig. 4 is the first means of communication multibyte communication of the present invention;
Sequential chart when Fig. 5 is the second means of communication multibyte communication of the present invention;
The process flow diagram of slave when Fig. 6 is the first means of communication multibyte communication of the present invention;
The process flow diagram of main frame when Fig. 7 is the first means of communication multibyte communication of the present invention;
The process flow diagram of slave when Fig. 8 is the second means of communication multibyte communication of the present invention;
The process flow diagram of main frame when Fig. 9 is the second means of communication multibyte communication of the present invention.
Embodiment
A kind of SPI communication interface of guaranteeing data integrity, main frame and at least one slave, MISO line, MOSI line, SCK line and CS line of comprising the SPI communication, it is characterized in that: every described slave has a Ready line to be connected with described main frame, is used for guaranteeing the data integrity of SPI communication.
Use above-mentioned SPI communication interface, the first is guaranteed the means of communication of data integrity, it is characterized in that may further comprise the steps:
(1) the slave data acquisition is complete and data are put into SPI send the buff district, when being ready for the SPI communication, drags down the Ready line;
When (2) Host Detection is low to certain slave Ready line, drag down CS line corresponding to this slave;
(3) main frame and this slave carry out the SPI communication;
(4) communication is complete, and main frame is drawn high the CS line, and slave is drawn high the Ready line.
Use above-mentioned SPI communication interface, the second is guaranteed the means of communication of data integrity, it is characterized in that, may further comprise the steps:
(1) the slave data acquisition is complete and data are put into SPI send the buff district, when being ready for the SPI communication, drags down the Ready line;
When (2) Host Detection is low to certain slave Ready line, drag down CS line corresponding to this slave;
(3) this slave and main frame begin the SPI communication, transmit a byte;
(4) judge whether data transmission is complete, end of transmission then goes to step (7), the not complete step (5) that then goes to;
(5) slave is put into the SPI data register with next byte, and the level of the Ready line that overturns;
(6) main frame judges according to the byte number that transmits whether Ready line level is correct, correctly then goes to step (3), the incorrect step (7) that then goes to;
(7) main frame is drawn high the CS line, and slave is drawn high the Ready line, and communication finishes.
Fig. 1 is the hardware principle block diagram of existing SPI communication, Fig. 2 is the hardware principle block diagram of SPI communication of the present invention, comparison diagram 1 and Fig. 2 are as seen, SPI communication of the present invention has been Duoed a Ready line than existing SPI communication at hardware, the signal of this line is exported by slave, be input to main frame, that slave is to the control line of whole SPI communication, this line makes main frame in whole SPI communication initiative arranged, therefore, the SPI communication command that no longer sent by main frame such as the task of the current execution of slave such as data collection interrupts.
Fig. 3 is the byte sequential chart of the SPI means of communication of the present invention, by finding out in the sequential chart, only the CS line just can drag down after the Ready line drags down, and only in the situation that Ready and CS line all be low CLK just can be effective, thereby data just can be effective, the just existence of Ready line and CS line, just make main frame and the slave both sides of SPI communication that ownership has been arranged, main frame and slave can not interrupt other tasks of oneself because of the passive communication command of accepting, thereby can guarantee data and other data integrities and the true and accurate of SPI communication.
Sequential chart when the present invention has two kinds of communication mode: Fig. 4 to be the first means of communication multibyte communication of the present invention, the sequential chart when Fig. 5 is the second means of communication multibyte communication of the present invention.The something in common of two kinds of communication modes is, slave has the Ready control line, all communication is had control; Difference is that the first pattern Ready line only overturns once, and beginning drags down before the communication, and communication is complete draws high, and is applicable to the demanding situation of communication speed, and main frame, slave can be with rapid data transmission means such as DMA; And the second pattern is overturn once at each byte end of transmission Ready line, in this case, main frame needed to judge the level of Ready line before each the byte transmission except first byte, thereby more can guarantee the correctness of communication, but the defective of this pattern is, main frame all needs to judge the state of Ready line at every turn because each slave all will overturn the Ready line, thereby has reduced the communication speed of SPI, and can not use the high speed means of communication such as DMA.So can come choice for use the first pattern or the second pattern according to actual conditions in use.
The process flow diagram of slave when Fig. 6 is the first means of communication multibyte communication of the present invention, the process flow diagram of main frame when Fig. 7 is the first means of communication multibyte communication of the present invention.As shown in the figure, when the slave DSR, drag down the Ready line; When Host Detection is low to certain slave Ready line, drag down CS line corresponding to this slave; Main frame and this slave carry out the SPI communication; Communication is complete, and main frame is drawn high the CS line, and slave is drawn high the Ready line.
The process flow diagram of slave when Fig. 8 is the second means of communication multibyte communication of the present invention, the process flow diagram of main frame when Fig. 9 is the second means of communication multibyte communication of the present invention.As shown in the figure:
(1) the slave data acquisition is complete and data are put into SPI send the buff district, when being ready for the SPI communication, drags down the Ready line;
When (2) Host Detection is low to certain slave Ready line, drag down CS line corresponding to this slave;
(3) this slave and main frame begin the SPI communication, transmit a byte;
(4) judge whether data transmission is complete, end of transmission then goes to step (7), the not complete step (5) that then goes to;
(5) slave is put into the SPI data register with next byte, and the level of the Ready line that overturns;
(6) main frame judges according to the byte number that transmits whether Ready line level is correct, correctly then goes to step (3), the incorrect step (7) that then goes to;
(7) main frame is drawn high the CS line, and slave is drawn high the Ready line, and communication finishes.
Process flow diagram by above-mentioned two kinds of communication modes can be found out, before each communication begins, all to operate the Ready line, this is that slave can select when to begin communication, and main frame is because the existence of CS line, do not lose the control to communication yet, like this slave can data acquisition or other tasks finish control afterwards Ready line notice main frame can communication, finish and control afterwards the CS line and begin communication and main frame also can be chosen in other tasks, the control that all has of main frame and slave makes the communication controllability that becomes very strong like this, other operations of main frame and slave can not interrupted, guaranteed the data integrity that is designed into of other operations.
Experimental verification:
Test for performance of the present invention, compare with existing SPI communication modes, both hardware circuits are identical, all adopting main frame is that LPC2136, two slaves are STM32F103, main frame carries out multiple communication simultaneously, and slave carries out the meter of pulsed quantity simultaneously to be measured frequently, and measurement range is 1-10000Hz.
Experimental results show that, when adopting traditional SPI means of communication, slave is because the passive communication command of accepting, when pulsed frequency is higher or pulsed frequency lower the time, the frequently operation meeting of the meter of slave is interrupted by the SPI communication, thereby causes result of calculation to follow the signal source of input inconsistent.When adopting the SPI means of communication of the present invention, slave is chosen in to calculate and drags down the Ready line after complete and begin communication, and through observing for a long time, the result of calculation of slave is consistent with the signal of input, and in measurement range, error is ± 1Hz.
By experimental result as can be known, the present invention can guarantee the correctness of other operations of SPI communication two party, can guarantee that the SPI communication two party carries out the complete of the data that relate to when other calculate.

Claims (3)

1. SPI communication interface of guaranteeing data integrity, main frame and at least one slave, MISO line, MOSI line, SCK line and CS line of comprising the SPI communication, it is characterized in that: every described slave has a Ready line to be connected with described main frame, is used for guaranteeing the data integrity of SPI communication.
2. use a kind of SPI communication interface as claimed in claim 1 to guarantee the means of communication of data integrity, it is characterized in that, may further comprise the steps:
(1) the slave data acquisition is complete and data are put into SPI send the buff district, when being ready for the SPI communication, drags down the Ready line;
When (2) Host Detection is low to certain slave Ready line, drag down CS line corresponding to this slave;
(3) main frame and this slave carry out the SPI communication;
(4) communication is complete, and main frame is drawn high the CS line, and slave is drawn high the Ready line.
3. use a kind of SPI communication interface as claimed in claim 1 to guarantee the means of communication of data integrity, it is characterized in that, may further comprise the steps:
(1) the slave data acquisition is complete and data are put into SPI send the buff district, when being ready for the SPI communication, drags down the Ready line;
When (2) Host Detection is low to certain slave Ready line, drag down CS line corresponding to this slave;
(3) this slave and main frame begin the SPI communication, transmit a byte;
(4) judge whether data transmission is complete, end of transmission then goes to step (7), the not complete step (5) that then goes to;
(5) slave is put into the SPI data register with next byte, and the level of the Ready line that overturns;
(6) main frame judges according to the byte number that transmits whether Ready line level is correct, correctly then goes to step (3), the incorrect step (7) that then goes to;
(7) main frame is drawn high the CS line, and slave is drawn high the Ready line, and communication finishes.
CN2012105806975A 2012-12-28 2012-12-28 Serial peripheral interface (SPI) communication interface for ensuring data integrity, and communication method thereof Pending CN103077144A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2012105806975A CN103077144A (en) 2012-12-28 2012-12-28 Serial peripheral interface (SPI) communication interface for ensuring data integrity, and communication method thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2012105806975A CN103077144A (en) 2012-12-28 2012-12-28 Serial peripheral interface (SPI) communication interface for ensuring data integrity, and communication method thereof

Publications (1)

Publication Number Publication Date
CN103077144A true CN103077144A (en) 2013-05-01

Family

ID=48153675

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2012105806975A Pending CN103077144A (en) 2012-12-28 2012-12-28 Serial peripheral interface (SPI) communication interface for ensuring data integrity, and communication method thereof

Country Status (1)

Country Link
CN (1) CN103077144A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103838700A (en) * 2014-02-20 2014-06-04 江苏理工学院 level multiplexing control serial communication device and communication method thereof
CN104735053A (en) * 2015-01-28 2015-06-24 上海兰宝传感科技股份有限公司 Multi-CPU control system based on SPI bus and MODBUS communication protocol
CN105024900A (en) * 2015-08-03 2015-11-04 艾德克斯电子(南京)有限公司 Multi-machine synchronous communication system and method
CN107346294A (en) * 2016-05-04 2017-11-14 上海商米科技有限公司 Data-flow-control system and method based on SPI protocol
CN112214440A (en) * 2020-10-10 2021-01-12 北京寓乐世界教育科技有限公司 Communication method based on SPI communication
CN114528235A (en) * 2022-01-21 2022-05-24 厦门亿联网络技术股份有限公司 SPI (Serial peripheral interface) -based communication method, slave equipment and system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1347611A (en) * 1999-04-19 2002-05-01 默勒股份有限公司 Data transmission device
CN1673985A (en) * 2004-03-26 2005-09-28 华为技术有限公司 Connection circuit for master equipment and multi-slave equipment and method for generating answer signal thereof
CN101076788A (en) * 2004-04-26 2007-11-21 爱特梅尔股份有限公司 Bi-directional serial interface for communication control
CN101552733A (en) * 2009-05-15 2009-10-07 深圳华为通信技术有限公司 Data transmission realizing method and system based on SPI
CN203117968U (en) * 2012-12-28 2013-08-07 上海自动化仪表股份有限公司 SPI (Serial Peripheral Interface) communication interface

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1347611A (en) * 1999-04-19 2002-05-01 默勒股份有限公司 Data transmission device
US7257656B1 (en) * 1999-04-19 2007-08-14 Moeller Gmbh Device for synchronous transmission of data between a master device and a slave device
CN1673985A (en) * 2004-03-26 2005-09-28 华为技术有限公司 Connection circuit for master equipment and multi-slave equipment and method for generating answer signal thereof
CN101076788A (en) * 2004-04-26 2007-11-21 爱特梅尔股份有限公司 Bi-directional serial interface for communication control
CN101552733A (en) * 2009-05-15 2009-10-07 深圳华为通信技术有限公司 Data transmission realizing method and system based on SPI
CN203117968U (en) * 2012-12-28 2013-08-07 上海自动化仪表股份有限公司 SPI (Serial Peripheral Interface) communication interface

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103838700A (en) * 2014-02-20 2014-06-04 江苏理工学院 level multiplexing control serial communication device and communication method thereof
CN104735053A (en) * 2015-01-28 2015-06-24 上海兰宝传感科技股份有限公司 Multi-CPU control system based on SPI bus and MODBUS communication protocol
CN105024900A (en) * 2015-08-03 2015-11-04 艾德克斯电子(南京)有限公司 Multi-machine synchronous communication system and method
CN105024900B (en) * 2015-08-03 2018-11-27 艾德克斯电子(南京)有限公司 A kind of Multi-Machine Synchronous communication system and method
CN107346294A (en) * 2016-05-04 2017-11-14 上海商米科技有限公司 Data-flow-control system and method based on SPI protocol
CN112214440A (en) * 2020-10-10 2021-01-12 北京寓乐世界教育科技有限公司 Communication method based on SPI communication
CN114528235A (en) * 2022-01-21 2022-05-24 厦门亿联网络技术股份有限公司 SPI (Serial peripheral interface) -based communication method, slave equipment and system
CN114528235B (en) * 2022-01-21 2024-05-31 厦门亿联网络技术股份有限公司 SPI-based communication method, slave device and system

Similar Documents

Publication Publication Date Title
CN103077144A (en) Serial peripheral interface (SPI) communication interface for ensuring data integrity, and communication method thereof
CN102819512B (en) A kind of full-duplex communication device based on SPI and method thereof
CN103714029A (en) Novel two-line synchronous communication protocol and application
CN107907814B (en) Method for improving mass production test efficiency of chips
CN206773693U (en) A kind of PCIe Riser cards for meeting OCP Mezzanine card standards
CN105335548B (en) A kind of MCU emulation mode for ICE
CN106569416B (en) Method and device for multiplexing serial interface and simulation debugging interface of microcontroller
CN102073611B (en) I2C bus control system and method
CN104142876A (en) Function verification method and verification environmental platform for USB (universal serial bus) equipment controller modules
CN203260029U (en) System chip prototype verification debugging device based on field programmable gate array (FPGA)
CN110399324A (en) It interrupts converter and interrupts conversion method
CN111008102B (en) FPGA accelerator card high-speed interface SI test control device, system and method
CN203117968U (en) SPI (Serial Peripheral Interface) communication interface
CN105068955A (en) Local bus structure and data interaction method
CN102508799B (en) Automatic control method, system and USB (universal serial bus) device
CN105718396B (en) A kind of I of big data master transmissions2C bus units and its means of communication
CN104063297A (en) Method and device capable of diagnosing computer hardware through USB interfaces
CN103593316B (en) A kind ofly reduce the method that MCU interruption takies I2C bus time
CN104123246A (en) Interface expansion device and serial attached SCSI expander
CN102708079B (en) Be applied to the method and system of the control data transmission of microcontroller
CN103257606A (en) USB interface high-speed and real-time sampling logic analyzer
CN102110066B (en) Tax-control encryption card control method
CN113986600B (en) Test method and device for chip serial interface and chip
Szecówka et al. USB receiver/transmitter for FPGA implementation
CN104182317B (en) A kind of DMI bus signals Integrity Testing

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
ASS Succession or assignment of patent right

Owner name: SHANGHAI AUTOMATION INSTRUMENTATION CO., LTD.

Free format text: FORMER OWNER: SHANGHAI AUTOMATIC INDUSTRUMENT AND METER CO LTD

Effective date: 20150612

C41 Transfer of patent application or patent right or utility model
TA01 Transfer of patent application right

Effective date of registration: 20150612

Address after: Zhabei District Shanghai City 200072 West Guangzhong Road No. 191 Building No. 7

Applicant after: Shanghai instrument and meter for automation company limited

Address before: 200233, No. 41 Rainbow Road, Shanghai, Xuhui District

Applicant before: Shanghai Automatic Industrument and Meter Co., Ltd.

WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20130501

WD01 Invention patent application deemed withdrawn after publication