KR101005933B1 - Method and Apparatus for transmitting of data between Master and Slave - Google Patents
Method and Apparatus for transmitting of data between Master and Slave Download PDFInfo
- Publication number
- KR101005933B1 KR101005933B1 KR1020080135732A KR20080135732A KR101005933B1 KR 101005933 B1 KR101005933 B1 KR 101005933B1 KR 1020080135732 A KR1020080135732 A KR 1020080135732A KR 20080135732 A KR20080135732 A KR 20080135732A KR 101005933 B1 KR101005933 B1 KR 101005933B1
- Authority
- KR
- South Korea
- Prior art keywords
- slave
- master
- data
- pin
- data transmission
- Prior art date
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W84/00—Network topologies
- H04W84/18—Self-organising networks, e.g. ad-hoc networks or sensor networks
- H04W84/20—Master-slave selection or change arrangements
Abstract
본 발명은 마스터와 슬레이브 간의 데이터 전송방법 및 장치에 관한 것이다. 본 발명은 마스터(100)와 슬레이브(200) 상호 간에 SPI(Serial Peripheral Interface) 규격에 의한 핀 구성 이외에 슬레이브(200)가 마스터(100)에게 전송할 데이터가 있음을 알리는 외부 핀을 추가로 구성한다. 외부 핀은 마스터(100)와 슬레이브(200)에 각각 구비되고 서로 연결된다. 그런 상태에서 슬레이브(200)가 데이터 전송준비를 완료하면 외부 핀을 로우레벨 상태로 설정한다. 로우레벨 상태는 데이터 송수신이 가능한 상태를 말한다. 마스터(100)는 외부 핀 상태를 감시하다가 슬레이브(200)의 외부 핀이 로우레벨로 설정되면, 클럭핀(SCK)을 통해 소정 주파수의 클럭신호를 슬레이브(200)에게 발생한다. 이에 슬레이브(200)는 클럭신호에 따라 상기 마스터(100)에게 데이터를 전송한다. 슬레이브(200)는 데이터 전송을 완료하면, 상기 마스터(100)에게 데이터 전송이 완료되었음을 통보하기 위해 상기 외부 핀을 하이레벨 상태로 설정한다. 이와 같은 본 발명에 따르면, 마스터가 슬레이브로부터 수신할 데이터 유무를 확인할 필요가 없기 때문에 데이터의 오버헤드를 감소시키는 이점이 있다. The present invention relates to a data transmission method and apparatus between a master and a slave. The present invention further configures an external pin informing that the slave 200 has data to be transmitted to the master 100 in addition to the pin configuration according to the SPI (Serial Peripheral Interface) standard between the master 100 and the slave 200. The external pins are provided in the master 100 and the slave 200, respectively, and connected to each other. In such a state, when the slave 200 completes the data transmission preparation, sets the external pin to the low level state. The low level state is a state in which data can be transmitted and received. When the master 100 monitors an external pin state and the external pin of the slave 200 is set to a low level, the master 100 generates a clock signal having a predetermined frequency to the slave 200 through the clock pin SCK. The slave 200 transmits data to the master 100 according to the clock signal. When the slave 200 completes the data transmission, the slave 200 sets the external pin to a high level state to notify the master 100 that the data transmission is completed. According to the present invention as described above, there is an advantage of reducing data overhead since the master does not need to confirm the presence or absence of data to be received from the slave.
마스터, 슬레이브, SPI, 외부 핀 Master, Slave, SPI, External Pins
Description
본 발명은 무선 센서네트워크 시스템에 관한 것으로, 특히 해양 무선센서네트워크의 센서노드에서 물리(PHY) 계층과 맥(MAC) 계층이 시리얼 방식으로 데이터전송을 하도록 하는 마스터와 슬레이브 간의 데이터 전송방법 및 장치에 관한 것이다. The present invention relates to a wireless sensor network system, and more particularly, to a method and apparatus for transmitting data between a master and a slave in which a physical (PHY) layer and a MAC (MAC) layer transmit data in a serial manner in a sensor node of a marine wireless sensor network. It is about.
무선 센서네트워크는 센서노드(Sensor Node)와 이를 수집하여 외부로 내보내는 싱크노드(Sink Node)로 구성된 네트워크를 말한다. 이러한 센서네트워크는 해양환경에도 적용되고 있으며, 그 필요성은 계속 증대하고 있다.The wireless sensor network refers to a network consisting of a sensor node and a sink node that collects and exports it to the outside. These sensor networks are also being applied to the marine environment, and the need continues to grow.
상기 센서노드는 IEEE 802.15.4 MAC 프로토콜이 탑재된 맥(MAC) 계층과, IEEE 802.15.4 PHY 프로토콜이 탑재된 물리(PHY) 계층을 포함한다. 상기 맥 계층은 센서노드의 데이터 통신을 전반적으로 제어하는 역할을 하고, 상기 물리 계층은 상기 맥 계층의 제어동작에 따라 데이터를 전송하는 역할을 한다. 상기 센서노드가 해양환경에 적용할 경우 상기 물리 계층은 수중 모뎀이 된다. The sensor node includes a MAC layer on which the IEEE 802.15.4 MAC protocol is mounted, and a physical (PHY) layer on which the IEEE 802.15.4 PHY protocol is mounted. The MAC layer controls overall data communication of a sensor node, and the physical layer plays a role of transmitting data according to a control operation of the MAC layer. When the sensor node is applied to the marine environment, the physical layer becomes an underwater modem.
상기 맥 계층과 물리 계층은 일정한 통신방식에 따라 상호간 데이터 송수신 이 수행된다. 예컨대, 시리얼 통신방식 중 직렬 인터페이스(SPI : serial peripheral interface) 방식이 그 하나이다. 상기 SPI 방식은 4개의 핀에 의해 데이터 송수신이 이루어진다. 즉, 아래에서 자세하게 설명하겠지만, 데이터 출력 핀, 데이터 입력 핀, 클럭 핀, 슬레이브 선택 핀이 사용된다. 상기 SPI 방식은 소켓 통신의 서버/클라이언트 모델과 유사하게 마스터/슬레이브 모델을 사용한다. 그렇기 때문에, 본 설명에서는 맥 계층은 마스터라 명명하고, 물리 계층은 슬레이브라고 명명하여 설명하기로 한다. The MAC layer and the physical layer perform data transmission and reception with each other according to a predetermined communication method. For example, a serial interface (SPI) is one of the serial communication methods. In the SPI method, data is transmitted and received by four pins. That is, as described in detail below, data output pins, data input pins, clock pins, and slave select pins are used. The SPI scheme uses a master / slave model similar to the server / client model of socket communication. Therefore, in this description, the Mac layer is named master and the physical layer is named slave.
상기 SPI 방식에 의해 연결된 마스터/슬레이브 구성이 도 1에 도시되어 있다. 도 1은 마스터/슬레이브가 SPI 방식에 의해 연결된 구성도이다. A master / slave configuration connected by the SPI scheme is shown in FIG. 1 is a configuration diagram in which a master / slave is connected by an SPI method.
도 1을 보면, 마스터(10)와 슬레이브(20)에는 SPI 방식을 사용하기 위해 4개의 핀이 구비된다. 상기 4개의 핀은 데이터 전송에 필요한 클럭신호를 발생하는 클럭(SCK : serial clock)핀, 상기 슬레이브(20)가 마스터(10)로 데이터를 전송하기 위해 사용되는 MISO(Master input Slave out)핀, 상기 마스터(10)가 슬레이브(20)에게 데이터를 전송하기 위해 사용되는 MOSI(Master output Slave input)핀, 상기 슬레이브(20)가 복수 개인 경우 하나의 슬레이브를 선택하기 위한 슬레이브 선택(slave select, /SS)핀으로 구성된다. 상기 슬레이브 선택핀(/SS)은 로우레벨 상태인 경우에만 데이터의 송수신이 가능하다.Referring to FIG. 1, four pins are provided in the
상기 SPI는 미도시하고 있지만 3개의 레지스터를 제공하고 있다. SPI를 사용하기 위한 각종 설정을 관리하는 SPCR(SPI Control Register)과, SPI로 송수신되는 데이터가 저장되는 8-비트 레지스터인 SPDR(SPI Data Register)과, 데이터의 전송 과 속도를 관리하는 SPSR(SPI Status Register)이다. 그 중 SPSR의 소정 비트에 포함된 플래그(Flag) 값에 따라 데이터 전송의 완료 여부를 확인하게 된다. 예컨대 상기 플래그가 셋팅(Setting)되면 데이터가 전송되었다고 판단하여 아래에서 설명될 버퍼에 기록된 값을 리드한다. Although not shown, the SPI provides three registers. SPPI (SPI Control Register), which manages various settings for using SPI, SPDR (SPI Data Register), an 8-bit register that stores data sent and received by SPI, and SPSR (SPI, which manages data transmission and speed). Status Register). It is checked whether data transmission is completed according to a flag value included in a predetermined bit of the SPSR. For example, when the flag is set, it is determined that data is transmitted, and the value recorded in the buffer to be described below is read.
그리고 상기 마스터(10)에는 CPU(12)가 구비된다. 이는 상기 마스터(10)가 데이터 통신을 전반적으로 제어하기 위함이다. The
한편, 상기 마스터(10) 및 슬레이브(20)는 상기 SPDR에 의해 데이터를 저장하기 위한 버퍼가 구비된다. 상기 버퍼는 8-비트 시프트레지스터(이하, '시프트레지스터'라 함)(14)(22)로 구성된다. 상기 시프트레지스터(14)(22)는 환형 큐(circular queue)처럼 동작한다. On the other hand, the
이하에서는 종래 기술에 따라 마스터(10)와 슬레이브(20) 상호간의 데이터 전송에 대해 설명하기로 한다.Hereinafter, data transmission between the
먼저, 마스터(10)가 1-바이트 데이터를 슬레이브(20)에게 전송하는 경우이다. SPI 방식에서는 1-바이트 단위로 데이터 전송이 이루어진다. First, the
우선 마스터(10)의 CPU(12)는 슬레이브 선택핀(/SS)을 로우레벨 상태가 되게한다.First, the
그런 상태에서 상기 마스터(10)는 시프트레지스터(14)에 새로운 1-바이트 데이터를 기록하고, 클럭핀(SCK)을 통해 소정 주파수의 클럭신호를 발생한다. 상기 클럭신호는 상기 CPU(12)가 SPI 인터페이스를 지원하면 자동으로 클럭핀(SCK)에서 출력되지만, 미지원하는 경우에는 상기 마스터(10)가 직접 발생시켜야 한다.In such a state, the
상기 클럭신호 발생에 따라 상기 마스터(10)는 MOSI 핀을 통해 데이터를 상기 슬레이브(20)에게 전송한다. 상기 슬레이브(20)는 상기 전송된 데이터를 시프트 레지스터(22)에 저장한다. 상기 데이터가 전송되면, 상기 마스터(10)는 슬레이브 선택핀(/SS)을 하이레벨 상태로 설정하여 상기 슬레이브(20)에게 데이터 송신이 완료되었음을 알린다. In response to the clock signal generation, the
한편, 상기 슬레이브(20)는 상기 슬레이브 선택핀(/SS)이 로우레벨 상태가 되면 상기 시프트레지스터(22)의 플래그 셋팅을 확인하고, 상기 플래그가 셋팅되면 상기 시프트레지스터(22)에 저장된 데이터를 리드하게 된다. 상기 플래그는 1-바이트 데이터가 수신되면 셋팅되지만, 인터럽트 서비스 루틴(ISR)을 사용하지 않을 경우에는 플래그 상태를 계속 검사해야 한다.On the other hand, the
다음, 슬레이브(20)가 1-바이트 데이터를 마스터(10)로 전송하는 경우이다. Next, the
먼저 슬레이브(20)는 시프트레지스터(22)에 전송할 데이터를 기록한다. 그런 다음 상기 마스터(10)의 클럭핀(SCK)에서 클럭신호가 발생할 때까지 대기한다. 즉 클럭신호는 마스터(10)에서만 발생하기 때문이다. First, the
이 상태에서, 마스터(10)가 슬레이브 선택핀(/SS)을 로우레벨로 설정하면, 상기 클럭핀(SCK)을 통해 클럭신호가 발생한다. 상기 클럭신호가 발생하면 상기 슬레이브(20)는 MISO핀을 통해 상기 마스터(10)에게 데이터를 전송한다. In this state, when the
상기 마스터(10)는 클럭신호가 모두 출력되면, 즉 데이터가 모두 전송되면 시프트레지스터(14)를 리드하여 데이터를 읽는다. When all clock signals are output, that is, all data is transmitted, the
하지만, 상기한 바와 같이 4-핀만 이용하여 마스터-슬레이브 상호간에서 데 이터 전송이 수행될 때, 다음과 같은 문제점이 있다. However, as described above, when data transfer is performed between master and slaves using only 4-pins, there are the following problems.
우선, 마스터(10)는 슬레이브(20)로부터 정상적인 데이터를 수신하기 위해 주기적으로 수신할 데이터가 있는지 확인해야한다. 이때 마스터(10)는 슬레이브(20)에게 요청신호(Request signal)를 보내고 응답신호(Ack signal)를 받는 과정에서 큰 오버헤드(overhead)가 발생한다. First, in order to receive normal data from the
또 상기 슬레이브(20)가 마스터(10)로 데이터를 전송할 준비가 완료되더라도 상기 슬레이브(20)는 상기 마스터(10)로부터 클럭신호가 발생하기를 기다려야 한다. 그렇기 때문에 상기 슬레이브(20)는 상기 데이터 전송을 준비할 동안에는 다른 작업을 할 수 없게 된다. 만약 상기 클럭신호의 발생을 기다리는 동안에 다른 작업을 하도록 코드를 작성할 경우 상기 다른 작업에 의해 전송하고자 하는 데이터가 변경될 수 있는 문제가 발생한다.In addition, even when the
따라서 본 발명의 목적은 상기한 문제점을 해결하기 위한 것으로, SPI 방식을 이용하여 마스터(MAC 계층)와 슬레이브(PHY 계층)가 상호간 데이터를 전송할 때 발생하는 오버헤드(overhead)를 줄이기 위한 것이다.Accordingly, an object of the present invention is to solve the above problems, and to reduce overhead caused when a master (MAC layer) and a slave (PHY layer) transmit data between each other using an SPI scheme.
본 발명의 다른 목적은 마스터(MAC 계층)의 클럭 발생 지연시간을 단축하는 것이다. Another object of the present invention is to reduce the clock generation delay time of the master (MAC layer).
상기한 목적을 달성하기 위한 본 발명의 특징에 따르면, 무선 센서네트워크에서 센서노드의 데이터 통신을 제어하는 마스터; 상기 마스터의 제어동작에 따라 데이터를 전송하는 슬레이브; 그리고, 상기 마스터와 슬레이브 사이에 연결되어 시리얼 전송 방식으로 상기 마스터와 슬레이브 간의 데이터 송수신을 수행하는 SPI 인터페이스부;를 포함하고, 상기 SPI 인터페이스부는, 상기 시리얼 전송 방식을 제공하기 위해 상기 마스터 및 슬레이브에 각각 설치되며, 데이터 전송에 필요한 클럭신호를 발생하는 클럭핀(serial clock), 상기 슬레이브가 상기 마스터에게 데이터를 전송하기 위한 MISO(Master input Slave out)핀, 상기 마스터가 상기 슬레이브에게 데이터를 전송하기 위한 MOSI(Master output Slave input)핀, 상기 슬레이브를 선택하기 위한 슬레이브 선택핀(/SS), 그리고 상기 슬레이브가 마스터로 데이터 전송을 요청하기 위한 입출력 핀을 포함하여 구성된다.According to a feature of the present invention for achieving the above object, a master for controlling data communication of the sensor node in the wireless sensor network; A slave transmitting data according to a control operation of the master; And an SPI interface unit connected between the master and the slave to perform data transmission and reception between the master and the slave in a serial transmission method, wherein the SPI interface unit is configured to provide the serial transmission method to the master and the slave. A clock pin (serial clock) for generating a clock signal for data transmission, a master input slave out (MISO) pin for transmitting data to the master, and the master transmitting data to the slave And a master output slave input (MOSI) pin, a slave selection pin (/ SS) for selecting the slave, and an input / output pin for requesting data transmission to the master.
상기 입출력 핀은, 상기 슬레이브가 마스터에게 데이터 전송을 요청하는 제1 핀, 상기 슬레이브가 데이터 수신중임을 나타내는 제2핀, 상기 슬레이브가 데이터 송신중임을 나타내는 제3핀을 포함하여 구성된다. The input / output pin may include a first pin for requesting data transmission by the slave to the master, a second pin indicating that the slave is receiving data, and a third pin indicating that the slave is transmitting data.
상기 제1핀, 제2핀, 제3핀의 구동은 모두 로우레벨 상태에서 수행된다.The driving of the first, second, and third pins is all performed at a low level.
본 발명의 다른 특징에 따르면, 슬레이브가 데이터 전송준비를 완료하는 단계; 상기 슬레이브가 데이터 전송을 완료하면, 상기 슬레이브와 연결된 마스터에게 전송할 데이터가 있음을 통보하는 제 1 통보단계; 상기 슬레이브가 상기 마스터로부터 소정 주파수의 클럭신호가 발생하면 상기 데이터를 전송하는 단계; 상기 슬레이브가 상기 데이터 전송을 완료하면, 상기 마스터에게 데이터 전송이 완료되었음을 통보하는 제 2 통보단계;를 포함하여 구성된다. According to another feature of the invention, the step of the slave completes the data transmission preparation; A first notification step of notifying that a master connected with the slave has data to transmit when the slave completes data transmission; Transmitting, by the slave, the data when a clock signal having a predetermined frequency is generated from the master; And a second notification step of notifying the master that data transmission is completed when the slave completes the data transmission.
본 발명의 또 다른 특징에 따르면, 시리얼 통신방식으로 데이터를 전송하도록 마스터와 슬레이브가 SPI 인터페이스 및 상기 슬레이브가 상기 마스터에게 데이터 전송요청을 할 수 있도록 제공된 외부 핀으로 연결된 상태에서, 상기 슬레이브가 데이터 전송준비를 완료하는 단계; 상기 슬레이브가 데이터 전송준비를 완료하면, 상기 외부 핀을 로우레벨 상태로 설정하는 단계; 상기 마스터가 상기 외부 핀이 로우레벨 상태로 설정되면, 소정 주파수의 클럭신호를 상기 슬레이브에게 발생하는 단계; 상기 슬레이브가 상기 클럭신호에 따라 상기 마스터에게 데이터를 전송하는 단계; 상기 슬레이브가 데이터 전송을 완료하면, 상기 마스터에게 데이터 전송이 완료되었음을 통보하기 위해 상기 외부 핀을 하이레벨 상태로 설정하는 단계;를 포함하여 구성된다. According to still another aspect of the present invention, the slave and the data transmission in a state in which the master and the slave is connected to the SPI interface and the external pin provided to allow the slave to request data transmission to the master to transmit data in a serial communication method. Completing the preparation; Setting the external pin to a low level state when the slave completes data transmission preparation; Generating, by the master, the clock signal of a predetermined frequency to the slave when the external pin is set to a low level state; The slave transmitting data to the master according to the clock signal; Setting the external pin to a high level state to notify the master that the data transfer is complete when the slave completes the data transfer.
상기 외부 핀이 로우레벨 상태로 설정되면, 상기 클럭신호를 발생시키기 위 하여 상기 마스터는 자신의 시프트레지스터에 더미 데이터를 기록한다.When the external pin is set to the low level state, the master writes dummy data in its shift register to generate the clock signal.
상기 슬레이브가 데이터를 전송하는 도중, 상기 마스터는 상기 외부 핀의 상태를 검사하고, 상기 검사 결과 상기 외부 핀이 하이레벨 상태로 설정되면 상기 더미 데이터의 수신을 중단하도록 한다.While the slave is transmitting data, the master checks the state of the external pin, and stops receiving the dummy data when the external pin is set to a high level as a result of the test.
상기 외부 핀이 인터럽트 처리된 경우, 상기 외부 핀이 로우레벨로 설정되기만 하면, 상기 마스터가 상기 슬레이브로부터 데이터를 수신받는다.When the external pin is interrupted, the master receives data from the slave as long as the external pin is set to the low level.
본 발명에서는 무선 센서네트워크의 센서노드에 있는 맥 계층(즉, 마스터)과 물리 계층(즉, 슬레이브)이 시리얼 방식의 주변장치 인터페이스에 의해 데이터를 송수신할 때, 슬레이브가 마스터에게 전송할 데이터가 있을 경우, 슬레이브가 이를 마스터에게 알려주기 때문에, 마스터가 슬레이브로부터 수신할 데이터가 있는지 주기적으로 확인할 필요가 없어 데이터의 오버헤드를 감소시킬 수 있는 효과가 있다. In the present invention, when the MAC layer (i.e., master) and the physical layer (i.e., slave) in the sensor node of the wireless sensor network transmit and receive data by the serial peripheral interface, the slave has data to transmit to the master. Since the slave notifies the master, the master does not need to periodically check whether there is data to be received from the slave, thereby reducing the overhead of the data.
또한, 슬레이브가 마스터에게 데이터를 전송하는 경우 슬레이브의 요청에 의해서만 마스터가 클럭신호를 발생하기 때문에 마스터의 클럭 발생 지연시간이 짧아지므로 슬레이브의 동작 효율성을 향상시키는 효과도 있다. In addition, when the slave transmits data to the master, since the master generates a clock signal only at the request of the slave, the clock generation delay time of the master is shortened, thereby improving the operation efficiency of the slave.
이하 본 발명에 의한 마스터와 슬레이브 간의 데이터 전송방법 및 장치를 첨부된 도면에 도시된 바람직한 실시 예를 참조하여 상세하게 설명한다. Hereinafter, a method and an apparatus for transmitting data between a master and a slave according to the present invention will be described in detail with reference to a preferred embodiment shown in the accompanying drawings.
앞서 설명한 바와 같이, 수중 센서네트워크 등에 적용되는 센서노드는 맥 계층과 물리 계층을 포함하고 있으며, 상기 맥 계층은 센서노드의 데이터 통신을 전 반적으로 제어하는 역할을 하고, 상기 물리 계층은 상기 맥 계층의 제어동작에 따라 데이터를 전송하는 역할을 하고 있는바, 본 발명의 실시 예에서는 상기 맥 계층은 마스터라 명명하고, 물리 계층은 슬레이브라고 명명하여 설명하기로 한다. 여기서 상기 물리 계층은 수중에서 다른 노드들과 데이터 통신을 할 수 있는 수중모뎀이 될 수 있다.As described above, a sensor node applied to an underwater sensor network or the like includes a MAC layer and a physical layer, and the MAC layer generally controls data communication of the sensor node, and the physical layer is the MAC layer. In the embodiment of the present invention, the MAC layer is referred to as a master and the physical layer is referred to as a slave. The physical layer may be an underwater modem capable of data communication with other nodes in the water.
도 2에는 본 발명의 바람직한 실시 예에 따른 SPI 핀 구성 및 그 핀 구성에 의해 연결되는 마스터와 슬레이브간의 구성도가 도시되어 있다. FIG. 2 is a diagram illustrating an SPI pin configuration and a configuration diagram between a master and a slave connected by the pin configuration according to an exemplary embodiment of the present invention.
도 2를 보면, 상기 마스터(100)와 슬레이브(200)는 SPI(serial peripheral interface) 방식에 의해 상호 연결된다. 2, the
상기 마스터(100) 및 슬레이브(200)의 구성은 종래 기술에서 언급한 것과 동일한 것이어서 이에 대한 자세한 설명은 생략하기로 한다. 다만, 상기 마스터(100)에는 CPU(110) 및 마스터용 시프트레지스터(120)가 구비되고, 상기 슬레이브(200)에는 임시 수신 버퍼(210) 및 슬레이브용 시프트레지스터(220)가 구비된다. 상기 임시 수신 버퍼(210)는 슬레이브(200)가 마스터(100)로부터 데이터를 전송받으면 이를 임시 저장하는 역할을 한다. The configurations of the
상기 SPI 방식을 적용하기 위한 핀 구성에는, 데이터 전송에 필요한 클럭신호를 발생하는 클럭핀(serial clock, SCK), 상기 슬레이브(200)가 마스터(100)에게 데이터를 전송하기 위해 사용되는 MISO(Master input Slave out)핀, 상기 마스터(100)가 슬레이브(200)에게 데이터를 전송하기 위해 사용되는 MOSI(Master output Slave input)핀, 슬레이브(200)를 선택하기 위한 슬레이브 선택핀(/SS), 그 리고 상기 슬레이브(200)가 마스터(100)에게 데이터 전송을 요청하기 위한 추가 핀을 포함한다.In the pin configuration for applying the SPI method, a clock pin (serial clock, SCK) for generating a clock signal required for data transmission, and MISO (Master used by the
상기 추가 핀은 모두 3핀으로 구성된다. 제1핀은 상기 슬레이브(200)가 마스터(100)에게 데이터 전송을 요청하는 역할을 한다. 이때, 상기 제1핀은 로우레벨 상태이어야 한다. 제2핀은 로우레벨 상태가 되면 상기 슬레이브(즉, 수중모뎀)(200)가 데이터를 수신하고 있음을 나타낸다. 제3핀은 로우레벨 상태가 되면 상기 슬레이브(즉, 수중모뎀)(200)이 데이터를 송신중임을 나타낸다. 상기 추가 핀은 모두 상기 슬레이브(200)에서 상기 마스터(100)에게 출력되도록 설정된다. 여기서, 상기 제1핀은 상기 슬레이브(200)가 데이터 전송을 위한 것으로 필수적인 핀이며, 상기 제1핀은 상기 마스터(100)가 인터럽트 방식으로 처리하는 것이 효과적이다. 그리고 상기 제2핀 및 제3핀은 상기 슬레이브(200)의 동작에 문제가 발생할 수 있는 부분을 최소화하기 위한 부분으로 필수적으로 사용되어야 하는 핀은 아니다. The additional pins consist of all three pins. The first pin serves to request data transmission from the
이어 상기한 구성에 따른 마스터와 슬레이브 상호간의 데이터 전송과정을 설명한다. 여기서, 상기 과정은 상기 슬레이브가 데이터를 수신 및 송신하는 과정과, 상기 마스터가 데이터를 송신하고 수신하는 과정으로 구분하여 설명하기로 한다. Next, the data transmission process between the master and the slave according to the above configuration will be described. Here, the process will be divided into a process of receiving and transmitting data by the slave and a process of transmitting and receiving data by the master.
첫 번째, 슬레이브(200) 동작에 대한 설명이다. First, the operation of the
먼저, 도 3을 참조하여 상기 슬레이브(200)가 상기 마스터(100)로부터 데이터를 수신하는 경우를 설명한다. First, a case in which the
상기 슬레이브(200)가 데이터를 수신하는 것은 SPI 인터럽트 서비스 루틴(ISR)에 의해 수행된다. 상기 SPI ISR은 MOSI핀으로 1-바이트 전송이 완료되면 발생한다(s100). Receiving data by the
따라서 상기 SPI ISR이 발생하면 상기 슬레이브(200)는 상기 마스터(100)의 시프트레지스터(120)에 저장하고 있는 데이터를 전송받아 임시 수신 버퍼(210)로 임시 저장한다(s102). 상기 임시 수신 버퍼(210)에 저장된 데이터는 데이터 전송이 모두 완료되면 시프트 레지스터(220)로 저장된다(s104).Therefore, when the SPI ISR occurs, the
이때, 상기 마스터(100)에서 1-바이트 이상의 여러 바이트의 데이터를 전송할 경우, 상기 슬레이브(200)는 데이터 전송이 완료되었는지 확인할 방법이 없다. 그래서, 상기 슬레이브(200)는 마지막으로 데이터를 수신한 후 약 30us 후에 임시 수신 버퍼(210)에 저장된 데이터를 시프트레지스터(220)에 저장하는 것이 바람직하다. 이는 상기 슬레이브(200)가 상기 MOSI핀을 통해 상기 마스터(100)로부터 전송받은 데이터를 먼저 임시 수신 버퍼(210)에 저장하고 이를 다시 시프트레지스터(220)로 이동시켜 저장하는데, 그 이동 시간이 필요하기 때문이다.In this case, when the
다음, 상기 슬레이브(200)가 상기 마스터(100)에게 데이터를 전송하는 경우이다. 이는 도 4를 참조한다. Next, the
먼저 슬레이브(200)는 데이터 송신 준비를 한다(s110). 데이터 송신 준비가 완료되면 상기 슬레이브(200)는 상기 마스터(100)에게 전송할 데이터가 있음을 통보하기 위해 자신의 추가 핀 중 제1핀 상태를 변경한다(s112).First, the
상기 마스터(100)는 자신의 추가 핀 중 제1핀과 연결된 상기 슬레이브(200)의 제1핀 상태를 검사한다(s114). 상기 검사 결과, 상기 제1핀이 하이레벨에서 로 우레벨 상태로 변경되면(s116), 상기 마스터(100)는 클럭핀(SCK)을 통해 소정 주파수의 클럭신호를 발생시킨다(s118). The
상기 클럭신호가 발생되면, 상기 슬레이브(200)는 상기 클럭신호에 따라 상기 마스터(100)에게 MISO핀을 통해 데이터를 전송한다(s120). When the clock signal is generated, the
상기 슬레이브(200)는 상기 마스터(100)에게 데이터를 모두 전송하면(s122), 상기 제1핀을 로우레벨 상태에서 하이레벨 상태로 변경한다(s124). 그래서 상기 마스터(100)에게 전송이 완료되었음을 알린다. When the
즉, 도 4는 슬레이브(200)가 마스터(100)에게 전송할 데이터가 있으면 상기 마스터(100)가 클럭신호를 발생할 때까지 대기하고 있는 것이 아니고, 상기 마스터(100)에게 전송할 데이터가 있음을 알릴 수 있는 것이다.That is, in FIG. 4, if there is data to be transmitted to the
두 번째, 마스터 동작에 대한 설명이다. Second is the description of the master operation.
먼저, 도 5를 참조하여 상기 마스터가 상기 슬레이브에게 데이터를 전송하는 경우를 설명한다.First, a case in which the master transmits data to the slave will be described with reference to FIG. 5.
상기 마스터(100)가 데이터를 전송하기 위해서는 슬레이브 선택핀(/SS)을 로우레벨로 설정하고(s130), 전송하고자 할 데이터를 시프트레지스터(120)에 기록한다(s132). 그런 다음, 상기 마스터(100)가 클럭핀(SCK)을 통해 소정 주파수의 클럭신호를 발생한다(s134).In order to transmit data, the
상기 클럭신호가 발생하면 그 클럭신호에 따라 상기 마스터(100)는 상기 시프트레지스터(120)에 기록된 데이터를 상기 MOSI핀을 통해 상기 슬레이브(200)에게 전송한다(s138). When the clock signal is generated, the
상기 마스터(100)는 상기 데이터 전송이 완료되면, 상기 슬레이브 선택핀(/SS)을 하이레벨로 설정하고 전송을 종료한다(s140). When the data transmission is completed, the
이때, 상기 마스터(100)는 데이터 전송이 완료되면 소정 시간 이내에는 데이터 송신을 하지 말아야 한다. 즉 상기 슬레이브(200)는 상기 MOSI핀을 통해 상기 마스터(100)로부터 전송받은 데이터를 먼저 임시 수신 버퍼(210)에 저장하고 이를 다시 시프트레지스터(220)로 이동시켜 저장하는데, 그 이동 시간이 필요하기 때문이다. 일반적으로 상기 이동시간은 30㎲가 소요되기 때문에, 상기 마스터(100)는 데이터 전송완료 후 30㎲ 이내에는 상기 슬레이브(200)에게 데이터를 다시 송신하지 않는 것이 바람직하다. At this time, the
다음, 상기 마스터가 상기 슬레이브로부터 데이터를 수신하는 경우이다. 이는 도 6을 참조한다. Next, the master receives data from the slave. This is referred to FIG. 6.
상기 마스터(100)는 자신의 추가 핀 중 제1핀과 연결된 상기 슬레이브(200)의 제1핀 상태를 검사한다(s150). 상기 제1핀 상태는 하이레벨 또는 로우레벨 상태이다. 상기 로우레벨인 경우만 전송할 데이터가 있다는 것을 말한다. The
상기 검사결과 상기 마스터(100)의 제1핀이 로우레벨로 되면(s152), 상기 마스터(100)는 상기 시프트레지스터(120)에 더미 데이터(Dumy Data)를 기록하여 클럭신호를 발생하거나, 또는 상기 마스터(100)가 직접 클럭신호를 발생한다(s154).When the first pin of the
상기 클럭신호 발생에 의해 상기 슬레이브(200)는 상기 MISO핀을 통해 데이터를 상기 마스터(100)에게 송신한다(s156).In response to the clock signal generation, the
상기 슬레이브(200)는 상기 마스터(100)에게 데이터를 모두 전송완료하면(s158), 상기 제1핀을 하이레벨로 설정한다(s160). 이에 상기 마스터(100)가 자신의 시프트레지스터(120)에 기록할 더미데이터를 수신하지 않게 된다. 즉 상기 마스터(100)는 1-바이트 데이터를 수신한 후에는 항상 제1핀 상태를 체크해야 한다. SPI에서는 1바이트 단위로 데이터 전송이 수행되기 때문이다. When the
이때, 상기 마스터(100)가 상기 슬레이브(200)로부터 데이터를 수신하는 경우, 상기 제1핀이 인터럽트로 처리되었다면, 상기 제1핀이 로우레벨로 설정되기만 하면, 상기 마스터(100)는 상기 슬레이브(200)로부터 데이터를 수신받게 된다. In this case, when the
이상과 같이 본 발명의 도시된 실시 예를 참고하여 설명하고 있으나, 이는 예시적인 것들에 불과하며, 본 발명의 속하는 기술분야의 통상 지식을 가진 자라면 본 발명의 요지 및 범위에 벗어나지 않으면서도 다양한 변형, 변경 및 균등한 타 실시 예들이 가능하다는 것을 명백하게 알 수 있을 것이다. 따라서 본 발명의 진정한 기술적 보호 범위는 첨부된 청구범위의 기술적인 사상에 의해 정해져야 할 것이다. Although described with reference to the illustrated embodiment of the present invention as described above, this is merely exemplary, those skilled in the art to which the present invention pertains various modifications without departing from the spirit and scope of the present invention. It will be apparent that other embodiments may be modified and equivalent. Therefore, the true technical protection scope of the present invention will be defined by the technical spirit of the appended claims.
즉 본 실시 예에서는 수중 센서네트워크에 사용되는 센서노드를 예를 들어 설명하고 있지만, 지상에서 사용되는 센서노드에도 본 발명이 적용될 수 있음은 물론이다. That is, in the present embodiment, a sensor node used in the underwater sensor network is described as an example, but the present invention can be applied to the sensor node used on the ground.
도 1은 마스터/슬레이브가 SPI 방식에 의해 연결된 구성도1 is a configuration diagram in which a master / slave is connected by an SPI method
도 2는 본 발명의 바람직한 실시 예에 따른 SPI 핀 구성 및 그 핀 구성에 의해 연결되는 마스터와 슬레이브간의 구성도2 is a configuration diagram between the SPI pin configuration and the master and slave connected by the pin configuration in accordance with a preferred embodiment of the present invention
도 3은 도 2의 구성에서 슬레이브가 마스터로부터 데이터를 수신하는 과정을 보인 흐름도3 is a flowchart illustrating a process in which a slave receives data from a master in the configuration of FIG.
도 4는 도 2의 구성에서 슬레이브가 마스터에게 데이터를 전송하는 과정을 보인 흐름도4 is a flowchart illustrating a process in which a slave transmits data to a master in the configuration of FIG.
도 5는 도 2의 구성에서 마스터가 슬레이브에게 데이터를 전송하는 과정을 보인 흐름도 5 is a flowchart illustrating a process in which a master transmits data to a slave in the configuration of FIG.
도 6은 도 2의 구성에서 마스터가 슬레이브로부터 데이터를 수신하는 과정을 보인 흐름도6 is a flowchart illustrating a process in which a master receives data from a slave in the configuration of FIG.
*도면의 주요 부분에 대한 부호의 설명** Description of the symbols for the main parts of the drawings *
100 : 마스터 110 : CPU100: master 110: CPU
120 : 마스터용 시프트레지스터 200 : 슬레이브120: master shift register 200: slave
210 : 임시 수신 버퍼 220 : 슬레이브용 시프트레지스터210: temporary receive buffer 220: shift register for slave
Claims (8)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
KR1020080135732A KR101005933B1 (en) | 2008-12-29 | 2008-12-29 | Method and Apparatus for transmitting of data between Master and Slave |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
KR1020080135732A KR101005933B1 (en) | 2008-12-29 | 2008-12-29 | Method and Apparatus for transmitting of data between Master and Slave |
Publications (2)
Publication Number | Publication Date |
---|---|
KR20100077708A KR20100077708A (en) | 2010-07-08 |
KR101005933B1 true KR101005933B1 (en) | 2011-01-03 |
Family
ID=42639028
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
KR1020080135732A KR101005933B1 (en) | 2008-12-29 | 2008-12-29 | Method and Apparatus for transmitting of data between Master and Slave |
Country Status (1)
Country | Link |
---|---|
KR (1) | KR101005933B1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109450912A (en) * | 2018-11-26 | 2019-03-08 | 北京旷视科技有限公司 | Data transmission method, device and equipment |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR101248034B1 (en) * | 2010-11-02 | 2013-03-27 | 한국표준과학연구원 | Synchronized multichannel SPI communication system for vibration sensors and its implementation method |
KR101967466B1 (en) * | 2017-07-04 | 2019-04-09 | 현대오트론 주식회사 | Spi monitoring device and method for determining mode operation of spi monitoring device |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5630152A (en) | 1992-05-18 | 1997-05-13 | Motorola, Inc. | Communication protocol between master and slave device with register information sharing |
US20020120795A1 (en) * | 2001-02-28 | 2002-08-29 | Alcatel | Serial peripheral interface master device, a serial peripheral interface slave device and a serial peripheral interface |
US20070136502A1 (en) | 2005-12-14 | 2007-06-14 | Mediatek Inc. | SPI device |
-
2008
- 2008-12-29 KR KR1020080135732A patent/KR101005933B1/en not_active IP Right Cessation
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5630152A (en) | 1992-05-18 | 1997-05-13 | Motorola, Inc. | Communication protocol between master and slave device with register information sharing |
US20020120795A1 (en) * | 2001-02-28 | 2002-08-29 | Alcatel | Serial peripheral interface master device, a serial peripheral interface slave device and a serial peripheral interface |
US20070136502A1 (en) | 2005-12-14 | 2007-06-14 | Mediatek Inc. | SPI device |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109450912A (en) * | 2018-11-26 | 2019-03-08 | 北京旷视科技有限公司 | Data transmission method, device and equipment |
CN109450912B (en) * | 2018-11-26 | 2021-11-16 | 北京旷视科技有限公司 | Data transmission method, device and equipment |
Also Published As
Publication number | Publication date |
---|---|
KR20100077708A (en) | 2010-07-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20200174953A1 (en) | Methods and apparatus for synchronizing uplink and downlink transactions on an inter-device communication link | |
US11379278B2 (en) | Methods and apparatus for correcting out-of-order data transactions between processors | |
US6934776B2 (en) | Methods and apparatus for determination of packet sizes when transferring packets via a network | |
CN106462526B (en) | Method and apparatus for multi-master bus protocol | |
JP2009538483A (en) | Flow control for Universal Serial Bus (USB) | |
JPWO2006114822A1 (en) | DMA controller, node, data transfer control method, and program | |
US20050204189A1 (en) | Network apparatus, method for controlling the same, and program for the same | |
JP2007251947A (en) | Multi-master, chaind two-wire serial bus | |
US7117283B2 (en) | Multi-master extended I2C protocol | |
JP2010011255A (en) | Wireless communication apparatus, and packet transfer method thereof | |
KR101005933B1 (en) | Method and Apparatus for transmitting of data between Master and Slave | |
JP3772690B2 (en) | Service system and service method used therefor | |
JP5775149B2 (en) | Station, target device, initiator device, communication system, and communication method | |
CN111290983B (en) | USB transmission equipment and transmission method | |
JP2004328262A (en) | Usb hub device, usb peripheral device, and data transmission and reception method | |
US8806082B2 (en) | Direct memory access device for multi-core system and operating method of the same | |
US20210109887A1 (en) | I3c pending read with retransmission | |
JP6136754B2 (en) | Communication control apparatus and image forming apparatus | |
US8639860B2 (en) | Data transfer system and data transfer method | |
JP2012010216A (en) | Interruption system, host device and peripheral device | |
JP2008117289A (en) | Data communication system, unit and data communication method | |
KR100681371B1 (en) | Post write buffer for a dual clock system | |
JP2009157731A (en) | Virtual machine system and control method of virtual machine system | |
KR100858158B1 (en) | An apparatus for controlling memory of Wireless LAN system and method for transmitting and receiving data thereof | |
JP2948380B2 (en) | Data communication device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A201 | Request for examination | ||
E902 | Notification of reason for refusal | ||
E701 | Decision to grant or registration of patent right | ||
GRNT | Written decision to grant | ||
FPAY | Annual fee payment |
Payment date: 20131220 Year of fee payment: 4 |
|
FPAY | Annual fee payment |
Payment date: 20141125 Year of fee payment: 5 |
|
LAPS | Lapse due to unpaid annual fee |