KR101565584B1 - Method and Apparatus for Transmitting Data Based on SPI Communication - Google Patents
Method and Apparatus for Transmitting Data Based on SPI Communication Download PDFInfo
- Publication number
- KR101565584B1 KR101565584B1 KR1020140041516A KR20140041516A KR101565584B1 KR 101565584 B1 KR101565584 B1 KR 101565584B1 KR 1020140041516 A KR1020140041516 A KR 1020140041516A KR 20140041516 A KR20140041516 A KR 20140041516A KR 101565584 B1 KR101565584 B1 KR 101565584B1
- Authority
- KR
- South Korea
- Prior art keywords
- clk
- spi
- edge
- signal
- cpol
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
-
- 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
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Synchronisation In Digital Transmission Systems (AREA)
Abstract
SPI 통신 기반의 데이터 전송 장치 및 방법을 개시한다.
본 실시예의 일 측면에 의하면, 슬레이브 장치가 SPI 동작 모드를 검출하는 방법에 있어서, SPI 버스를 통해 수신한 CLK 및 CSB를 이용하여 CPOL를 결정하는 과정과, MOSI 신호를 디코딩한 결과를 사전에 약속된 신호패턴과 비교하여, 마스터 장치가 MOSI 신호 전송에 사용한 CLK의 에지를 판단하는 과정과, 결정된 CPOL 및 판단된 CLK의 에지를 기초로 CPHASE(Clock Phase)를 결정하는 과정을 포함하는 것을 특징으로 하는 SPI 동작 모드 검출 방법을 제공한다.An apparatus and method for data transmission based on SPI communication are disclosed.
According to an aspect of the present invention, there is provided a method for a slave device to detect an SPI operation mode, comprising: determining CPOL using CLK and CSB received via an SPI bus; Determining a CPHASE (Clock Phase) based on the determined CPOL and the determined edge of the CLK, comparing the detected signal pattern with the signal pattern of the master device, determining the edge of the CLK used by the master device for MOSI signal transmission, The method comprising:
Description
본 실시예는 SPI 통신에서 통신 방식을 결정하는 클럭 극성 및 클럭 위상을 검출하는 장치 및 방법에 관한 것이다. The present embodiment relates to an apparatus and method for detecting a clock polarity and a clock phase for determining a communication method in SPI communication.
이 부분에 기술된 내용은 단순히 본 실시예에 대한 배경 정보를 제공할 뿐 종래기술을 구성하는 것은 아니다.The contents described in this section merely provide background information on the present embodiment and do not constitute the prior art.
도 1은 시리얼 직렬 인터페이스(SPI : serial peripheral interface) 통신에서 기존의 슬레이브 장치의 구성을 나타낸 예시도이다. SPI통신은 4개의 신호에 의해 데이터 송수신이 이루어진다. MOSI(Master Out Slave In; 120)신호는 마스터에 의해서 발생하여 슬레이브가 수신하는 신호이고, MISO(Master In Slave Out; 130)신호는 슬레이브가 발생시켜 마스터가 수신하는 신호이다. 또한 CLK(Clock; 110)는 마스터에 의해 발생하는 마스터와 슬레이브간에 데이터를 전송하기 위해 동기화하는 신호이다. CSB(Chip Select Bar; 140)는 마스터가 발생시키며 주변기기나 슬레이브 장치들을 선택하는 신호로써, CSB 신호가 낮은(low) 값일 때, 슬레이브가 활성화된다. FIG. 1 is a diagram illustrating a configuration of a conventional slave device in a serial peripheral interface (SPI) communication. In SPI communication, data transmission / reception is performed by four signals. The Master Out Slave In (MOSI) signal is a signal generated by the master and received by the slave. The master in slave out (MISO) signal is a signal generated by the slave and received by the master. CLK (Clock) 110 is a signal synchronized to transfer data between a master and a slave generated by a master. A CSB (Chip Select Bar) 140 is a signal generated by the master and selecting peripheral devices or slave devices. When the CSB signal is low, the slave is activated.
또 다른 필요로 하는 신호 값으로는 클럭 극성(CPOL; Clock Polarity; 150) 및 클럭 위상(CPHASE; Clock Phase; 160)이 있다. 이 신호들은 마스터에서 보내져서 샘플링되는 클럭 신호의 에지를 결정하는 신호이다. CPOL과 CPHASE는 각각 0이나 1 값을 가지게 되므로, 클럭신호가 데이터 전송을 하기 위해 동기화를 하고자 할 때, CPOL과 CPHASE가 각각 0이냐 1이냐에 따라 전송하는 방법이 4가지가 된다. 따라서 전송 방법을 정하기 위해선 필수적으로 CPOL과 CPHASE를 알아야 한다.Another required signal value is a clock polarity (CPOL) 150 and a clock phase (CPHASE) 160. These signals are the signals that are sent from the master to determine the edge of the clock signal to be sampled. Since CPOL and CPHASE have 0 or 1 value respectively, when the clock signal is synchronized to perform data transmission, there are four methods of transmitting according to whether CPOL and CPHASE are 0 or 1 respectively. Therefore, it is essential to know CPOL and CPHASE to determine transmission method.
SPI 복호부(170)는 마스터로부터 수신되는 CPOL과 CPHASE 값을 이용하여 SPI 동작 모드를 판단하고, 판단한 동작 모드에 따라 마스터가 보낸 신호를 디코딩하는 역할을 한다.The SPI decoding unit 170 determines the SPI operation mode using the CPOL and CPHASE values received from the master, and decodes a signal transmitted from the master according to the determined operation mode.
종래 기술에 따르면 데이터를 송수신하기 위해 필요한 4개의 신호를 받기 위한 핀 이외에 슬레이브가 CPOL과 CPHASE를 정한 신호를 받기 위해 추가적으로 핀이 2개 사용하게 되는 문제가 있다. There is a problem in that, in addition to the pins for receiving four signals required for transmitting and receiving data, the slave uses two additional pins to receive the CPOL and CPHASE signals.
본 실시예는, 마스터로부터 CPOL과 CPHASE에 대한 신호를 받기 위한 추가적인 핀의 사용 없이, CPOL과 CPHASE를 검출하는 장치 및 방법을 제공하는 데 주된 목적이 있다.The main purpose of this embodiment is to provide an apparatus and method for detecting CPOL and CPHASE without using additional pins for receiving CPOL and CPHASE signals from the master.
본 실시예의 일 측면에 의하면, 데이터 통신 시스템에 있어서 SPI 버스와, 상기 SPI 버스에 연결된 마스터 장치와, 상기 SPI 버스에 연결된 하나 이상의 슬레이브(Slave) 장치를 포함하되, 상기 슬레이브 장치는 상기 마스터 장치가 사용하는 SPI 통신 모드를 결정함에 있어서, 상기 SPI 버스를 통해 수신되는 CLK, CSB 및 MOSI 신호 중 적어도 일부를 기초로 CPOL 및 CPHASE를 검출하는 것을 특징으로 하는 데이터 통신 시스템을 제공한다.According to an aspect of the present invention, there is provided a data communication system including an SPI bus, a master device connected to the SPI bus, and one or more slave devices connected to the SPI bus, And determines a CPOL and CPHASE based on at least a part of CLK, CSB, and MOSI signals received through the SPI bus in determining an SPI communication mode to be used.
본 실시예의 다른 측면에 의하면, 슬레이브 장치가 SPI 통신 모드를 검출하는 방법에 있어서, SPI 버스를 통해 수신한 CLK 및 CSB를 이용하여 CPOL를 결정하는 과정과, MOSI 신호를 디코딩한 결과를 사전에 약속된 신호패턴과 비교하여, 마스터 장치가 MOSI 신호 전송에 사용한 CLK의 에지를 판단하는 과정과, 결정된 CPOL 및 판단된 CLK의 에지를 기초로 CPHASE를 결정하는 과정을 포함하는 것을 특징으로 하는 SPI 동작 모드 검출 방법을 제공한다.According to another aspect of the present invention, there is provided a method for a slave device to detect an SPI communication mode, comprising: determining a CPOL using CLK and CSB received via an SPI bus; Determining a CPHASE based on the determined CPOL and an edge of the determined CLK; comparing the signal pattern with a predetermined signal pattern to determine an edge of the CLK used by the master device for transmitting the MOSI signal; Detection method.
이상에서 설명한 바와 같이 본 실시예에 의하면, CPOL과 CPHASE를 알기 위한 별도의 신호를 받을 필요 없이 CPOL과 CPHASE를 검출하여 알아낼 수 있으며, 이에 따라 CPOL과 CPHASE에 대한 신호를 받을 핀의 사용을 막아 핀 낭비를 막을 수 있는 효과가 있다.As described above, according to the present embodiment, it is possible to detect and detect the CPOL and the CPHASE without receiving a separate signal for knowing the CPOL and the CPHASE, thereby preventing the use of the pin for receiving the CPOL and CPHASE signals, It is effective to prevent waste.
도 1은 SPI 통신에서 기존의 슬레이브 장치의 구성을 나타낸 예시도이다.
도 2는 마스터와 슬레이브 간의 SPI 통신을 하는 구성도이다.
도 3은 각각의 CPOL과 CPHASE에 따른 4가지의 SPI 동작 모드를 나타낸 타이밍 다이어그램이다.
도 4는 SPI 통신에서 본 발명의 일 실시예에 따른 슬레이브 장치의 구성을 나타낸 예시도이다.
도 5는 본 발명의 일 실시예에 따른 SPI 모드 검출부의 구성도이다.
도 6은 본 발명의 일 실시예에 따른 CPOL과 CPHASE를 검출하는 방법을 나타낸 순서도이다.1 is a diagram illustrating an exemplary configuration of a conventional slave device in SPI communication.
2 is a configuration diagram for performing SPI communication between a master and a slave.
3 is a timing diagram showing four SPI operation modes according to CPOL and CPHASE, respectively.
4 is an exemplary diagram illustrating a configuration of a slave device according to an embodiment of the present invention in SPI communication.
5 is a configuration diagram of an SPI mode detecting unit according to an embodiment of the present invention.
6 is a flowchart illustrating a method of detecting CPOL and CPHASE according to an embodiment of the present invention.
이하, 본 발명의 일부 실시예들을 예시적인 도면을 통해 상세하게 설명한다. 각 도면의 구성요소들에 참조부호를 부가함에 있어서, 동일한 구성요소들에 대해서는 비록 다른 도면상에 표시되더라도 가능한 한 동일한 부호를 가지도록 하고 있음에 유의해야 한다. 또한, 본 발명을 설명함에 있어, 관련된 공지 구성 또는 기능에 대한 구체적인 설명이 본 발명의 요지를 흐릴 수 있다고 판단되는 경우에는 그 상세한 설명은 생략한다.Hereinafter, some embodiments of the present invention will be described in detail with reference to exemplary drawings. It should be noted that, in adding reference numerals to the constituent elements of the drawings, the same constituent elements are denoted by the same reference numerals even though they are shown in different drawings. In the following description of the present invention, a detailed description of known functions and configurations incorporated herein will be omitted when it may make the subject matter of the present invention rather unclear.
또한, 본 발명의 구성 요소를 설명하는 데 있어서, 제 1, 제 2, A, B, (a), (b) 등의 용어를 사용할 수 있다. 이러한 용어는 그 구성 요소를 다른 구성 요소와 구별하기 위한 것일 뿐, 그 용어에 의해 해당 구성 요소의 본질이나 차례 또는 순서 등이 한정되지 않는다. 명세서 전체에서, 어떤 부분이 어떤 구성요소를 '포함', '구비'한다고 할 때, 이는 특별히 반대되는 기재가 없는 한 다른 구성요소를 제외하는 것이 아니라 다른 구성요소를 더 포함할 수 있는 것을 의미한다. 또한, 명세서에 기재된 '…부' 등의 용어는 적어도 하나의 기능이나 동작을 처리하는 단위를 의미하며, 이는 하드웨어나 소프트웨어 또는 하드웨어 및 소프트웨어의 결합으로 구현될 수 있다.In describing the components of the present invention, terms such as first, second, A, B, (a), and (b) may be used. These terms are intended to distinguish the constituent elements from other constituent elements, and the terms do not limit the nature, order or order of the constituent elements. Throughout the specification, when an element is referred to as being "comprising" or "comprising", it means that it can include other elements as well, without excluding other elements unless specifically stated otherwise . In addition, '... Quot ;, " part, " and the like denote a unit for processing at least one function or operation, which may be implemented by hardware, software, or a combination of hardware and software.
도 2는 마스터(210)와 슬레이브(220(a), 220(b), 220(c)) 간의 SPI 통신을 하는 구성을 도시한다.2 shows a configuration for performing SPI communication between the
SPI (Serial Peripheral Interconnect) 통신는 Motorola사에 의해 개발된 전이중 (full duplex) 통신이 가능한 동기 통신 규격이다. 장치들은 마스터 - 슬레이브 모드로 동작하며 마스터가 동기를 위한 클럭을 출력한다. 각 SPI 슬레이브 장치는 CSB가 활성화되었을 때에만 동작한다. 따라서 마스터는 여러 개의 CSB 버스를 통해 슬레이브 장치들에 CSB를 송신하고 한 순간에 하나의 슬레이브 장치만 선택하는 방법을 사용하여 두 개 이상의 슬레이브 장치들을 구동할 수 있다 Serial Peripheral Interconnect (SPI) communication is a synchronous communication standard developed by Motorola that enables full duplex communication. The devices operate in master-slave mode and the master outputs the clock for synchronization. Each SPI slave device operates only when the CSB is activated. Thus, the master can drive two or more slave devices using the method of sending CSB to slave devices over multiple CSB buses and selecting only one slave device at a time
도 2에 표시된 4개의 버스는 SPI 통신에서 정의된 데이터를 송수신하는 신호 를 전송하는 버스로, 4개의 버스로부터 전송되는 신호들은 다음과 같다. 첫 번째로, CLK는 마스터(210)가 출력하는 동기용 클럭이다. 이는 제조사에 따라 SCLK, SCK로 불리기도 한다. 두 번째로, CSB는 마스터(210)가 슬레이브(220(a), 220(b), 220(c))를 선택하기 위해 출력하는 신호이다. 이는 제조사에 따라 SS, CS, CSN, STE로 불리기도 한다. 세 번째로, MOSI는 마스터(210)의 출력으로 슬레이브(220(a), 220(b), 220(c))로 정보를 보내기 위한 신호이다. 이는 제조사에 따라 SDI, SI, DI, DIN으로 불리기도 한다. 네 번째로, MISO는 슬레이브(220(a), 220(b), 220(c))의 출력으로 마스터(210)가 슬레이브의 정보를 받기 위한 신호이다. 이는 제조사에 따라 SDO, DO, SO, DOUT으로 불리기도 한다.The four buses shown in FIG. 2 are buses for transmitting and receiving data defined in the SPI communication, and the signals transmitted from the four buses are as follows. First, CLK is a synchronization clock output from the
일반적으로 슬레이브는 CSB가 낮은(Low) 상태인 동안에만 활성화된다. 통신을 진행하기 위해서 마스터는 우선 CSB에 낮은(Low) 상태를 출력하여 해당 슬레이브를 활성화시킨다. 그런 다음 마스터는 클럭 신호의 핀에 동기를 위한 CLK를 출력하는데 이 CLK에 맞추어 MOSI 신호의 버스로 데이터를 한 비트씩 내보낸다. 이와 동시에 마스터는 자신이 출력하는 CLK에 맞추어 MISO 신호를 한 비트씩 읽는다. 다시 말해서 마스터는 자신의 출력인 CLK에 맞추어 MOSI 신호의 핀으로 데이터를 내보내며 동시에 MISO 신호의 버스로는 데이터를 수신한다. SPI 통신은 언제나 양방향 통신을 진행한다. 수신되는 데이터는 상황에 따라 의미가 있는 값일 수도 있고 의미 없는 값일 수도 있다. 마찬가지로 슬레이브의 데이터를 읽기 위하여 CLK에 맞추어 MISO 신호의 버스로 입력을 받는 동안 MOSI 신호의 버스로는 데이터가 출력된다.Generally, slaves are enabled only while CSB is low. In order to communicate, the master first outputs a low state to the CSB to activate the corresponding slave. The master then outputs a CLK for synchronization to the pin of the clock signal, which sends out the data to the bus of the MOSI signal bit by bit. At the same time, the master reads the MISO signal bit by bit according to the CLK it outputs. In other words, the master outputs the data to the pin of the MOSI signal in accordance with its output CLK, and at the same time receives the data to the bus of the MISO signal. SPI communication always carries out bidirectional communication. The received data may be a meaningful value or a meaningless value depending on the situation. Similarly, data is output to the bus of the MOSI signal while receiving the input of the MISO signal to the CLK in order to read the data of the slave.
보통 SPI 통신은 8 비트 단위로 진행되지만 12 비트나 16 비트 또는 그 이상의 길이가 한 단위가 될 수도 있다. 비트 전송 순서에 대한 규정은 없다. 데이터의 전송은 최상위 비트(MSB; Most Significant Bit)부터 시작될 수도 있고 최하위 비트(LSB; Least Significant Bit)부터 시작될 수도 있다. SPI 규격은 이런 부분까지 규정하고 있지는 않으며 마스터와 슬레이브 사이의 약속에 따라 결정된다. Normally, SPI communication proceeds in 8-bit units, but it can be 12 bits or 16 bits or more in length. There is no specification for bit transmission order. The transmission of data may start at the most significant bit (MSB) or may start at the least significant bit (LSB). The SPI specification does not specify this part, but is determined by the commitment between the master and the slave.
데이터를 전송하는 경우 한 단위의 데이터마다 보내는 단일 바이트 방식(Single Byte Mode)이 있고, 계속적으로 데이터를 전송하는 다중 바이트 방식(Multiple Byte Mode)이 있다. 단일 바이트 방식은 한 단위의 데이터를 보낼 때마다 CSB를 전송하여야 하지만, 다중 바이트 방식은 CSB를 낮은 상태로 설정한 후 모든 데이터를 다 보낼 때까지 이 상태를 유지하고 있다가 데이터의 전송이 끝났을 때 CSB를 높은(High) 상태로 바꿀 수 있다. When data is transmitted, there is a single-byte mode in which data is transmitted per unit of data, and a multiple-byte mode in which data is continuously transmitted. In the single-byte method, the CSB should be transmitted every time one unit of data is transmitted. However, the multi-byte method maintains this state until all the data is transmitted after setting the CSB to a low state. CSB can be changed to a high state.
또 다른 인자로 CPOL과 CPHASE가 있다. 이들은 SPI통신에 사용되는 클럭 신호의 유형을 결정하는 중요요소이다. CPOL은 CLK의 기본 값(Base Value)에 따라 나누어진다. 여기서 기본 값이란, SPI 버스가 활성화되지 않은 상태 즉, CSB가 낮은 상태를 유지하고 있지 않은 때, CLK가 갖는 값을 의미한다. CPOL이 0인 경우 CLK의 기본 값은 0이고, CPOL이 1인 경우 CLK의 기본 값은 1이 된다. CPHASE는 데이터를 샘플링하는 때가 언제인지 여부에 따라 나뉜다. 클럭의 에지가 상승 에지(Rising Edge)인지 하강 에지(Falling Edge)인지와 무관하게, CPHASE가 0인 경우 데이터는 첫 번째 클럭의 에지에서 샘플링되며, CPHASE가 1인 경우 데이터는 두 번째 클럭의 에지에서 샘플링된다. 이처럼 CPOL과 CPHASE가 각각 0과 1을 갖기 때문에 CPOL과 CPHASE의 값에 따라 4가지 SPI 동작 모드를 가지게 된다.Another factor is CPOL and CPHASE. These are important factors in determining the type of clock signal used in SPI communications. CPOL is divided according to the base value of CLK. Here, the default value means the value of CLK when the SPI bus is not activated, that is, when the CSB is not kept in a low state. If CPOL is 0, the default value of CLK is 0. If CPOL is 1, the default value of CLK is 1. CPHASE depends on when it is time to sample the data. Regardless of whether the edge of the clock is a rising edge or a falling edge, data is sampled at the edge of the first clock if CPHASE is 0 and data is sampled at the edge of the second clock when CPHASE is 1, Lt; / RTI > Since CPOL and CPHASE have 0 and 1, respectively, they have four SPI operation modes according to CPOL and CPHASE values.
도 3은 4가지 SPI 동작 모드를 나타낸 타이밍 다이어그램이다. 3 is a timing diagram illustrating four SPI modes of operation.
사실상 CLK의 매 주기마다 샘플링이 이루어지지만, 도 3에서는 편의상 한 주기에서 샘플링(310)만을 예시적으로 도시하였다. 도 3의 (a)는 CPOL과 CPHASE가 각각 0일 때의 경우를 나타낸 타이밍 다이어그램이다. CPOL이 0이기 때문에 클럭은 기본값으로 0을 갖게 되어 CLK는 0부터 발생한다. 또한 CPHASE가 0이기 때문에, 첫 번째 클럭의 에지에서 샘플링되므로, 상승 에지일 때 데이터는 샘플링된다. 이후 하강 에지일 때 데이터가 전달된다. 도 3의 (b)는 CPOL은 1이고 CPHASE가 0일 때의 경우를 나타낸 타이밍 다이어그램이다. CPOL이 1이기 때문에 클럭은 기본값으로 1을 갖게 되어 CLK는 1부터 발생한다. 또한 CPHASE가 0이기 때문에 첫 번째 클럭의 에지에서 샘플링되므로, 하강 에지일 때 데이터는 샘플링된다. 이후 상승 에지일 때 데이터가 전달된다. 도 3의 (c)는 CPOL이 0이고 CPHASE가 1인 경우를 나타낸 타이밍 다이어그램이다. CPOL이 0이기 때문에 클럭은 기본값으로 0을 갖게 되어 CLK는 0부터 발생한다. 또한 CPHASE가 0이기 때문에, 두 번째 클럭의 에지에서 샘플링되므로, 하강 에지일 때 데이터는 샘플링된다. 이후 상승 에지일 때 데이터가 전달된다. 도 3의 (d)는 CPOL이 1이고 CPHASE가 1인 경우를 나타낸 타이밍 다이어그램이다. CPOL이 1이기 때문에 클럭은 기본값으로 1을 갖게 되어 CLK는 1부터 발생한다. 또한 CPHASE가 1이기 때문에, 두 번째 클럭의 에지에서 샘플링되므로, 상승 에지일 때 데이터는 샘플링된다. 이후 하강 에지일 때 데이터가 전달된다.In practice, sampling is performed every cycle of the CLK, but in FIG. 3, only sampling 310 in one cycle is illustrated for convenience. 3 (a) is a timing diagram showing a case where CPOL and CPHASE are 0, respectively. Since CPOL is 0, the clock has a default value of 0, so CLK occurs from 0. Since CPHASE is 0, it is sampled at the edge of the first clock, so data is sampled at the rising edge. Then, data is transmitted when the falling edge. FIG. 3 (b) is a timing diagram showing a case where the CPOL is 1 and the CPHASE is 0. Since CPOL is 1, the clock has a default of 1, so CLK occurs from 1. Since CPHASE is 0, it is sampled at the edge of the first clock, so data is sampled at the falling edge. The data is then transmitted on the rising edge. FIG. 3 (c) is a timing diagram showing a case where the CPOL is 0 and the CPHASE is 1. Since CPOL is 0, the clock has a default value of 0, so CLK occurs from 0. Since CPHASE is 0, it is sampled at the edge of the second clock, so data is sampled at the falling edge. The data is then transmitted on the rising edge. 3 (d) is a timing diagram showing a case where the CPOL is 1 and the CPHASE is 1. Since CPOL is 1, the clock has a default of 1, so CLK occurs from 1. Since CPHASE is 1, it is sampled at the edge of the second clock, so data is sampled at the rising edge. Then, data is transmitted when the falling edge.
도 4는 SPI 통신에서 본 발명의 일 실시예에 따른 슬레이브 장치의 구성을 나타낸 예시도이다.4 is an exemplary diagram illustrating a configuration of a slave device according to an embodiment of the present invention in SPI communication.
본 발명의 일 실시예에 따른 슬레이브 장치(400)는 SPI 검출부(410) 및 SPI 복호부(420)를 포함한다.The
SPI 검출부(410)는 SPI 버스를 통해 수신되는 CLK, CSB 및 MOSI 신호를 이용하여 CPOL과 CPHASE를 검출하고, 검출된 CPOL과 CPHASE를 SPI 복호기(420)에 제공하는 역할을 한다.The
SPI 복호기(420)는 SPI 검출부(410)로부터 수신되는 CPOL과 CPHASE 값을 이용하여 SPI 동작 모드를 판단하고, 판단한 SPI 동작 모드에 따라 마스터가 보낸 신호를 디코딩하는 역할을 한다.The
도 1과 관련하여 설명한 바와 같이, 종래 기술에 따르면 CLK, CSB, MOSI 및 MISO 신호 외에도 CPOL과 CPHASE도 함께 송수신하기 위한 핀이 필요하다. 이에 반해, 본 발명의 일 실시예는 CLK, CSB 및 MOSI 신호로부터 CPOL과 CPHASE 를 검출하므로, 도 4에서 보듯이, CLK, CSB, MOSI 및 MISO 신호를 송수신을 위한 핀 외에, 별도로 CPOL과 CPHASE를 수신하기 위한 핀이 불필요하다.1, in addition to the CLK, CSB, MOSI, and MISO signals according to the related art, a pin for transmitting and receiving the CPOL and the CPHASE is also required. In contrast, the embodiment of the present invention detects CPOL and CPHASE from the CLK, CSB, and MOSI signals. Therefore, as shown in FIG. 4, in addition to pins for transmitting and receiving CLK, CSB, MOSI, and MISO signals, No pin to receive is needed.
도 5는 본 발명의 일 실시예에 따른 SPI 모드 검출부의 구성도이다.5 is a configuration diagram of an SPI mode detecting unit according to an embodiment of the present invention.
검출부(410)는 SPI 버스를 통해 수신한 정보를 이용하여 CPOL과 CPHASE를 검출하며, 이를 위해 본 발명의 일 실시예에서는 극성 검출부(510), 디코딩부(520), 에지 판단부(530) 및 위상 검출부(540)를 포함하도록 구성된다.The
극성 검출부(510)는 CSB 신호가 비활성 상태(즉, 하이 레벨)일 때의 CLK 신호의 레벨(즉, CLK 신호의 기본값(Base Value))을 이용하여 CPOL을 검출한다.The
디코딩부(520)는 CLK의 상승 에지(또는 하강 에지)를 이용하여 MOSI 신호를 샘플링하고, 샘플링된 신호를 디코딩한다. 디코딩부(520)는 마스터가 사용한 SPI 통신 모드를 알지 못하므로, 마스터가 사용한 SPI 통신 모드에 무관하게, 사전설정에 따라, CLK의 상승 에지(또는 하강 에지)를 이용한다.The
에지 핀단부(530)는 사전에 약속된 패턴값과 디코딩부(520)에서 디코딩한 MOSI 신호 패턴을 비교한다.The edge
위상 검출부(540)는 에지 판단부(530)의 비교 결과 및 극성 검출부(510)에서 검출한 CPOL을 이용하여 CPHASE를 검출한다.The
이하에서는 도 6을 참조하여, CPOL 및 CPHASE을 검출하는 방법을 보다 상세히 설명하기로 한다. 도 6은 본 발명의 일 실시예에 따른 CPOL과 CPHASE를 검출하는 방법을 나타낸 순서도이다.Hereinafter, a method for detecting CPOL and CPHASE will be described in more detail with reference to FIG. 6 is a flowchart illustrating a method of detecting CPOL and CPHASE according to an embodiment of the present invention.
SPI 동작 모드를 확인하기 위한 초기 설정단계에서, 슬레이브는 SPI 버스를 통하여 마스터에서 보내는 출력신호를 수신한다(S610). 다만, 본 발명의 일 실시예에 따르면 CLK, CSB, MOSI 및 MISO 신호만을 이용하여 CPOL과 CPHASE를 검출하므로, 마스터로부터 별도로 CPOL과 CPHASE에 대한 신호를 수신할 필요가 없다.In the initial setting step for confirming the SPI operation mode, the slave receives the output signal from the master via the SPI bus (S610). However, according to the embodiment of the present invention, since CPOL and CPHASE are detected using only CLK, CSB, MOSI, and MISO signals, it is not necessary to separately receive CPOL and CPHASE signals from the master.
다음으로, CSB와 CLK를 이용하여 CPOL을 검출한다(S620). CPOL을 검출할 때는, CSB가 비활성 상태일 때를 이용한다. 이는 CSB가 비활성 상태일 때, CLK가 기본 값(Base Value)을 갖기 때문이다. 따라서 CSB가 비활성 상태일 때, CLK의 기본 값이 0이라면 CPOL은 0이 되고, CLK의 기본 값이 1이라면 CPOL은 1이 된다.Next, the CPOL is detected using the CSB and the CLK (S620). When CPOL is detected, it is used when CSB is inactive. This is because CLK has a base value when the CSB is inactive. Therefore, when the CSB is inactive, the CPOL becomes 0 if the CLK default value is 0, and the CPOL becomes 1 if the CLK default value is 1.
다음으로, 사전설정에 따라 CLK의 상승 에지 및 하강 에지를 택일적으로 사용하여, SPI 버스를 이용하여 수신한 MOSI 신호의 패턴을 디코딩한다(S630). SPI 동작 모드를 확인하기 위한 초기 설정단계에서 슬레이브는 아직 CPHASE를 모르는 상태이므로, 사전에 설정에 따라 CLK의 상승 에지를 사용하여 MOSI 신호를 디코딩하거나 CLK의 하강 에지를 사용하여 MOSI 신호를 디코딩한다.Next, the pattern of the MOSI signal received using the SPI bus is decoded using the rising edge and the falling edge of the CLK in accordance with the preset (S630). In the initial setup stage to check the SPI operation mode, the slave does not yet know the CPHASE, so it decodes the MOSI signal using the rising edge of CLK or decodes the MOSI signal using the falling edge of CLK in advance.
다음으로, 슬레이브는 디코딩한 신호의 패턴과 사전에 약속된 패턴을 비교하여, 마스터가 CLK의 상승 에지를 사용했는지 또는 하강 에지를 사용했는지 여부를 판단한다(S640). 예를 들어, CLK의 상승 에지를 사용하여 디코딩한 MOSI 신호의 패턴이 사전에 약속된 패턴신호와 일치한다면, CLK의 상승 에지를 사용하는 것이 마스터가 사용한 SPI 동작 모드(즉, 마스터가 사용한 CLK의 에지)와 일치한다는 것을 알 수 있다. 반대로 일치하지 않는다면 마스터는 CLK의 하강 에지를 사용했다는 것을 알 수 있다.Next, the slave compares the pattern of the decoded signal with the predetermined pattern, and determines whether the master uses the rising edge or the falling edge of the CLK (S640). For example, if the pattern of the MOSI signal decoded using the rising edge of CLK matches the previously promised pattern signal, then using the rising edge of CLK is the SPI mode of operation used by the master Edge). Conversely, if they do not match, the master knows that they used the falling edge of CLK.
다만, CPHASE가 0인 경우에도 상승 에지를 사용하는 모드(도 3의 (a))가 존재하고, CPHASE가 1인 경우에도 상승 에지를 사용하는 모드(도 3의 (d))가 존재하기 때문에, 위 결과만으로는 CPHASE를 검출할 수 없다.However, even when the CPHASE is 0, there is a mode (Fig. 3 (a)) that uses the rising edge and a mode (Fig. 3 (d)) that uses the rising edge even when the CPHASE is 1 , The above result alone can not detect CPHASE.
따라서, 슬레이브는 S640 과정에서 판단한 마스터가 사용한 CLK의 에지와 함께 S620 과정에서 검출한 CPOL을 이용하여 CPHASE를 결정한다(S650). 예를 들어, S640 과정에서 마스터가 CLK의 상승 에지를 사용한 것으로 판단된 경우를 가정하면, S620 과정에서 결정된 CPOL이 0이라면 CPHASE는 0을 가질 수밖에 없으며(도 3(a)의 모드에 해당), 결정된 CPOL이 1이라면 CPHASE는 1을 가질 수밖에 없다(도 3(d)의 모드에 해당). Accordingly, the slave determines the CPHASE using the CPOL detected in step S620 together with the edge of the CLK used by the master determined in step S640 (S650). For example, if it is determined in step S640 that the master uses the rising edge of the CLK, CPHASE has to be 0 (corresponding to the mode of FIG. 3A) if the CPOL determined in step S620 is 0, If the determined CPOL is 1, CPHASE has to have 1 (corresponding to the mode of FIG. 3 (d)).
위와 같은 방식으로 결정한 CPOL과 CPHASE를 이용하여, 슬레이브는 마스터가 사용하는 SPI 통신 방식을 판단한다(S660). Using the CPOL and CPHASE determined in the above manner, the slave determines the SPI communication method used by the master (S660).
도 6에서는 과정 S610 내지 과정 S650을 순차적으로 실행하는 것으로 기재하고 있으나, 이는 본 발명의 일 실시예의 기술 사상을 예시적으로 설명한 것에 불과한 것이다. 다시 말해, 본 발명의 일 실시예가 속하는 기술 분야에서 통상의 지식을 가진 자라면 본 발명의 일 실시예의 본질적인 특성에서 벗어나지 않는 범위에서 도 6에 기재된 순서를 변경하여 실행하거나 과정 S610 내지 과정 S660 중 하나 이상의 과정을 병렬적으로 실행하는 것으로 다양하게 수정 및 변형하여 적용 가능할 것이므로, 도 6은 시계열적인 순서로 한정되는 것은 아니다.Although it is described in FIG. 6 that steps S610 to S650 are sequentially executed, this is merely illustrative of the technical idea of an embodiment of the present invention. In other words, those skilled in the art will appreciate that the present invention can be implemented by changing the order described in FIG. 6 without departing from the essential characteristics of an embodiment of the present invention, or by executing one of steps S610 to S660 6 is not limited to the time-series order because it can be variously modified and modified by being executed in parallel.
이상의 설명은 본 실시예의 기술 사상을 예시적으로 설명한 것에 불과한 것으로서, 본 실시예가 속하는 기술 분야에서 통상의 지식을 가진 자라면 본 실시예의 본질적인 특성에서 벗어나지 않는 범위에서 다양한 수정 및 변형이 가능할 것이다. 따라서, 본 실시예들은 본 실시예의 기술 사상을 한정하기 위한 것이 아니라 설명하기 위한 것이고, 이러한 실시예에 의하여 본 실시예의 기술 사상의 범위가 한정되는 것은 아니다. 본 실시예의 보호 범위는 아래의 청구범위에 의하여 해석되어야 하며, 그와 동등한 범위 내에 있는 모든 기술 사상은 본 실시예의 권리범위에 포함되는 것으로 해석되어야 할 것이다.The foregoing description is merely illustrative of the technical idea of the present embodiment, and various modifications and changes may be made to those skilled in the art without departing from the essential characteristics of the embodiments. Therefore, the present embodiments are to be construed as illustrative rather than restrictive, and the scope of the technical idea of the present embodiment is not limited by these embodiments. The scope of protection of the present embodiment should be construed according to the following claims, and all technical ideas within the scope of equivalents thereof should be construed as being included in the scope of the present invention.
170: SPI 복호부 210: SPI Master
220(a)~220(c): SPI Slave 310: 샘플링 시점
400: SPI Slave 410: SPI 검출부
420: SPI 복호부 510: 극성 검출부
520: 디코딩부 530: 에지 판단부
540: 위상 검출부170: SPI decoding unit 210: SPI Master
220 (a) to 220 (c): SPI Slave 310: sampling point
400: SPI Slave 410: SPI detector
420: SPI decoding unit 510: Polarity detection unit
520: decoding unit 530: edge determining unit
540:
Claims (11)
SPI(Serial Peripheral Interface) 버스;
상기 SPI 버스에 연결된 마스터(Master) 장치; 및
상기 SPI 버스에 연결되며, 상기 SPI 버스를 통해 수신되는 CLK(Clock), CSB(Chip Select Bar) 및 MOSI(Master Out Slave In) 신호 중 적어도 일부를 기초로 CPOL(Clock Polarity) 및 CPHASE(Clock Phase)를 검출하여 상기 마스터 장치가 사용하는 SPI 통신 모드를 결정하는 하나 이상의 슬레이브(Slave) 장치
를 포함하되,
상기 슬레이브 장치는 상기 CSB가 비활성 상태일 때의 상기 CLK 값에 따라 상기 CPOL을 결정하는 극성 검출부를 포함하는 것을 특징으로 하는 데이터 통신 시스템.In a data communication system,
SPI (Serial Peripheral Interface) bus;
A master device connected to the SPI bus; And
(Clock Phase) and CPHASE (Clock Phase) based on at least a part of CLK (Clock), CSB (Chip Select Bar) and MOSI (Master Out Slave In) signals connected to the SPI bus. ) For determining an SPI communication mode to be used by the master device and a slave device
, ≪ / RTI &
Wherein the slave device includes a polarity detector for determining the CPOL according to the CLK value when the CSB is in an inactive state.
상기 슬레이브 장치는,
상기 CLK의 상승 에지 또는 하강 에지를 택일적으로 사용하여, 상기 MOSI 신호를 디코딩하는 디코딩부를 더 포함하는 것을 특징으로 하는 데이터 통신 시스템.The method according to claim 1,
The slave device includes:
Further comprising a decoding unit for decoding the MOSI signal by alternatively using a rising edge or a falling edge of the CLK.
상기 슬레이브 장치는,
상기 MOSI 신호를 디코딩한 결과를 사전에 약속된 신호패턴과 비교하여, 마스터가 MOSI 신호 전송에 사용한 CLK의 에지를 판단하는 에지 판단부를 더 포함하는 것을 특징으로 하는 데이터 통신 시스템.The method of claim 3,
The slave device includes:
Further comprising an edge determining unit for comparing the result of decoding the MOSI signal with a predetermined signal pattern and determining an edge of a CLK used by the master to transmit the MOSI signal.
상기 슬레이브 장치는,
상기 극성 검출부가 결정된 CPOL 및 상기 에지 판단부가 판단된 CLK의 에지를 기초로 CPHASE(Clock Phase)를 결정하는 위상 검출부를 더 포함하는 것을 특징으로 하는 데이터 통신 시스템.5. The method of claim 4,
The slave device includes:
And a phase detector for determining a CPHASE (Clock Phase) based on the CPOL determined by the polarity detector and the edge of the CLK determined by the edge determiner.
상기 사전에 약속된 신호패턴은,
상기 SPI 통신이 단일 바이트 방식인지 또는 다중 바이트 방식인지에 따라, 신호패턴의 길이를 달리하는 것을 특징으로 하는 데이터 통신 시스템.5. The method of claim 4,
The pre-determined signal pattern may be a signal pattern,
Wherein the length of the signal pattern is different depending on whether the SPI communication is a single-byte method or a multi-byte method.
SPI 버스를 통해 수신한 CLK(Clock) 및 CSB(Chip Select Bar)를 이용하여 상기 CSB가 비활성 상태일 때의 CLK 값에 따라 CPOL(Clock Polarity)을 결정하는 과정;
MOSI(Master Out Slave In) 신호를 디코딩한 결과를 사전에 약속된 신호패턴과 비교하여, 마스터 장치가 MOSI 신호 전송에 사용한 CLK의 에지를 판단하는 과정; 및
결정된 CPOL 및 판단된 CLK의 에지를 기초로 CPHASE(Clock Phase)를 결정하는 과정
을 포함하는 것을 특징으로 하는 SPI 동작 모드 검출 방법.A method of detecting a SPI communication mode in a slave device in SPI (Serial Peripheral Interface) communication,
Determining a CPOL (Clock Polarity) according to a CLK value when the CSB is in an inactive state using a CLK (Clock) and a CSB (Chip Select Bar) received via an SPI bus;
Comparing a result of decoding the Master Out Slave In (MOSI) signal with a predetermined signal pattern, and determining an edge of the CLK used by the master device to transmit the MOSI signal; And
The process of determining the CPHASE (Clock Phase) based on the determined CPOL and the edge of the determined CLK
The method comprising the steps of:
CLK의 상승 에지 또는 하강 에지를 택일적으로 사용하여, 상기 MOSI 신호를 디코딩하는 과정을 더 포함하는 것을 특징으로 하는 SPI 동작 모드 검출 방법.8. The method of claim 7,
Further comprising the step of decoding the MOSI signal by alternatively using a rising edge or a falling edge of the clock signal CLK.
상기 디코딩한 결과가 사전에 약속된 신호패턴과 일치하는 경우, 상기 마스터 장치가 MOSI 신호 전송에 사용한 CLK의 에지는 상기 MOSI 신호의 디코딩에 사용한 사용한 CLK의 에지와 동일한 것으로 판단하는 것을 특징으로 하는 SPI 동작 모드 검출 방법.10. The method of claim 9,
And the edge of the CLK used for the MOSI signal transmission is determined to be equal to the edge of the CLK used for decoding the MOSI signal when the decoded result coincides with the predetermined signal pattern. Method of detecting operating mode.
상기 사전에 약속된 신호패턴은,
상기 SPI 통신이 단일 바이트 방식인지 또는 다중 바이트 방식인지에 따라, 신호패턴의 길이를 달리하는 것을 특징으로 하는 SPI 동작 모드 검출 방법.
8. The method of claim 7,
The pre-determined signal pattern may be a signal pattern,
Wherein the length of the signal pattern is different depending on whether the SPI communication is a single-byte method or a multi-byte method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
KR1020140041516A KR101565584B1 (en) | 2014-04-07 | 2014-04-07 | Method and Apparatus for Transmitting Data Based on SPI Communication |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
KR1020140041516A KR101565584B1 (en) | 2014-04-07 | 2014-04-07 | Method and Apparatus for Transmitting Data Based on SPI Communication |
Publications (2)
Publication Number | Publication Date |
---|---|
KR20150116557A KR20150116557A (en) | 2015-10-16 |
KR101565584B1 true KR101565584B1 (en) | 2015-11-04 |
Family
ID=54365558
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
KR1020140041516A KR101565584B1 (en) | 2014-04-07 | 2014-04-07 | Method and Apparatus for Transmitting Data Based on SPI Communication |
Country Status (1)
Country | Link |
---|---|
KR (1) | KR101565584B1 (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR102150068B1 (en) | 2017-12-21 | 2020-08-31 | 주식회사 엘지화학 | Apparatus and method for diagnosing communication fault |
CN116436720B (en) * | 2023-03-07 | 2024-07-26 | 深圳市杰美康机电有限公司 | Method, device and system for online multiaxial parameter writing of EtherCAT |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050172059A1 (en) * | 2004-01-07 | 2005-08-04 | Hitachi, Ltd. | Data communication system and controller |
-
2014
- 2014-04-07 KR KR1020140041516A patent/KR101565584B1/en active IP Right Grant
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050172059A1 (en) * | 2004-01-07 | 2005-08-04 | Hitachi, Ltd. | Data communication system and controller |
Also Published As
Publication number | Publication date |
---|---|
KR20150116557A (en) | 2015-10-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP2924584B1 (en) | Connecting usb type-c devices | |
JP5767462B2 (en) | COMMUNICATION MODE DETECTION METHOD BY RECEIVING DEVICE FOR NEAR RANGE COMMUNICATION | |
JP6411480B2 (en) | Error detection capability via CCIe protocol | |
JP2017511044A (en) | Bit allocation via shared bus to facilitate error detection optimization | |
JP2017516353A (en) | Method for transmitting additional information in-band over an inter-integrated circuit (I2C) bus | |
TW201506634A (en) | Camera control interface extension bus | |
CN107431614B (en) | Method and apparatus for automatic offset compensation | |
JP5238369B2 (en) | Data receiving apparatus, data receiving method, and data receiving program | |
JP5096024B2 (en) | USB controller and USB controller test method | |
US20110019762A1 (en) | Information transmission system, information transmission device, information transmission method, and computer readable medium storing a program for information transmission | |
KR101565584B1 (en) | Method and Apparatus for Transmitting Data Based on SPI Communication | |
JP2004260677A (en) | Communication equipment | |
US11122187B2 (en) | Transmitter, receiver, transmitter/receiver, and transmitting/receiving system | |
CN115668855A (en) | Wireless BMS host time synchronization mechanism | |
US10977206B2 (en) | Data communication device and method for data communication | |
JP2010212989A (en) | Address decoder and address setting method | |
KR20160133472A (en) | Method for using error correction codes with n factorial or cci extension | |
KR101876418B1 (en) | Apparatus and method deskew on peripheral component interconnect express | |
JP2009164833A (en) | Data processing apparatus and method, and program | |
US10462268B2 (en) | Data transmitting/receiving apparatus and data transmitting/receiving method | |
US9722630B1 (en) | Decoding apparatus and method for decoding a serially transmitted signal thereof | |
CN106856464A (en) | A kind of sync symbols detecting system | |
US7106820B2 (en) | System and method for establishing word synchronization | |
CN110347629B (en) | Data processing method and data processing device | |
JP2021535669A (en) | Reliable asynchronous baseband protocol with correlated clock and data recovery |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
GRNT | Written decision to grant | ||
FPAY | Annual fee payment |
Payment date: 20181016 Year of fee payment: 4 |
|
FPAY | Annual fee payment |
Payment date: 20191007 Year of fee payment: 5 |