JP6004891B2 - Serial communication system - Google Patents

Serial communication system Download PDF

Info

Publication number
JP6004891B2
JP6004891B2 JP2012236502A JP2012236502A JP6004891B2 JP 6004891 B2 JP6004891 B2 JP 6004891B2 JP 2012236502 A JP2012236502 A JP 2012236502A JP 2012236502 A JP2012236502 A JP 2012236502A JP 6004891 B2 JP6004891 B2 JP 6004891B2
Authority
JP
Japan
Prior art keywords
information processing
data
signal line
byte
communication
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.)
Active
Application number
JP2012236502A
Other languages
Japanese (ja)
Other versions
JP2014086992A (en
Inventor
池内 義宏
義宏 池内
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Citizen Holdings Co Ltd
Citizen Watch Co Ltd
Original Assignee
Citizen Holdings Co Ltd
Citizen Watch 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 Citizen Holdings Co Ltd, Citizen Watch Co Ltd filed Critical Citizen Holdings Co Ltd
Priority to JP2012236502A priority Critical patent/JP6004891B2/en
Publication of JP2014086992A publication Critical patent/JP2014086992A/en
Application granted granted Critical
Publication of JP6004891B2 publication Critical patent/JP6004891B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、主情報処理装置(マスター)と従情報処理装置(スレーブ)との間の同期式シリアル通信方式に関するものである。   The present invention relates to a synchronous serial communication system between a main information processing apparatus (master) and a sub information processing apparatus (slave).

腕時計などの機器において、機器の操作部の入力処理や表示等の機能を含む機器の基本的な処理を主情報処理装置のマイクロコンピュータ(以下マスター)が行い、これとは別に、外部機器との通信処理や、気温や気圧などの各種周辺情報の計測処理、などの、製品に固有の処理を従情報処理装置のマイクロコンピュータ(以下スレーブ)が行い、これらのマイクロコンピュータ間で必要なデータを通信し全体の制御を行うことが多い。これにより、処理を個々のマイクロコンピュータへ分割するので、全体の処理速度の低下を防止することができる。また、製品間で基本機能を処理するマスターを共通化できるのでコストを低く抑えられる。   In a device such as a wristwatch, the microcomputer of the main information processing device (hereinafter referred to as “master”) performs basic processing of the device including functions such as input processing and display of the operation unit of the device. The microcomputer of the slave information processing device (hereinafter referred to as slave) performs processing unique to the product, such as communication processing and measurement processing of various peripheral information such as temperature and pressure, and communicates necessary data between these microcomputers. However, the overall control is often performed. As a result, the processing is divided into individual microcomputers, so that a decrease in the overall processing speed can be prevented. In addition, since the master for processing basic functions can be shared among products, the cost can be kept low.

マスターとスレーブ間の同期式シリアル通信では、マスターが通信要求信号(CDREQ)を送出し、これを受信したスレーブが通信可能信号(CDRDY)を送出することにより開始され、クロック信号に同期してデータがシリアルデータとして送られる。そしてあらかじめ定められた一連のデータの送信を行って通信要求に対する通信処理を終了する。   In synchronous serial communication between a master and a slave, the master sends a communication request signal (CDREQ), and the slave that has received it sends a communication enable signal (CDRDY). Data is synchronized with the clock signal. Is sent as serial data. Then, a predetermined series of data is transmitted, and the communication process for the communication request is completed.

また、スレーブの処理中に直ちにマスターへ情報を通知すべきイベントが発生した場合、スレーブから通信を開始する必要がある。
特許文献1によれば、通信可能信号経路を介してスレーブからマスターへ通信開始を要求する通信要求信号(CDRDY)の送出を可能にし、スレーブからも通信を開始できるようにしたものである。
In addition, if an event that should notify the master immediately occurs during the processing of the slave, it is necessary to start communication from the slave.
According to Patent Document 1, it is possible to send a communication request signal (CDRDY) for requesting communication start from a slave to a master via a communicable signal path so that communication can be started from the slave.

スレーブの通信要求信号は、マスターから通信を開始したときには、通信を許可する通信可能信号に兼用され、スレーブから通信可能信号として送出される。同様に、マスターの通信要求信号は、スレーブから通信を開始したときには、通信を許可する通信可能信号に兼用され、マスターから通信可能信号として送出される。   When communication is started from the master, the slave communication request signal is also used as a communication enable signal for permitting communication, and is transmitted from the slave as a communication enable signal. Similarly, when the communication is started from the slave, the master communication request signal is also used as a communication enable signal for permitting communication, and is transmitted from the master as a communication enable signal.

特開平5−46549号公報JP-A-5-46549

特許文献1に記載の同期式シリアル通信方式では、マスターとスレーブが同時に通信要求信号を送出した場合、マスターが通信を開始しようとして通信要求信号のつもりで送信した信号が、自らが通信要求信号を送出しているスレーブは、通信を許可する通信可能信号として解釈することとなる。マスターもまた、同様である。   In the synchronous serial communication system described in Patent Document 1, when the master and the slave send a communication request signal at the same time, the signal transmitted by the master as a communication request signal in an attempt to start communication is transmitted by itself. The sending slave interprets it as a communicable signal that permits communication. The same applies to the master.

従って、マスターとスレーブが通信要求信号を同時に送出した場合、マスターは通信可能信号により通信開始と判断して通信を始め、スレーブも通信要求信号により通信開始と判断して通信を始めてしまい、つまりは、双方が発信側として動作し、結果、通信が失敗してしまう、という問題があった。   Therefore, when the master and the slave send the communication request signal at the same time, the master determines that the communication is started by the communication enable signal and starts communication, and the slave also determines that the communication is started by the communication request signal and starts communication. There is a problem in that both parties operate as callers, and as a result, communication fails.

また、仮に、通信要求信号を通信可能信号と兼用していなくても、マスターとスレーブが同時に通信要求信号を送出すると、双方共に通信を開始する動作を行なっているために通信要求信号を受信した側が、通信可能信号を出さないことにより、通信を開始できず、エラーとなってしまうという問題があった。   Even if the communication request signal is not used as a communicable signal, if the master and the slave send the communication request signal at the same time, the communication request signal is received because both start the communication. There is a problem in that communication cannot be started and an error occurs because the side does not issue a communicable signal.

本発明の目的は、マスターとスレーブの通信開始が同時に発生しても、通信に失敗することなく、安定した通信が可能な同期式シリアル通信システムを実現することである。   An object of the present invention is to realize a synchronous serial communication system capable of performing stable communication without failing in communication even when master and slave communication start at the same time.

上記目的を達成するため、本発明は、第1情報処理装置と第2情報処理装置と、前記第1情報処理装置と前記第2情報処理装置との間でシリアル通信によりデータを送受信するための信号線とを有し、前記第1及び前記第2情報処理装置との間で同期して通信するための同期信号を、前記第1又は前記第2情報処理装置が出力するシリアル通信システムであって、前記第1情報処理装置は、前記第2情報処理装置にデータを送信する第1送信動作を開始する際に、前記第2情報処理装置に、前記第1情報処理装置から送信されたデータを受信をする第1受信動作の実行を要求する第1要求信号を出力し、前記第2情報処理装置は、前記第1情報処理装置にデータを送信する第2送信動作を開始する際に、前記第1情報処理装置に、前記第2情報処理装置から送信されたデータを受信する第2受信動作の実行を要求する第2要求信号を出力し、前記第1情報処理装置は、前記第2受信動作中に、前記第1送信動作で前記2情報処理装置へのデータの送信に用いる信号線を介して、予め定められたデータを送信し、前記第2情報処理装置は、前記第2送信動作において、前記予め定められたデータを受信しない場合には、前記第2送信動作から前記第1受信動作に切替えることを特徴とする。
In order to achieve the above object, the present invention provides a first information processing apparatus, a second information processing apparatus, and data transmission / reception between the first information processing apparatus and the second information processing apparatus by serial communication. A serial communication system that has a signal line and outputs a synchronization signal for synchronously communicating with the first and second information processing devices. When the first information processing apparatus starts a first transmission operation for transmitting data to the second information processing apparatus, the data transmitted from the first information processing apparatus to the second information processing apparatus When the second information processing apparatus starts a second transmission operation for transmitting data to the first information processing apparatus, a first request signal for requesting execution of a first reception operation is received. The first information processing apparatus includes the second information. The execution of the second reception operation of receiving the data transmitted from the processing unit outputs the second request signal for requesting the first information processing apparatus, the second receiving operation, the in the first transmission operation Predetermined data is transmitted via a signal line used to transmit data to the second information processing apparatus, and the second information processing apparatus receives the predetermined data in the second transmission operation. If not, the second transmission operation is switched to the first reception operation.

また、第1情報処理装置と第2情報処理装置と、前記第1情報処理装置と前記第2情報処理装置との間でシリアル通信によりデータを送受信するための複数の信号線とを有し、前記第1及び前記第2情報処理装置との間で同期して通信するための同期信号を、前記第1又は前記第2情報処理装置が出力するシリアル通信システムであって、前記第1情報処理装置は、前記第2情報処理装置にデータを送信する第1送信動作を開始する際に、前記第2情報処理装置に、前記第1情報処理装置から送信されたデータを受信する第1受信動作の実行を要求する第1要求信号を出力し、前記第2情報処理装置は、前記第1情報処理装置にデータを送信する第2送信動作を開始する際に、前記第1情報処理装置に、前記第2情報処理装置から送信されたデータを受信する第2受信動作の実行を要求する第2要求信号を出力し、前記第1情報処理装置は、前記第1送信動作中に、該第1送信動作で前記2情報処理装置へのデータの送信に用いる信号線を介して、予め定められたデータを送信し、前記第2情報処理装置は、前記第2送信動作において、前記予め定められたデータを受信した場合には、前記第2送信動作から前記第1受信動作に切替えることを特徴とする。 A first information processing device; a second information processing device; and a plurality of signal lines for transmitting and receiving data by serial communication between the first information processing device and the second information processing device; A serial communication system in which the first or second information processing apparatus outputs a synchronization signal for synchronously communicating with the first and second information processing apparatuses, wherein the first information processing apparatus When the device starts a first transmission operation for transmitting data to the second information processing device, the first information receiving device receives data transmitted from the first information processing device to the second information processing device. When the second information processing apparatus starts a second transmission operation for transmitting data to the first information processing apparatus, the first information processing apparatus Sent from the second information processing apparatus Outputs a second request signal for requesting execution of the second reception operation of receiving the over data, the first information processing apparatus, in the first transmission operation, the second information processing apparatus by the first transmission operation When predetermined data is transmitted via a signal line used for transmitting data to the second information processing apparatus, when the second information processing apparatus receives the predetermined data in the second transmission operation, The second transmission operation is switched to the first reception operation.

また、前記データを送受信するための信号線は、前記第1情報処理装置が前記第2情報処理装置に、前記第1要求信号を出力する第1信号線と、前記第2情報処理装置が前記第1情報処理装置に、前記第2要求信号を出力する第2信号線とを有し、前記第2情報処理装置が、前記第1要求信号に対して、前記第2信号線から受信動作の実行を示す信号を送信し、前記第1情報処理装置が、前記第2信号線から、前記受信動作の実行を示す信号を受信することにより前記第1送信動作を実行するように構成するか、又は、前記第1情報処理装置が、前記第2要求信号に対して、前記第1信号線から受信動作の実行を示す信号を送信し、前記第2情報処理装置が、前記第1信号線から、前記受信動作の実行を示す信号を受信することにより前記第2送信動作を実行するように構成することにより、前記第1信号線と前記第2信号線の少なくともいずれかを、受信動作の実行を示す信号を送信する信号線と兼用したことを特徴とする。   In addition, the signal line for transmitting and receiving the data includes a first signal line for outputting the first request signal from the first information processing apparatus to the second information processing apparatus, and a signal line for transmitting the first request signal to the second information processing apparatus. The first information processing apparatus has a second signal line for outputting the second request signal, and the second information processing apparatus performs a receiving operation from the second signal line with respect to the first request signal. A signal indicating execution is transmitted, and the first information processing apparatus is configured to execute the first transmission operation by receiving a signal indicating execution of the reception operation from the second signal line, Alternatively, the first information processing apparatus transmits a signal indicating execution of a receiving operation from the first signal line in response to the second request signal, and the second information processing apparatus transmits the signal from the first signal line. Receiving the signal indicating execution of the receiving operation. By configured to perform a transmission operation, characterized in that at least one of the second signal line and the first signal line, and also used as a signal line for transmitting a signal indicating the execution of the reception operation.

また、前記第2情報処理装置は、前記第1受信動作中に、前記第2送信動作で前記第1情報処理装置へのデータの送信に用いる信号線を介して、前記第1情報処理装置に所定のチェック用データを送信し、前記第1情報処理装置は、前記第1送信動作中に、前記第2情報処理装置から、前記所定のチェック用データを受信することにより正常にデータが送信されたと判断し、前記所定のチェック用データを受信しない場合に正常にデータが送信されなかったと判断し、前記第2情報処理装置は、前記第2送信動作から前記第1受信動作に切り替えたときに、前記第2送信動作で前記第1情報処理装置へのデータの送信に用いる信号線から、前記所定のチェック用データを送信することを特徴とする。   In addition, the second information processing apparatus communicates with the first information processing apparatus via a signal line used for transmitting data to the first information processing apparatus in the second transmission operation during the first reception operation. The first information processing apparatus transmits predetermined check data, and the first information processing apparatus receives the predetermined check data from the second information processing apparatus during the first transmission operation, whereby the data is normally transmitted. The second information processing apparatus determines that the data has not been transmitted normally when the predetermined check data is not received, and the second information processing apparatus switches from the second transmission operation to the first reception operation. The predetermined check data is transmitted from a signal line used for transmitting data to the first information processing apparatus in the second transmission operation.

また、前記第1送信動作において送信されるデータが複数バイトのデータで構成され、前記第2情報処理装置は、前記第1受信動作において、前記第1送信動作で送信される第2バイト以降のデータを受信する際に、前記第2送信動作で前記第1情報処理装置へのデータの送信に用いる信号線を介して、所定のチェック用のデータを送信し、前記第1情報処理装置は、前記第1送信動作において、第2バイト以降のデータを送信する際に、該第2バイト以降のデータの送信とともに、前記第2情報処理装置から送信される前記チェック用データを受信し、前記第2情報処理装置は、前記第2送信動作において、前記第1情報処理装置から送信される第1バイトのデータが、前記予め定められたデータではない場合に、前記第2送信動作から前記第1受信動作に切替えるとともに、該第1受信動作において、前記第1情報処理装置が前記第2バイト以降のデータを送信するときに、前記所定のチェック用データを送信することを特徴とする。   Further, the data transmitted in the first transmission operation is composed of data of a plurality of bytes, and the second information processing apparatus includes a second and subsequent bytes transmitted in the first transmission operation in the first reception operation. When receiving data, a predetermined check data is transmitted via a signal line used for transmitting data to the first information processing apparatus in the second transmission operation, and the first information processing apparatus In the first transmission operation, when the data after the second byte is transmitted, the check data transmitted from the second information processing apparatus is received together with the transmission of the data after the second byte, 2 In the second transmission operation, when the first byte data transmitted from the first information processing device is not the predetermined data in the second transmission operation, the second information processing device With switching to a first receive operation, in the first receive operation, when the first information processing apparatus transmits the data after the second byte, and transmits the predetermined data for checking.

本発明は、上記に示した構成を採用しているので、マスターとスレーブの通信開始が同時に発生しても、通信に失敗することなく、安定した通信が可能な同期式シリアル通信システムを実現する、という効果を発揮するものである。   Since the present invention employs the above-described configuration, it realizes a synchronous serial communication system capable of stable communication without failing in communication even when master and slave communication start simultaneously. , It demonstrates the effect.

本発明の第1の実施の形態における腕時計の回路構成を示すブロック図である。It is a block diagram which shows the circuit structure of the wristwatch in the 1st Embodiment of this invention. 本発明の第1の実施の形態におけるマスターのシリアル通信部と、スレーブのシリアル通信部の接続を表わしたブロック図である。It is a block diagram showing the connection of the serial communication part of the master in the 1st Embodiment of this invention, and the serial communication part of a slave. 本発明の第1の実施の形態におけるシリアル通信部の信号線の説明を示した図である。It is the figure which showed description of the signal wire | line of the serial communication part in the 1st Embodiment of this invention. 本発明の第1の実施の形態における通信データの形式を示した図である。It is the figure which showed the format of the communication data in the 1st Embodiment of this invention. 本発明の第1の実施の形態における、マスターから送信されるデータの例を示した図である。It is the figure which showed the example of the data transmitted from the master in the 1st Embodiment of this invention. 本発明の第1の実施の形態における、スレーブから送信されるデータの例を示した図である。It is the figure which showed the example of the data transmitted from the slave in the 1st Embodiment of this invention. 本発明の第1の実施の形態における、マスターから3バイトのデータ送信を実行する場合のタイミングチャートを示した図である。It is the figure which showed the timing chart in the case of performing data transmission of 3 bytes from the master in the 1st Embodiment of this invention. 本発明の第1の実施の形態における、マスターから3バイトのデータ送信を実行する場合の、MOSI信号線とMISO信号線のそれぞれで送信されるデータの値の例を示した図である。It is the figure which showed the example of the value of the data transmitted by each of a MOSI signal line and a MISO signal line in the case of performing 3-byte data transmission from the master in the 1st Embodiment of this invention. 本発明の第1の実施の形態における、スレーブから3バイトのデータ送信を実行する場合のタイミングチャートを示した図である。It is the figure which showed the timing chart in the case of performing data transmission of 3 bytes from the slave in the 1st Embodiment of this invention. 本発明の第1の実施の形態における、スレーブから3バイトのデータ送信を実行する場合の、MOSI信号線とMISO信号線のそれぞれで送信されるデータの値の例を示した図である。It is the figure which showed the example of the value of the data transmitted by each of a MOSI signal line and a MISO signal line in the case of performing 3-byte data transmission from the slave in the 1st Embodiment of this invention. 本発明の第1の実施の形態における、マスターから3バイト、スレーブから3バイトのデータ送信を同時に実行する場合のタイミングチャートを示した図である。It is the figure which showed the timing chart in the case of performing simultaneously the data transmission of 3 bytes from a master, and 3 bytes from a slave in the 1st Embodiment of this invention. 図11の通信における、MOSI信号線とMISO信号線のそれぞれで送信されるデータの値の例を示した図である。FIG. 12 is a diagram illustrating an example of data values transmitted on each of the MOSI signal line and the MISO signal line in the communication of FIG. 11. 本発明の第1の実施の形態における、図11の通信後に、スレーブが送信保留データの送信を開始するタイミングを示した図である。It is the figure which showed the timing which a slave starts transmission of transmission pending | holding data after the communication of FIG. 11 in the 1st Embodiment of this invention. 図13の通信における、MOSI信号線とMISO信号線のそれぞれで送信されるデータの値の例を示した図である。It is the figure which showed the example of the value of the data transmitted by each of a MOSI signal line and a MISO signal line in the communication of FIG. 本発明の第1の実施の形態における、送信側として動作する場合のマスターのフローチャートを示した図である。It is the figure which showed the flowchart of the master in the case of operate | moving as a transmission side in the 1st Embodiment of this invention. 本発明の第1の実施の形態における、マスターがRDYの立ち下りエッジを検知してから受信側として動作する場合のフローチャートを示した図である。It is the figure in the 1st Embodiment of this invention which showed the flowchart in case a master operate | moves as a receiving side after detecting the falling edge of RDY. 本発明の第1の実施の形態における、送信側として動作する場合のスレーブのフローチャートを示した図である。It is the figure which showed the flowchart of the slave in the case of operate | moving as a transmission side in the 1st Embodiment of this invention. 本発明の第1の実施の形態における、スレーブがSS信号線のLowレベルを検知してから受信側として動作する場合のフローチャートを示した図である。It is the figure in the 1st Embodiment of this invention which showed the flowchart in case a slave operate | moves as a receiving side after detecting the low level of SS signal line. REQ信号線を追加する場合の、マスターのシリアル通信部と、スレーブのシリアル通信部の接続を表わしたブロック図である。It is a block diagram showing the connection of the serial communication part of a master, and the serial communication part of a slave in the case of adding a REQ signal line. REQ信号線を追加する場合の、スレーブから3バイトのデータ送信を実行する場合のタイミングチャートを示した図である。It is the figure which showed the timing chart in the case of performing data transmission of 3 bytes from a slave in the case of adding a REQ signal line.

図面に基づいて、本発明の(第1の)実施形態における通信システムを説明する。
図1は、本発明の実施例としての腕時計の回路構成を示すブロック図である。第1情報処理装置としての主情報処理装置100は、操作部の入力処理や表示等の機能を含む、時計の基本的な処理を行なう。第2情報処理装置としての従情報処理装置200は、外部機器との通信処理や、周辺情報の計測処理、を行う。
Based on the drawings, a communication system in the (first) embodiment of the present invention will be described.
FIG. 1 is a block diagram showing a circuit configuration of a wristwatch as an embodiment of the present invention. The main information processing apparatus 100 as the first information processing apparatus performs basic processing of the clock including functions such as input processing and display of the operation unit. The slave information processing device 200 as the second information processing device performs communication processing with an external device and measurement processing of peripheral information.

主情報処理装置100は、ROM102と、RAM103と、計時部106と、表示部107と、入力部108と、内部クロック発生部120、をメイン・マイクロコンピュータであるマスター101に接続し、マスター101内にシリアル通信部110を内蔵する構成となっている。マスター101は、主情報処理装置100全体の制御を司る。マスター10
1のシリアル通信部110は、スレーブ201と同期式シリアル通信を行なうためのインターフェース部で、スレーブ201のシリアル通信部210と接続している。ROM102は、マスター101が主情報処理装置100全体を制御するためのプログラムなどが記憶される。RAM103は、マスター101のワークエリアとして使用される。計時部106は、基準発信周波数を元に現在の時刻を計時する。表示部107は、前記計時部106で計時している現在時刻と、スレーブ201から取得した情報に応じた内容、を表示する。表示部107は、例えば、複数の針による表示形態でもよいし、液晶表示等によるデジタルの表示形態でもよい。
The main information processing apparatus 100 connects a ROM 102, a RAM 103, a clock unit 106, a display unit 107, an input unit 108, and an internal clock generation unit 120 to a master 101 which is a main microcomputer. The serial communication unit 110 is built in. The master 101 controls the entire main information processing apparatus 100. Master 10
One serial communication unit 110 is an interface unit for performing synchronous serial communication with the slave 201 and is connected to the serial communication unit 210 of the slave 201. The ROM 102 stores a program for the master 101 to control the main information processing apparatus 100 as a whole. The RAM 103 is used as a work area for the master 101. The timer 106 measures the current time based on the reference transmission frequency. The display unit 107 displays the current time measured by the time measuring unit 106 and the contents corresponding to the information acquired from the slave 201. The display unit 107 may be, for example, a display form using a plurality of hands or a digital display form such as a liquid crystal display.

入力部108は、スイッチやりゅうずなど、入力装置の状態を検出する。送信データ記憶部104は、シリアル通信部110からスレーブ201へ送信するデ−タを記憶する部で、RAM103内に配置されている。受信データ記憶部105は、シリアル通信部110でスレーブ201から受信したデ−タを記憶し、RAM103内に配置されている。送信データ記憶部104、および受信データ記憶部105の記憶容量は、少なくとも、スレーブ201と同期式シリアル通信で通信する形式の最大バイト数があればよい。タイマー109は、同期式シリアル通信のエラーを検出するためのタイマー部である。内部クロック発生部120は、基本クロック発信器を元に、CPUクロックを発生させる。前記CPUクロックを元に、マスター101は内部回路の同期をとって動作している。基本クロック発信器としては、水晶発振器やシリコン発振器などがある。   The input unit 108 detects the state of the input device such as a switch crown. The transmission data storage unit 104 is a unit that stores data to be transmitted from the serial communication unit 110 to the slave 201, and is disposed in the RAM 103. The reception data storage unit 105 stores data received from the slave 201 by the serial communication unit 110 and is disposed in the RAM 103. The storage capacities of the transmission data storage unit 104 and the reception data storage unit 105 may be at least the maximum number of bytes in a format for communicating with the slave 201 by synchronous serial communication. The timer 109 is a timer unit for detecting an error in synchronous serial communication. The internal clock generator 120 generates a CPU clock based on the basic clock generator. Based on the CPU clock, the master 101 operates in synchronization with internal circuits. Examples of the basic clock oscillator include a crystal oscillator and a silicon oscillator.

従情報処理装置200は、ROM202と、RAM203と、計測部206と、外部通信部207と、内部クロック発生部220、をサブ・マイクロコンピュータであるスレーブ201に接続し、スレーブ201内にシリアル通信部210を内蔵する構成となっている。スレーブ201は、従情報処理装置200全体の制御を司る。スレーブ201のシリアル通信部210は、マスター101と同期式シリアル通信を行なうためのインターフェース部で、シリアル通信部110と接続している。ROM202は、スレーブ201が従情報処理装置200全体を制御するためのプログラムなどが記憶される。RAM203は、CPU201のワークエリアとして使用される。計測部206は、気温や気圧などの周辺情報を計測する。外部通信部207は、携帯電話や自動車など、外部機器と有線、または無線による通信を行なう。   The slave information processing device 200 connects a ROM 202, a RAM 203, a measurement unit 206, an external communication unit 207, and an internal clock generation unit 220 to a slave 201 that is a sub-microcomputer. 210 is built-in. The slave 201 controls the entire slave information processing apparatus 200. The serial communication unit 210 of the slave 201 is an interface unit for performing synchronous serial communication with the master 101 and is connected to the serial communication unit 110. The ROM 202 stores a program for the slave 201 to control the slave information processing apparatus 200 as a whole. The RAM 203 is used as a work area for the CPU 201. The measurement unit 206 measures peripheral information such as temperature and atmospheric pressure. The external communication unit 207 performs wired or wireless communication with an external device such as a mobile phone or a car.

送信データ記憶部204は、シリアル通信部210からマスター101へ送信するデ−タを記憶し、RAM203内に配置されている。受信データ記憶部205は、シリアル通信部210でマスター101から受信したデ−タを記憶し、RAM203内に配置されている。送信保留データ記憶部208は、シリアル通信部210からマスター101へのデータ送信をキャンセルした場合に送信デ−タを記憶し、RAM203内に配置されている。送信データ記憶部204、および受信データ記憶部205、および送信保留データ記憶部208の記憶容量は、少なくとも、マスター101と同期式シリアル通信で通信する形式の最大バイト数があればよい。タイマー209は、同期式シリアル通信のエラーを検出するためのタイマー部である。内部クロック発生部220は、基本クロック発信器を元に、CPUクロックを発生させる。前記CPUクロックを元に、スレーブ201は内部回路の同期をとって動作している。   The transmission data storage unit 204 stores data to be transmitted from the serial communication unit 210 to the master 101 and is disposed in the RAM 203. The received data storage unit 205 stores data received from the master 101 by the serial communication unit 210 and is arranged in the RAM 203. The transmission suspension data storage unit 208 stores transmission data when data transmission from the serial communication unit 210 to the master 101 is canceled, and is arranged in the RAM 203. The storage capacity of the transmission data storage unit 204, the reception data storage unit 205, and the transmission hold data storage unit 208 may be at least the maximum number of bytes in a format for communicating with the master 101 by synchronous serial communication. The timer 209 is a timer unit for detecting an error in synchronous serial communication. The internal clock generator 220 generates a CPU clock based on the basic clock generator. Based on the CPU clock, the slave 201 operates in synchronization with an internal circuit.

図2は、マスター101のシリアル通信部110と、スレーブ201のシリアル通信部210の接続を表わしたブロック図で、図3でそれぞれの接続線を説明した。   FIG. 2 is a block diagram showing the connection between the serial communication unit 110 of the master 101 and the serial communication unit 210 of the slave 201. Each connection line has been described with reference to FIG.

マスター101のシリアル通信部110、スレーブ201のシリアル通信部210には、「RDY」「SS」「SCK」「MOSI」「MISO」の入力端子又は出力端子が設けられ、同じ名称の端子どうしが接続線で接続されている。   The serial communication unit 110 of the master 101 and the serial communication unit 210 of the slave 201 are provided with input terminals or output terminals of “RDY”, “SS”, “SCK”, “MOSI”, and “MISO”, and terminals having the same name are connected to each other. Connected with wires.

SS信号線(スレーブ・セレクト)は、マスター101側は出力端子112、スレーブ201側は入力端子212である。これらを接続するSS信号線は、マスター101側から通信を開始する場合に、マスター101からスレーブ201に通信開始を通知する信号(第1要求信号)を出力して受信動作を要求する機能を果たす第1信号線として用いられ、また、スレーブ201側から通信を開始する場合にマスター101からスレーブ201に対して通信許可を通知する信号線として用いられる。   The SS signal line (slave select) is an output terminal 112 on the master 101 side and an input terminal 212 on the slave 201 side. The SS signal line that connects them performs a function of requesting a reception operation by outputting a signal (first request signal) for notifying the slave 201 of communication start when the communication is started from the master 101 side. Used as a first signal line, and also used as a signal line for notifying the slave 201 of communication permission when communication is started from the slave 201 side.

RDY信号線(通信準備完了)はスレーブ201側が出力端子211、マスター101側は入力端子111である。これらを接続するRDY信号線は、スレーブ201が、マスター101に対して送信するデータが準備完了したことを、スレーブ201からマスター101に通知する。スレーブ201から送信を開始する場合、RDY信号線は、マスター101に通信開始を通知する信号(第2要求信号)を出力して受信動作を要求する機能を果たす第2信号線として用いられる。   The RDY signal line (communication ready) is an output terminal 211 on the slave 201 side and an input terminal 111 on the master 101 side. The RDY signal line connecting them notifies the master 101 from the slave 201 that the slave 201 is ready for data to be transmitted to the master 101. When transmission is started from the slave 201, the RDY signal line is used as a second signal line that performs a function of requesting a reception operation by outputting a signal (second request signal) for notifying the master 101 of communication start.

SCK信号線は、マスター101側が出力端子113、スレーブ201側が入力端子213である。これらを接続するSCK信号線で、マスター101がプログラムでHighレベルとLowレベルを交互に発生させ、スレーブ201はSCK信号線のレベルの変化を利用してマスター101と同期する。   The SCK signal line has an output terminal 113 on the master 101 side and an input terminal 213 on the slave 201 side. With the SCK signal line connecting them, the master 101 alternately generates a high level and a low level by a program, and the slave 201 synchronizes with the master 101 using a change in the level of the SCK signal line.

MOSI信号線(マスター・アウト・スレーブ・イン)は、マスター101側が出力端子114、スレーブ側が入力端子214である。これらを接続するMOSI信号線は、マスター101側からスレーブ201側へデータを送信する第1信号線である。MISO信号線(マスター・イン・スレーブ・アウト)はスレーブ201側が出力端子215、マスター101側が入力端子115である。これらを接続するMISO信号線は、スレーブ201側からマスター101側へデータを送信する第2信号線である。   The MOSI signal line (master-out / slave-in) has an output terminal 114 on the master 101 side and an input terminal 214 on the slave side. The MOSI signal line that connects them is a first signal line that transmits data from the master 101 side to the slave 201 side. The MISO signal line (master-in-slave-out) has an output terminal 215 on the slave 201 side and an input terminal 115 on the master 101 side. The MISO signal line that connects them is a second signal line that transmits data from the slave 201 side to the master 101 side.

図4に本発明の第1の実施の形態による通信データの形式を示した。   FIG. 4 shows the format of communication data according to the first embodiment of the present invention.

送信側からの送信データは、コマンド(CMD)、データバイト数(n)、nバイトのデータ(D(1)〜D(n))、コマンドからデータまでをXORしたチェックサム(SUM)、の第n+3バイトの複数データから成る。本発明における同期式シリアル通信においては、1バイト通信毎に双方向で送信が行なわれるため、受信側からもデータが送信される。受信側からの送信データは、第1バイトには予め定められたデータとして、例えばNULL(00H)を準備し、第2〜第n+3バイトは、所定のチェック用データとして前回送信側から送信されて受信した第1〜第n+2バイトのデータをそのまま送るものとする。マスター101からの送信は、スレーブ201に対し、外部機器との通信処理や、気温や気圧などの各種周辺情報の計測処理、などの処理を実行させる必要が発生した場合や、スレーブ201からの要求に応じた情報を返す場合に実行される。図5がその一例である。   Transmission data from the transmission side includes a command (CMD), the number of data bytes (n), n-byte data (D (1) to D (n)), and a checksum (SUM) obtained by XORing the command to data. It consists of a plurality of n + 3 byte data. In the synchronous serial communication according to the present invention, data is transmitted from the receiving side because data is transmitted bidirectionally for each 1-byte communication. For the transmission data from the receiving side, for example, NULL (00H) is prepared in the first byte as predetermined data, and the second to n + 3 bytes are transmitted from the previous transmitting side as predetermined check data. Assume that the received first to (n + 2) th bytes of data are sent as they are. The transmission from the master 101 is performed when the slave 201 needs to execute processing such as communication processing with an external device, measurement processing of various kinds of peripheral information such as temperature and pressure, or a request from the slave 201. It is executed when returning information according to. FIG. 5 is an example.

図5は、マスター101から送信されるデータを示し、1段目と2段目は3バイトで構成されるデータの例、3段目〜5段目は、4バイトで構成されるデータの例である。1段目の「無線接続」と2段目の「無線切断」は、第1バイトのコマンドが「81H」と「82H」、第2バイトのデータ数がいずれも「0」、第3バイトにチェックサムが付与されている。3段目〜5段目は、第1バイトのコマンドが、「83H」「84H」「85H」、第2バイトのデータ数がいずれも「1」、第3バイトのデータが「残量」「位置」「位置」、第4バイトにチェックサムが付与されている。
スレーブ201からの送信は、マスター101に対し、表示内容変更の指示や、マスター101が管理する機器の状態に関する情報を要求する場合に実行される。図6がその一例である。
FIG. 5 shows data transmitted from the master 101. Examples of data composed of 3 bytes in the first and second stages. Examples of data composed of 4 bytes in the third to fifth stages. It is. The first stage “wireless connection” and the second stage “wireless disconnection” have the first byte command “81H” and “82H”, the second byte data count is both “0”, and the third byte. A checksum is given. In the third to fifth tiers, the command of the first byte is “83H”, “84H”, “85H”, the number of data of the second byte is “1”, the data of the third byte is “remaining”, “ A checksum is given to the “position”, “position”, and the fourth byte.
The transmission from the slave 201 is executed when the master 101 is requested to change the display contents or request information regarding the status of the device managed by the master 101. FIG. 6 is an example.

図6は、スレーブ201から送信されるデータを示し、1段目は9バイトで構成されるデータの例、2段目は3バイトで構成されるデータの例、3段目と4段目は4バイトで構成されるデータの例である。1段目の「時刻設定」は、第1バイトのコマンドが「02H」、第2バイトのデータ数が「6」、第3バイトのデータが「年」、第4バイトのデータが「月」、第5バイトのデータが「日」、第6バイトのデータが「時」、第7バイトのデータが「分」、第8バイトのデータが「秒」、第9バイトにチェックサムが付与されている。2段目の「電池残量問い合わせ」は、第1バイトのコマンドが「01H」、第2バイトのデータ数が「0」、第3バイトのデータにチェックサムが付与されている。3段目〜4段目は、第1バイトのコマンドが、「03H」「04H」、第2バイトのデータ数がいずれも「1」、第3バイトのデータが「秒針位置」「分針位置」、第4バイトにチェックサムが付与されている。   FIG. 6 shows data transmitted from the slave 201. The first stage is an example of data composed of 9 bytes, the second stage is an example of data composed of 3 bytes, the third stage and the fourth stage are It is an example of data composed of 4 bytes. “Time setting” in the first row is “02H” for the first byte command, “6” for the second byte data, “year” for the third byte data, and “month” for the fourth byte data. The fifth byte data is “day”, the sixth byte data is “hour”, the seventh byte data is “minute”, the eighth byte data is “second”, and the ninth byte is given a checksum. ing. In the second stage “remaining battery amount inquiry”, the command of the first byte is “01H”, the number of data of the second byte is “0”, and the checksum is added to the data of the third byte. In the third to fourth stages, the first byte command is “03H” “04H”, the number of second byte data is “1”, the third byte data is “second hand position”, “minute hand position”. A checksum is added to the fourth byte.

次に、本発明における同期式シリアル通信の動作について説明する。
本発明の同期式シリアル通信の動作には3つの動作がある。1つ目は、マスター101がスレーブ201に対して受信動作を要求してからマスター101がデータを送信し(マスターが第1送信動作を行い)、スレーブ201がマスター101から送信されるデータを受信する(第1受信動作を行う)場合の通信動作である。2つ目は、スレーブ201がマスター101に対して受信動作を要求してからスレーブ201がデータを送信し(スレーブ201が第2送信動作を行い)、マスター101がスレーブ201から送信されるデータを受信する(マスター101が第2受信動作を行う)場合の通信動作である。3つめは、マスター101とスレーブ201が同時に通信相手に対して受信動作を要求して、それぞれが、同時に第1及び第2送信動作を開始してから、スレーブ201が、第1受信動作に切替る場合の通信動作である。
Next, the operation of the synchronous serial communication in the present invention will be described.
There are three operations in the operation of the synchronous serial communication of the present invention. First, after the master 101 requests the slave 201 to receive data, the master 101 transmits data (the master performs the first transmission operation), and the slave 201 receives data transmitted from the master 101. This is a communication operation in the case of performing (performing the first reception operation). Second, slave 201 transmits data after slave 201 requests master 101 to receive data (slave 201 performs a second transmission operation), and master 101 transmits data transmitted from slave 201. This is a communication operation when receiving (the master 101 performs the second reception operation). Third, the master 101 and the slave 201 simultaneously request the receiving party to perform a receiving operation, and each starts the first and second transmitting operations at the same time, and then the slave 201 switches to the first receiving operation. Communication operation when

尚、以下に説明する各通信動作において、送信でMISO信号線、MOSI信号線にセットするレベルは、送信する値が1の場合はHighレベル、0の場合はLowレベルとする。受信でMISO信号線、MOSI信号線がHighレベルの場合は受信値は1とし、Lowレベルの場合は受信値は0とする。   In each communication operation described below, the level set to the MISO signal line and the MOSI signal line by transmission is set to the high level when the value to be transmitted is 1, and to the low level when it is 0. The received value is 1 when the MISO signal line and the MOSI signal line are at the high level during reception, and the received value is 0 when the signal is at the low level.

まず、マスター101がスレーブ201に対して受信動作を要求してからマスター101がデータを送信し(マスターが第1送信動作を行い)、スレーブ201がマスター101から送信されるデータを受信する(第1受信動作を行う)場合の動作について説明する。
図7は、マスター101から3バイトの送信を実行する場合のタイミングチャートである。ここで、マスター101、スレーブ201の双方の送信データは図8の内容とする。
マスター101において、スレーブ201へ通信する必要が発生した場合、送信データを送信データ記憶部104に格納し、通信(第1送信動作)を開始する。具体的には、送信データ記憶部104の先頭の第1バイトの記憶領域から、81H、00H、81Hの順に格納する。
First, after the master 101 requests the slave 201 to receive data, the master 101 transmits data (the master performs a first transmission operation), and the slave 201 receives data transmitted from the master 101 (first The operation when 1 reception operation is performed) will be described.
FIG. 7 is a timing chart when transmission of 3 bytes from the master 101 is executed. Here, the transmission data of both the master 101 and the slave 201 has the contents shown in FIG.
When it is necessary for the master 101 to communicate with the slave 201, the transmission data is stored in the transmission data storage unit 104 and communication (first transmission operation) is started. Specifically, the first byte storage area of the transmission data storage unit 104 is stored in the order of 81H, 00H, and 81H.

まず、マスター101は、SS信号線をLowレベルにして第1要求信号を出力することにより、通信開始および通信許可をスレーブ201に通知する(図7のa)。スレーブ201は、SS信号線がLowレベルであることを検知すると(図7のa)、以下のように受信側として通信(第1受信動作)を開始する。送信データ記憶部204の第1バイト用の記憶領域に、受信側であることを示す所定値、NULLを格納する。送信データ記憶部204の第1バイト用の記憶領域に記憶した値NULLを構成するLSB側の第1ビットの値を送信用のデータとしてMISO信号線にセットした後(図7のb)、RDY信号線が一定期間だけLowレベルとなるRDYパルスを出力する(図7のc)。前記RDYパルスを出力することにより、1バイト目の通信準備完了をマスター101へ通知する。すなわち、RDYパルスによって、スレーブ201による受信動作の実行が、マスター101に通
知される。この動作により、スレーブ201から送信する第1バイトのデータのうちの第1ビットのデータを送信する(図7のb)。前記RDYパルスのLowレベルを保持する時間は、マスター101でRDY信号線をポーリングするために十分な時間であればよい。
First, the master 101 notifies the slave 201 of communication start and communication permission by setting the SS signal line to a low level and outputting a first request signal (a in FIG. 7). When the slave 201 detects that the SS signal line is at a low level (a in FIG. 7), the slave 201 starts communication (first reception operation) as a receiving side as follows. A predetermined value indicating NULL is stored in the storage area for the first byte of the transmission data storage unit 204, and NULL is stored. After setting the value of the first bit on the LSB side constituting the value NULL stored in the storage area for the first byte of the transmission data storage unit 204 to the MISO signal line as transmission data (b in FIG. 7), RDY The RDY pulse that outputs the signal line at a low level for a certain period is output (c in FIG. 7). By outputting the RDY pulse, the master 101 is notified of the completion of communication preparation for the first byte. That is, the master 101 is notified of the execution of the reception operation by the slave 201 by the RDY pulse. By this operation, the first bit data of the first byte data transmitted from the slave 201 is transmitted (b in FIG. 7). The time for holding the low level of the RDY pulse may be sufficient for the master 101 to poll the RDY signal line.

マスター101では、RDY信号線の立ち下りエッジを検知すると(図7のc)、以下のように送信側として第1送信動作を実行する。送信データ記憶部104に記憶した第1バイトの値81Hを構成するLSB側の第1ビットの値を送信用のデータとしてMOSI信号線にセットしてから(図7のA)、SCK信号線をHighレベルにする(図7のB)。そして、MISO信号線に入力されるレベル(図7のbのレベル)を受信データ記憶部105における第1バイトのLSB側の第1ビット用の記憶領域に受信したデータとして記憶した後、SCK信号線をLowレベルにする(図7のC)。これらの動作により、マスター101から送信する第1バイトのデータのうちの第1ビットのデータを送信し(図7のA)、スレーブ201から送信される第1バイトのデータのうちの第1ビットのデータを受信する(図7のb)。   When detecting the falling edge of the RDY signal line (c in FIG. 7), the master 101 executes the first transmission operation as the transmission side as follows. After setting the value of the first bit on the LSB side constituting the first byte value 81H stored in the transmission data storage unit 104 to the MOSI signal line as data for transmission (A in FIG. 7), the SCK signal line is High level is set (B in FIG. 7). Then, the level (level b in FIG. 7) input to the MISO signal line is stored as the received data in the first bit storage area on the LSB side of the first byte in the reception data storage unit 105, and then the SCK signal The line is set to the low level (C in FIG. 7). By these operations, the first bit data of the first byte data transmitted from the master 101 is transmitted (A in FIG. 7), and the first bit of the first byte data transmitted from the slave 201 is transmitted. Is received (b in FIG. 7).

次に、送信データ記憶部104に記憶されている第1バイトの値81Hを構成するLSB側の第2ビットの値を送信用のデータとしてMOSI信号線にセットしてから(図7のD)、SCK信号線をHighレベルにする(図7のE)。そして、MISO信号線に入力されるレベル(図7のdのレベル)を受信データ記憶部105における第1バイトのLSB側の第2ビット用の記憶領域に受信したデータとして記憶した後、SCK信号線をLowレベルにする(図7のF)。これらの動作により、マスター101から送信する第1バイトのデータのうちの第2ビットのデータを送信し(図7のD)、スレーブ201から送信される第1バイトのデータうちの第2ビットのデータを受信する(図7のd)。第3ビットから第8ビットも同様にして繰返す。以上で第1バイトの通信を終了し、マスター101は、2バイト目のRDYパルスの立ち下りエッジ(図7のe)を検知することを待つ状態となる。   Next, after setting the value of the second bit on the LSB side constituting the value 81H of the first byte stored in the transmission data storage unit 104 to the MOSI signal line as data for transmission (D in FIG. 7) The SCK signal line is set to the high level (E in FIG. 7). Then, after the level input to the MISO signal line (level d in FIG. 7) is stored as the received data in the second bit storage area on the LSB side of the first byte in the reception data storage unit 105, the SCK signal The line is set to the low level (F in FIG. 7). By these operations, the second bit data of the first byte data transmitted from the master 101 is transmitted (D in FIG. 7), and the second bit data of the first byte data transmitted from the slave 201 is transmitted. Data is received (d in FIG. 7). The same process is repeated for the third to eighth bits. Thus, the communication of the first byte is completed, and the master 101 waits to detect the falling edge (e in FIG. 7) of the RDY pulse of the second byte.

スレーブ201は、SCK信号線の立ち上がりエッジを検知すると(図7のB)、MOSI信号線に入力されるレベル(図7のAのレベル)を受信データ記憶部205における第1バイトのLSB側の第1ビット用の記憶領域に受信したデータとして記憶する。そして、SCK信号線の立ち下りエッジを検知すると(図7のC)、送信データ記憶部204に記憶されている第1バイトの値NULLを構成するLSB側の第2ビットの値を送信用のデータとしてMISO信号線にセットする(図7のd)。   When the slave 201 detects the rising edge of the SCK signal line (B in FIG. 7), the slave 201 sets the level (A level in FIG. 7) input to the MOSI signal line on the LSB side of the first byte in the received data storage unit 205. The received data is stored in the first bit storage area. When the falling edge of the SCK signal line is detected (C in FIG. 7), the value of the second bit on the LSB side constituting the value NULL of the first byte stored in the transmission data storage unit 204 is used for transmission. Data is set on the MISO signal line (d in FIG. 7).

次に、SCK信号線が立ち上がりエッジを検知すると(図7のE)、MOSI信号線に入力されるレベル(図7のDのレベル)を受信データ記憶部205における第1バイトのLSB側の第2ビット用の記憶領域に受信したデータとして記憶する。これらの動作により、マスター101から送信される第1バイトのデータのうちの第2ビットまでのデータ(図7のAとDのデータ)を受信し、スレーブ201から送信する第1バイトのデータのうちの第2ビットまでのデータ(図7のbとdのデータ)を送信する。第3ビットから第8ビットも同様にして繰返して第1バイトの通信を行なう。2バイト目の送信データは、1バイト目で受信した、受信データ記憶部205に記憶されている第1バイトの値81Hである。これを送信データ記憶部204における第2バイト用の記憶領域に格納する。送信データ記憶部204に記憶されている第2バイトの値81Hを構成するLSB側の第1ビットの値をMISO信号線に送信用のデータとしてセットした後、RDYパルスを出力することにより(図7のe)、2バイト目の通信準備完了をマスター101へ通知する。その後、SCK信号線の立ち上がりエッジを検知するまで待ち状態となる。   Next, when the rising edge of the SCK signal line is detected (E in FIG. 7), the level (D level in FIG. 7) input to the MOSI signal line is set to the first byte on the LSB side of the first byte in the received data storage unit 205. The received data is stored in the 2-bit storage area. With these operations, data up to the second bit (data A and D in FIG. 7) of the first byte data transmitted from the master 101 is received, and the first byte data transmitted from the slave 201 is received. Data up to the second bit (b and d data in FIG. 7) is transmitted. The first byte communication is repeated in the same manner for the third to eighth bits. The transmission data of the second byte is the value 81H of the first byte stored in the reception data storage unit 205 received at the first byte. This is stored in the storage area for the second byte in the transmission data storage unit 204. By setting the value of the first bit on the LSB side constituting the value 81H of the second byte stored in the transmission data storage unit 204 to the MISO signal line as data for transmission, an RDY pulse is output (FIG. 7 e) Notifying the master 101 of completion of communication preparation for the second byte. Thereafter, the process waits until the rising edge of the SCK signal line is detected.

マスター101からスレーブ201への送信データの2バイト目は送信データ記憶部104に記憶されている第2バイトの値00H、3バイト目は送信データ記憶部104に記
憶されている第3バイトの値81Hである。スレーブ201からマスター101への送信データの3バイト目は、2バイト目でマスター101から受信し、送信データ記憶部204の第3バイト用の記憶領域に記憶した値00Hである。このように、マスター101から送信される複数バイトのデータのうち、2バイト目以降のデータを受信するときに、スレーブ201は、1バイト前の通信でマスター101から受信したデータ(所定のチェック用データ)をマスター102に送信する。マスター101は、2バイト目以降のデータを送信するときに、1バイト前の通信で自ら送信したデータ(所定のチェック用データ)をスレーブ201から受信する。
The second byte of the transmission data from the master 101 to the slave 201 is the second byte value 00H stored in the transmission data storage unit 104, and the third byte is the third byte value stored in the transmission data storage unit 104. 81H. The third byte of transmission data from the slave 201 to the master 101 is the value 00H received from the master 101 at the second byte and stored in the third byte storage area of the transmission data storage unit 204. As described above, when receiving data after the second byte among the data of a plurality of bytes transmitted from the master 101, the slave 201 receives data (predetermined check data) received from the master 101 in the previous communication. Data) to the master 102. When the master 101 transmits data after the second byte, the master 101 receives data (predetermined check data) transmitted by itself in communication one byte before from the slave 201.

3バイトの通信が終了すると、スレーブ201は、RDYパルスを出力することにより、通信終了および通信禁止をマスター101へ通知する。(図7のf)
マスター101は3バイトの通信後に、RDY信号線の立ち下りエッジを検知すると(図7のf)、SS信号線をHighレベルにすることにより、通信終了および通信禁止をスレーブ201に通知する(図7のg)。
When the communication of 3 bytes is completed, the slave 201 notifies the master 101 of the communication end and communication prohibition by outputting an RDY pulse. (F in FIG. 7)
When the master 101 detects the falling edge of the RDY signal line after 3 bytes of communication (f in FIG. 7), the master 101 notifies the slave 201 of communication end and communication prohibition by setting the SS signal line to the high level (FIG. 7). 7 g).

次に、スレーブ201がマスター101に対して受信動作を要求してからスレーブ201がデータを送信し(スレーブ201が第2送信動作を行い)、マスター101がスレーブ201から送信されるデータを受信する(マスター101が第2受信動作を行う)場合の通信動作について説明する。図9は、スレーブ201から3バイトの送信を実行する場合のタイミングチャートである。ここで、マスター101、スレーブ201の双方の送信データは図10の内容とする。   Next, after the slave 201 requests a reception operation from the master 101, the slave 201 transmits data (the slave 201 performs a second transmission operation), and the master 101 receives data transmitted from the slave 201. A communication operation when the master 101 performs the second reception operation will be described. FIG. 9 is a timing chart when 3 bytes are transmitted from the slave 201. Here, the transmission data of both the master 101 and the slave 201 has the contents shown in FIG.

スレーブ201において、マスター101へ通信する必要が発生した場合、SS信号線がLowレベルである場合は、マスター101が通信処理中であるので、SS信号線がHighレベルになるのを待つ。SS信号線がHighレベルである場合は、送信データを送信データ記憶部204に格納し、通信(第2送信動作)を開始する。具体的には、送信データ記憶部204の先頭の第1バイトの記憶領域から、01H、00H、01Hを順に格納する。
まず、スレーブ201は、送信データ記憶部204の第1バイト用の記憶領域に記憶された値01Hを構成するLSB側の第1ビットの値1を送信用のデータとしてMISO信号線にセットした後(図9のb)、第2要求信号としてRDYパルスを出力することにより、通信開始および1バイト目の通信準備完了をマスター101へ通知する(図9のc)。
When it is necessary for the slave 201 to communicate with the master 101, if the SS signal line is at a low level, the master 101 is in communication processing, and therefore waits for the SS signal line to be at a high level. When the SS signal line is at the high level, the transmission data is stored in the transmission data storage unit 204, and communication (second transmission operation) is started. Specifically, 01H, 00H, and 01H are sequentially stored from the first byte storage area of the transmission data storage unit 204.
First, the slave 201 sets the LSB side first bit value 1 constituting the value 01H stored in the first byte storage area of the transmission data storage unit 204 as transmission data to the MISO signal line. (B in FIG. 9), by outputting an RDY pulse as the second request signal, the master 101 is notified of the start of communication and the completion of communication preparation for the first byte (c in FIG. 9).

マスター101は、RDY信号線の立ち下りエッジを検知すると(図9のc)、以下のように受信側として通信(第2受信動作)を開始する。送信データ記憶部104の第1バイト用の記憶領域に、受信側であるとこを示す所定値、NULLを格納する。SS信号線をLowレベルにしてスレーブ201に対して通信許可を通知する(図9のa)。すなわち、SS信号線をLowレベルにすることによって、マスター101の受信動作の実行が、スレーブ201に通知される。その後、送信データ記憶部104の第1バイト用の記憶領域に記憶された値NULLを構成するLSB側の第1ビットの値を送信用のデータとしてMOSI信号線にセットしてから(図9のA)、SCK信号線をHighレベルにする(図9のB)。そして、MISO信号線に入力されるレベル(図9のbのレベル)を受信データ記憶部105における第1バイトのLSB側の第1ビット用の記憶領域に記憶した後、SCK信号線をLowレベルにする(図9のC)。これらの動作により、マスター101から送信する第1バイトのデータのうちの第1ビットのデータを送信し(図9のA)、スレーブ201から送信される第1バイトのデータのうちの第1ビットのデータを受信する(図9のb)。   When the master 101 detects the falling edge of the RDY signal line (c in FIG. 9), it starts communication (second reception operation) as the receiving side as follows. A predetermined value indicating NULL is stored in the storage area for the first byte of the transmission data storage unit 104, indicating NULL. The SS signal line is set to Low level to notify the slave 201 of communication permission (a in FIG. 9). In other words, the execution of the reception operation of the master 101 is notified to the slave 201 by setting the SS signal line to the low level. Thereafter, the value of the first bit on the LSB side constituting the value NULL stored in the storage area for the first byte of the transmission data storage unit 104 is set as transmission data on the MOSI signal line (FIG. 9). A), the SCK signal line is set to the high level (B in FIG. 9). Then, after the level (the level b in FIG. 9) input to the MISO signal line is stored in the first bit storage area on the LSB side of the first byte in the received data storage unit 105, the SCK signal line is set to the low level. (C in FIG. 9). By these operations, the first bit data of the first byte data transmitted from the master 101 is transmitted (A in FIG. 9), and the first bit of the first byte data transmitted from the slave 201 is transmitted. Is received (b in FIG. 9).

次に、送信データ記憶部104に記憶されている第1バイトの値NULLを構成するLSB側の第2ビットの値0を送信用のデータとしてMOSI信号線にセットしてから(図9のD)、SCK信号線をHighレベルにする(図9のE)。そして、MISO信号線に入力
されるレベル(図9のdのレベル)を受信データ記憶部105における第1バイトのLSB側の第2ビット用の記憶領域に受信データとして記憶した後、SCK信号線をLowレベルにする(図9のF)。これらの動作により、マスター101から送信する第1バイトのデータのうちの第2ビットのデータを送信し(図9のD)、スレーブ201から送信される第1バイトのデータうちの第2ビットのデータを受信する(図9のd)。第3ビットから第8ビットも同様にして繰返して1バイト通信を終了する。2バイト目の送信データは、1バイト目で受信した、受信データ記憶部105の第1バイト用の記憶領域に記憶されている値01Hである。これを送信データ記憶部104の第2バイト用の記憶領域に格納する。その後、マスター101は、2バイト目のRDY信号線の立ち下りエッジ(図9のe)の検知を待つ状態となる。
Next, the value 0 of the second bit on the LSB side constituting the value NULL of the first byte stored in the transmission data storage unit 104 is set to the MOSI signal line as data for transmission (D in FIG. 9). ), The SCK signal line is set to the high level (E in FIG. 9). Then, after the level (d in FIG. 9) input to the MISO signal line is stored as received data in the second bit storage area on the LSB side of the first byte in the received data storage unit 105, the SCK signal line is stored. Is set to Low level (F in FIG. 9). By these operations, the second bit data of the first byte data transmitted from the master 101 is transmitted (D in FIG. 9), and the second bit data of the first byte data transmitted from the slave 201 is transmitted. Data is received (d in FIG. 9). Similarly, the third to eighth bits are repeated to complete one-byte communication. The transmission data of the second byte is the value 01H stored in the storage area for the first byte of the reception data storage unit 105 received at the first byte. This is stored in the storage area for the second byte of the transmission data storage unit 104. Thereafter, the master 101 waits for detection of the falling edge of the second byte RDY signal line (e in FIG. 9).

スレーブ201は、SS信号線のLowレベルを検知することにより(図9のa)、通信が開始されたと判断する。まず、SCK信号線の立ち上がりエッジを検知すると(図9のB)、MOSI信号線に入力されるレベル(図9のAのレベル)を受信データ記憶部205における第1バイトのLSB側の第1ビット用の記憶領域に受信データとして記憶する。そして、SCK信号線の立ち下りエッジを検知すると(図9のC)、送信データ記憶部204の第1バイト用の記憶領域に記憶された値01Hを構成するLSB側の第2ビットの値0を送信用のデータとしてMISO信号線にセットする(図9のd)。   The slave 201 determines that communication has started by detecting the low level of the SS signal line (a in FIG. 9). First, when the rising edge of the SCK signal line is detected (B in FIG. 9), the level input to the MOSI signal line (the level A in FIG. 9) is set to the first LSB side of the first byte in the received data storage unit 205. The received data is stored in the bit storage area. When the falling edge of the SCK signal line is detected (C in FIG. 9), the value 0 of the second bit on the LSB side constituting the value 01H stored in the storage area for the first byte of the transmission data storage unit 204 Is set to the MISO signal line as data for transmission (d in FIG. 9).

次に、SCK信号線の立ち上がりエッジを検知すると(図9のE)、MOSI信号線に入力されるレベル(図9のDのレベル)を受信データ記憶部205における第1バイトのLSB側の第2ビット用の記憶領域に受信データとして記憶する。これらの動作により、マスター101から送信される第1バイトのデータのうちの第2ビットまでのデータ(図9のAとDのデータ)を受信し、スレーブ201から送信する第1バイトのデータのうちの第2ビットまでのデータ(図9のbとdのデータ)を送信する。第3ビットから第8ビットも同様にして繰返して第1バイトの通信を行なう。   Next, when the rising edge of the SCK signal line is detected (E in FIG. 9), the level input to the MOSI signal line (the level D in FIG. 9) is changed to the first byte on the LSB side of the first byte in the reception data storage unit 205. The received data is stored in a 2-bit storage area. With these operations, data up to the second bit (data A and D in FIG. 9) of the first byte data transmitted from the master 101 is received, and the first byte data transmitted from the slave 201 is received. Data up to the second bit (data b and d in FIG. 9) is transmitted. The first byte communication is repeated in the same manner for the third to eighth bits.

スレーブ201からマスター101への送信データの2バイト目は送信データ記憶部204の第2バイト用の記憶領域に記憶されている値00Hである。前記00Hを構成するLSB側の第1ビットの値0を送信用のデータとしてMISO信号線にセットした後、RDYパルスを出力することにより(図9のe)、2バイト目の通信準備完了をマスター101へ通知する。その後、SCK信号線の立ち上がりエッジを検知するまで待ち状態となる。   The second byte of transmission data from the slave 201 to the master 101 is a value 00H stored in the second byte storage area of the transmission data storage unit 204. After setting the value 0 of the first bit on the LSB side constituting 00H to the MISO signal line as transmission data, the RDY pulse is output (e in FIG. 9) to complete the communication preparation for the second byte. Notify the master 101. Thereafter, the process waits until the rising edge of the SCK signal line is detected.

スレーブ201からマスター101への送信データの3バイト目は送信データ記憶部204における第3バイト用の記憶領域に記憶されている値01Hである。
マスター101からスレーブ201への送信データの3バイト目は、2バイト目でスレーブ201から受信し、送信データ記憶部104における第3バイト用の記憶領域にコピーして記憶した値00Hである。
The third byte of transmission data from the slave 201 to the master 101 is the value 01H stored in the third byte storage area in the transmission data storage unit 204.
The third byte of transmission data from the master 101 to the slave 201 is a value 00H received from the slave 201 at the second byte, copied and stored in the third byte storage area in the transmission data storage unit 104.

3バイトの通信が終了すると、スレーブ201は、RDYパルスを出力することにより、通信終了および通信禁止をマスター101へ通知する(図9のf)。
マスター101は3バイトの通信後のRDYパルスの立ち下りエッジを検知すると(図9のf)、SS信号線をHighレベルにすることにより、通信終了および通信禁止をスレーブ201に通知する(図9のg)。
When the 3-byte communication is completed, the slave 201 notifies the master 101 of the communication end and the communication inhibition by outputting an RDY pulse (f in FIG. 9).
When the master 101 detects the falling edge of the RDY pulse after communication of 3 bytes (f in FIG. 9), the master 101 notifies the slave 201 of communication end and communication prohibition by setting the SS signal line to the high level (FIG. 9). G).

次に、マスター101とスレーブ201が同時に通信相手に対して受信動作を要求して、それぞれが、同時に第1及び第2送信動作を開始してから、スレーブ201が、第1受信動作に切替る場合の動作について説明する。   Next, after the master 101 and the slave 201 simultaneously request the communication partner to perform a reception operation, and each starts the first and second transmission operations at the same time, the slave 201 switches to the first reception operation. The operation in this case will be described.

図11は、マスター101とスレーブ201が同時に送信を開始するタイミングを示し
た図である。ここで、マスター101は、図12(a)に示すように、図8のMOSIの送信データを送信するものとする。具体的には、送信データ記憶部104の先頭の第1バイト用の記憶領域から、81H、00H、81Hの順に格納する。また、スレーブ201は、図12(a)に示すように、図10のMISOの送信データを送信するものとする。具体的には、送信データ記憶部204の先頭の第1バイト用の記憶領域から、01H、00H、01Hを順に格納する。
FIG. 11 is a diagram illustrating the timing at which the master 101 and the slave 201 simultaneously start transmission. Here, it is assumed that the master 101 transmits the transmission data of the MOSI of FIG. 8 as shown in FIG. Specifically, the first byte storage area of the transmission data storage unit 104 is stored in the order of 81H, 00H, and 81H. In addition, as shown in FIG. 12A, the slave 201 transmits the transmission data of the MISO in FIG. Specifically, 01H, 00H, and 01H are sequentially stored from the first byte storage area of the transmission data storage unit 204.

マスター101は、送信側として通信(第1送信動作)を開始する。すなわち、通信開始および通信許可をスレーブ201に通知するため、SS信号線をLowレベルにして第1要求信号を出力する(図11のa)。そして、RDY信号線の立下りを検出するのを待つ。   The master 101 starts communication (first transmission operation) as a transmission side. That is, in order to notify the slave 201 of communication start and communication permission, the SS signal line is set to low level and the first request signal is output (a in FIG. 11). Then, it waits to detect the fall of the RDY signal line.

スレーブ201もまた、送信側として通信(第2送信動作)を開始する。すなわち、送信データ記憶部204に記憶されている第1バイトの値01Hを構成するLSB側の第1ビットの値を送信用のデータとしてMISO信号線にセットした後(図11のb)、第2要求信号であるRDYパルスを出力することにより、通信開始および1バイト目の通信準備完了をマスター101へ通知する(図11のc)。   The slave 201 also starts communication (second transmission operation) as a transmission side. That is, after setting the value of the first bit on the LSB side constituting the value 01H of the first byte stored in the transmission data storage unit 204 to the MISO signal line as transmission data (b in FIG. 11), By outputting an RDY pulse that is a 2 request signal, the master 101 is notified of the start of communication and the completion of communication preparation for the first byte (c in FIG. 11).

マスター101は、RDYパルスを検出して(図11のc)、このパルスをスレーブ201の通信準備完了の信号、すなわち、スレーブ201の受信動作の実行を通知する信号であると判断し、以下のように送信側として通信を継続する。   The master 101 detects the RDY pulse (c in FIG. 11), determines that this pulse is a signal indicating that the slave 201 is ready for communication, that is, a signal notifying the execution of the reception operation of the slave 201. Thus, communication is continued as the transmission side.

送信データ記憶部104に記憶されている第1バイトの値81Hを構成するLSB側の第1ビットの値を送信用のデータとしてMOSI信号線にセットしてから(図11のA)、SCK信号線をHighレベルにする(図11のB)。そして、MISO信号線に入力されるレベル(図11のbのレベル)を受信データ記憶部105における第1バイトのLSB側の第1ビット用の記憶領域に受信したデータとして記憶した後、SCK信号線をLowレベルにする(図11のC)。これらの動作により、マスター101から送信する第1バイトのデータのうちの第1ビットのデータを送信し(図11のA)、スレーブ201から送信される第1バイトのデータのうちの第1ビットのデータを受信する(図11のb)。   The value of the first bit on the LSB side constituting the value 81H of the first byte stored in the transmission data storage unit 104 is set on the MOSI signal line as data for transmission (A in FIG. 11), and then the SCK signal The line is set to the high level (B in FIG. 11). Then, the level (level b in FIG. 11) input to the MISO signal line is stored as the received data in the first bit storage area on the LSB side of the first byte in the reception data storage unit 105, and then the SCK signal The line is set to the low level (C in FIG. 11). By these operations, the first bit data of the first byte data transmitted from the master 101 is transmitted (A in FIG. 11), and the first bit of the first byte data transmitted from the slave 201 is transmitted. Is received (b in FIG. 11).

次に、送信データ記憶部104における第1バイトの値81Hを構成するLSB側の第2ビットの値を送信用のデータとしてMOSI信号線にセットしてから(図11のD)、SCK信号線をHighレベルにする(図11のE)。そして、MISO信号線に入力されるレベル(図11のdのレベル)を受信データ記憶部105における第1バイトのLSB側の第2ビット用の記憶領域に受信データとして記憶した後、SCK信号線をLowレベルにする(図11のF)。これらの動作により、マスター101から送信する第1バイトのデータのうちの第2ビットのデータを送信し(図11のD)、スレーブ201から送信される第1バイトのデータうちの第2ビットのデータを受信する(図11のd)。第3ビットから第8ビットも同様にして繰返す。以上で1バイト目の通信を終了し、マスター101は、2バイト目のRDYの立ち下りエッジ(図11のe)を検知することを待つ状態となる。   Next, the value of the second bit on the LSB side constituting the value 81H of the first byte in the transmission data storage unit 104 is set to the MOSI signal line as data for transmission (D in FIG. 11), and then the SCK signal line Is set to the high level (E in FIG. 11). Then, after the level input to the MISO signal line (level d in FIG. 11) is stored as reception data in the second bit storage area on the LSB side of the first byte in the reception data storage unit 105, the SCK signal line Is set to Low level (F in FIG. 11). By these operations, the second bit data of the first byte data transmitted from the master 101 is transmitted (D in FIG. 11), and the second bit data of the first byte data transmitted from the slave 201 is transmitted. Data is received (d in FIG. 11). The same process is repeated for the third to eighth bits. Thus, the communication of the first byte is completed, and the master 101 waits to detect the falling edge of RDY of the second byte (e in FIG. 11).

スレーブ201もまた、SS信号線のLowレベルを検知することにより、マスター101の受信動作の実行を通知する信号であると判断して、以下のように送信側として通信(第2送信動作)を開始する。まず、SCK信号線の立ち上がりエッジを検知すると(図11のB)、MOSI信号線に入力されるレベル(図11のAのレベル)を受信データ記憶部205における第1バイトのLSB側の第1ビット用の記憶領域に受信したデータとして記憶し、SCK信号線の立ち下りエッジを検知すると(図11のC)、送信データ記憶部204に記憶されている第1バイトの値01Hを構成するLSB側の第2ビットの値を送信用のデータとしてMISO信号線にセットする(図11のd)。   The slave 201 also determines that it is a signal for notifying execution of the reception operation of the master 101 by detecting the low level of the SS signal line, and performs communication (second transmission operation) as the transmission side as follows. Start. First, when the rising edge of the SCK signal line is detected (B in FIG. 11), the level (level A in FIG. 11) input to the MOSI signal line is set to the first LSB side of the first byte in the received data storage unit 205. When the falling edge of the SCK signal line is detected (C in FIG. 11), the LSB that constitutes the first byte value 01H stored in the transmission data storage unit 204 is stored as the received data in the bit storage area. The value of the second bit on the side is set as the transmission data on the MISO signal line (d in FIG. 11).

次に、SCK信号線の立ち上がりエッジを検知すると(図11のE)、MOSI信号線に入力されるレベル(図11のDのレベル)を受信データ記憶部205における第1バイトのLSB側の第2ビット用の記憶領域に受信したデータとして記憶する。これらの動作により、マスター101から送信される第1バイトのデータのうちの第2ビットまでのデータ(図11のAとDのデータ)を受信し、スレーブ201から送信する第1バイトのデータのうちの第2ビットまでのデータ(図11のbとdのデータ)を送信する。第3ビットから第8ビットも同様にして繰返し、1バイト目の通信を行なう。   Next, when the rising edge of the SCK signal line is detected (E in FIG. 11), the level (D level in FIG. 11) input to the MOSI signal line is set to the first byte on the LSB side of the first byte in the received data storage unit 205. The received data is stored in the 2-bit storage area. Through these operations, data up to the second bit (data A and D in FIG. 11) of the first byte data transmitted from the master 101 is received, and the first byte data transmitted from the slave 201 is received. Data up to the second bit (data b and d in FIG. 11) is transmitted. The 3rd to 8th bits are repeated in the same manner and the first byte is communicated.

図11の第1バイトの通信が終了したとき、マスター101が受信して、受信データ記憶部105における第1バイト用の記憶領域に記憶されたデータの値は01Hであり、これは1バイト目の通信で、スレーブ201から送信したコマンドの値である。また、スレーブ201が受信して、受信データ記憶部205における第1バイト用の記憶領域に記憶されたデータの値は81Hであり、これは1バイト目の通信でマスター101から送信したコマンドの値である。この1バイト目の通信が行われた時点で、スレーブ201は、マスター101から1バイト目に受信したデータである81Hが、受信側であることを示す所定値であるNULLと異なることにより、マスター101が送信側として1バイト目にコマンドを送信してきたと判断する。そして、スレーブ201は、送信データ記憶部204に格納された送信データを送信保留データ記憶部208へコピーした後、受信側の動作(第1受信動作)に切り換えて通信を継続する。   When communication of the first byte in FIG. 11 is completed, the value of the data received by the master 101 and stored in the storage area for the first byte in the received data storage unit 105 is 01H, which is the first byte. Is the value of the command transmitted from the slave 201 in the communication. The value of the data received by the slave 201 and stored in the storage area for the first byte in the received data storage unit 205 is 81H, which is the value of the command transmitted from the master 101 in the first byte communication. It is. At the time when the communication of the first byte is performed, the slave 201 determines that the data received in the first byte from the master 101 is different from NULL, which is a predetermined value indicating that it is the receiving side. It is determined that 101 has transmitted a command at the first byte as the transmission side. Then, after copying the transmission data stored in the transmission data storage unit 204 to the transmission hold data storage unit 208, the slave 201 switches to the operation on the reception side (first reception operation) and continues communication.

スレーブ201の2バイト目の送信データは、1バイト目でマスター101から受信した、受信データ記憶部205に記憶されている第1バイトの値81Hとなる。これを送信データ記憶部204における第2バイト用の記憶領域に記憶する。送信データ記憶部204における第2バイト用記憶領域に記憶されている値81Hを構成するLSB側の第1ビットの値(所定のチェック用データを構成するデータ)を送信用のデータとしてMISO信号線にセットした後(図11のh)、RDYパルスを出力することにより、2バイト目の通信準備完了をマスター101へ通知する(図11のe)。その後、SCK信号線の立ち上がりエッジを検知するまで待ち状態となる。   The transmission data of the second byte of the slave 201 becomes the value 81H of the first byte stored in the reception data storage unit 205 received from the master 101 at the first byte. This is stored in the storage area for the second byte in the transmission data storage unit 204. The MISO signal line using the LSB side first bit value (data constituting predetermined check data) constituting the value 81H stored in the second byte storage area in the transmission data storage unit 204 as transmission data (H in FIG. 11), the RDY pulse is output to notify the master 101 of the completion of communication preparation for the second byte (e in FIG. 11). Thereafter, the process waits until the rising edge of the SCK signal line is detected.

マスター101は、スレーブ201から送信された1バイト目の値にかかわらず、そのまま送信動作を継続する。マスター101からスレーブ201への送信データの2バイト目は送信データ記憶部104に記憶されている第2バイトの値00H、3バイト目は送信データ記憶部104に記憶されている第3バイトの値81Hである。   Regardless of the value of the first byte transmitted from the slave 201, the master 101 continues the transmission operation as it is. The second byte of the transmission data from the master 101 to the slave 201 is the second byte value 00H stored in the transmission data storage unit 104, and the third byte is the third byte value stored in the transmission data storage unit 104. 81H.

スレーブ201の3バイト目の送信データは、2バイト目でマスター101から受信した、受信データ記憶部205に記憶されている第2バイトの値00Hとなる。これを送信データ記憶部204における第3バイト用の記憶領域に記憶する。   The transmission data of the third byte of the slave 201 becomes the value 00H of the second byte stored in the reception data storage unit 205 received from the master 101 at the second byte. This is stored in the third byte storage area in the transmission data storage unit 204.

3バイトの通信が終了すると、スレーブ201は、RDYパルスを出力することにより、通信終了および通信禁止をマスター101へ通知する(図11のf)。
マスター101は3バイトの通信後に、RDY信号線の立ち下りエッジを検知すると(図11のf)、SS信号線をHighレベルにすることにより、通信終了および通信禁止をスレーブ201に通知する(図11のg)。
When the 3-byte communication is completed, the slave 201 notifies the master 101 of the communication end and the communication inhibition by outputting an RDY pulse (f in FIG. 11).
When the master 101 detects a falling edge of the RDY signal line after 3 bytes of communication (f in FIG. 11), the master 101 notifies the slave 201 of communication end and communication prohibition by setting the SS signal line to the high level (FIG. 11). 11 g).

図12(b)は、図11の通信で、マスター101からMOSI信号線で送信された送信データと、スレーブ201からMISO信号線で送信された送信データの内容となる。MOSIにおいては、第1バイトの値は81H、第2バイトの値は00H、第3バイトの値は81H、であり、MISOにおいては、第1バイトの値は01H、第2バイトの値は81H、第3バイトの値は00H、である。送信された図12(b)のデータにおいて、
スレーブ201からMISO信号線で送信したデータは、通信開始時の図12(a)のデータと比較して、第2バイトのデータが00Hから81Hに替わり、第3バイトのデータが01Hから00Hに替わっている。
FIG. 12B shows the contents of transmission data transmitted from the master 101 via the MOSI signal line and transmission data transmitted from the slave 201 via the MISO signal line in the communication of FIG. In MOSI, the value of the first byte is 81H, the value of the second byte is 00H, the value of the third byte is 81H, and in MISO, the value of the first byte is 01H and the value of the second byte is 81H. The value of the third byte is 00H. In the transmitted data of FIG. 12 (b),
The data transmitted from the slave 201 via the MISO signal line has the second byte data changed from 00H to 81H and the third byte data changed from 01H to 00H as compared with the data in FIG. It has changed.

図13は、図11の通信でスレーブ201が送信を保留した送信データを、マスター101へ送信する通信のタイミングを示した図である。
スレーブ201は、図11の通信が終了し、SS信号線がHighレベルになったことを検出すると(図11のg)、送信保留データ記憶部208に格納した送信データをマスター101へ送信する作業を開始する。具体的には、送信保留データ記憶部208に格納した図12(a)の送信データを送信データ記憶部204の先頭の第1バイトの記憶領域から、01H、00H、01Hの順に格納する。そして、送信データ記憶部204に記憶されている第1バイトの値01Hを構成するLSB側の第1ビットの値1を送信用のデータとしてMISO信号線にセットした後(図13のb)、RDYパルスを出力することにより、通信開始および1バイト目の通信準備完了をマスター101へ通知する(図13のc)。
マスター101は、RDY信号線の立ち下りエッジを検知すると(図13のc)、受信側として通信を開始する。送信データ記憶部104の第1バイト用の記憶領域に、受信側であるとこを示す所定値、NULLを記憶する。そして、マスター101は、SS信号線をLowレベルにしてスレーブ201に対して通信許可を通知する(図13のa)。その後、送信データ記憶部104に記憶されている第1バイトの値NULLを構成するLSB側の第1ビットの値を送信用のデータとしてMOSI信号線にセットしてから(図13のA)、SCK信号線をHighレベルにする(図13のB)。そして、MISO信号線に入力されているレベル(図13のbのレベル)を受信データ記憶部105における第1バイトのLSB側の第1ビット用の記憶領域に受信したデータとして記憶した後、SCK信号線をLowレベルにする(図13のC)。これらの動作により、マスター101から送信する第1バイトのデータのうちの第1ビットのデータを送信し(図13のA)、スレーブ201から送信される第1バイトのデータのうちの第1ビットのデータを受信する(図13のb)。
次に、送信データ記憶部104に記憶されている第1バイトの値NULLを構成するLSB側の第2ビットの値0を送信用のデータとしてMOSI信号線にセットしてから(図13のD)、SCK信号線をHighレベルにする(図13のE)。そして、MISO信号線に入力されているレベル(図13のdのレベル)を受信データ記憶部105における第1バイトのLSB側の第2ビット用の記憶領域に受信したデータとして記憶した後、SCK信号線をLowレベルにする(図7のF)。これらの動作により、マスター101から送信する第1バイトのデータのうちの第2ビットのデータを送信し(図13のD)、スレーブ201から送信される第1バイトのデータうちの第2ビットのデータを受信する(図13のd)。第3ビットから第8ビットも同様にして繰返して1バイト通信を終了する。2バイト目の送信データは、1バイト目で受信した、受信データ記憶部105に記憶されている第1バイトの値01Hである。これを送信データ記憶部104における第2バイト用の記憶領域に記憶する。その後、マスター101は、2バイト目のRDYの立ち下りエッジ(図13のe)の検知を待つ状態となる。
FIG. 13 is a diagram illustrating the timing of communication for transmitting to the master 101 transmission data that the slave 201 has suspended transmission in the communication of FIG.
When the slave 201 detects that the communication in FIG. 11 is completed and the SS signal line is at the high level (g in FIG. 11), the slave 201 transmits the transmission data stored in the transmission pending data storage unit 208 to the master 101. To start. Specifically, the transmission data of FIG. 12A stored in the transmission pending data storage unit 208 is stored in the order of 01H, 00H, 01H from the first byte storage area of the transmission data storage unit 204. Then, after setting the value 1 of the first bit on the LSB side constituting the value 01H of the first byte stored in the transmission data storage unit 204 to the MISO signal line as data for transmission (b in FIG. 13), By outputting the RDY pulse, the master 101 is notified of the start of communication and the completion of communication preparation for the first byte (c in FIG. 13).
When the master 101 detects the falling edge of the RDY signal line (c in FIG. 13), it starts communication as the receiving side. A predetermined value indicating NULL is stored in the storage area for the first byte of the transmission data storage unit 104 as NULL. Then, the master 101 sets the SS signal line to the low level and notifies the slave 201 of communication permission (a in FIG. 13). Then, after setting the value of the first bit on the LSB side constituting the value NULL of the first byte stored in the transmission data storage unit 104 to the MOSI signal line as data for transmission (A in FIG. 13), The SCK signal line is set to the high level (B in FIG. 13). Then, after storing the level (level b in FIG. 13) input to the MISO signal line as the received data in the first bit storage area on the LSB side of the first byte in the received data storage unit 105, SCK The signal line is set to the low level (C in FIG. 13). With these operations, the first bit data of the first byte data transmitted from the master 101 is transmitted (A in FIG. 13), and the first bit of the first byte data transmitted from the slave 201 is transmitted. Is received (b in FIG. 13).
Next, the value 0 of the second bit on the LSB side constituting the value NULL of the first byte stored in the transmission data storage unit 104 is set to the MOSI signal line as data for transmission (D in FIG. 13). ), The SCK signal line is set to the high level (E in FIG. 13). Then, after storing the level (level d in FIG. 13) input to the MISO signal line as received data in the second bit storage area on the LSB side of the first byte in the received data storage unit 105, SCK The signal line is set to the low level (F in FIG. 7). By these operations, the second bit data of the first byte data transmitted from the master 101 is transmitted (D in FIG. 13), and the second bit data of the first byte data transmitted from the slave 201 is transmitted. Data is received (d in FIG. 13). Similarly, the third to eighth bits are repeated to complete one-byte communication. The transmission data of the second byte is the value 01H of the first byte received in the first byte and stored in the reception data storage unit 105. This is stored in the storage area for the second byte in the transmission data storage unit 104. Thereafter, the master 101 waits for detection of the falling edge (R in FIG. 13) of the second byte RDY.

スレーブ201は、SS信号線のLowレベルを検知することにより(図13のa)、通信が開始されたと判断する。まず、SCK信号線の立ち上がりエッジを検知すると(図13のB)、MOSI信号線に入力されているレベル(図13のAのレベル)を受信データ記憶部205における第1バイトのLSB側の第1ビット用の記憶領域に受信したデータとして記憶し、SCK信号線の立ち下りエッジを検知すると(図13のC)、送信データ記憶部204に記憶されている第1バイトの値01Hを構成するLSB側の第2ビットの値0を送信用のデータとしてMISO信号線にセットする(図13のd)。   The slave 201 determines that communication has started by detecting the low level of the SS signal line (a in FIG. 13). First, when the rising edge of the SCK signal line is detected (B in FIG. 13), the level (level A in FIG. 13) input to the MOSI signal line is set to the first byte on the LSB side of the first byte in the received data storage unit 205. When the falling edge of the SCK signal line is detected (C in FIG. 13), the first byte value 01H stored in the transmission data storage unit 204 is configured. The value 0 of the second bit on the LSB side is set to the MISO signal line as transmission data (d in FIG. 13).

次に、SCK信号線の立ち上がりエッジを検知すると(図13のE)、MOSI信号線に入力されているレベル(図13のDのレベル)を受信データ記憶部205における第1
バイトのLSB側の第2ビット用の記憶領域に受信したデータとして記憶する。これらの動作により、マスター101から送信される第1バイトのデータのうちの第2ビットまでのデータ(図13のAとDのデータ)を受信し、スレーブ201から送信する第1バイトのデータのうちの第2ビットまでのデータ(図13のbとdのデータ)を送信する。第3ビットから第8ビットも同様にして繰返して1バイト通信を行なう。
Next, when the rising edge of the SCK signal line is detected (E in FIG. 13), the level (D level in FIG. 13) input to the MOSI signal line is set to the first in the received data storage unit 205.
The received data is stored in the second bit storage area on the LSB side of the byte. By these operations, data up to the second bit (data A and D in FIG. 13) of the first byte data transmitted from the master 101 is received, and the first byte data transmitted from the slave 201 is received. The data up to the second bit (b and d data in FIG. 13) is transmitted. The 1st byte communication is repeated in the same manner for the 3rd to 8th bits.

スレーブ201からマスター101への送信データの2バイト目は送信データ記憶部204に記憶されている第2バイトの値00Hである。00Hを構成するLSB側の第1ビットの値0を送信用のデータとしてMISO信号線にセットした後、RDYパルスを出力することにより(図13のe)、2バイト目の通信準備完了をマスター101へ通知する。その後、SCK信号線の立ち上がりエッジを検知するまで待ち状態となる。   The second byte of transmission data from the slave 201 to the master 101 is the value 00H of the second byte stored in the transmission data storage unit 204. The first bit value 0 on the LSB side constituting 00H is set to the MISO signal line as data for transmission, and then the RDY pulse is output (e in FIG. 13) to master the completion of communication preparation for the second byte. 101 is notified. Thereafter, the process waits until the rising edge of the SCK signal line is detected.

スレーブ201からマスター101への送信データの3バイト目は送信データ記憶部204に記憶されている第3バイトの値01Hである。
マスター101からスレーブ201への送信データの3バイト目は、2バイト目でスレーブ201から受信し、送信データ記憶部104の第3バイト用の記憶領域に記憶した値00Hである。
The third byte of transmission data from the slave 201 to the master 101 is the third byte value 01H stored in the transmission data storage unit 204.
The third byte of transmission data from the master 101 to the slave 201 is the value 00H received from the slave 201 at the second byte and stored in the third byte storage area of the transmission data storage unit 104.

3バイトの通信が終了すると、スレーブ201は、RDYパルスを出力することにより、通信終了および通信禁止をマスター101へ通知する(図13のf)。
マスター101は3バイトの通信後のRDYパルスの立ち下りエッジを検知すると(図13のf)、SS信号線をHighレベルにすることにより、通信終了および通信禁止をスレーブ201に通知する(図13のg)。
図14は、図13の通信で、マスター101からMOSI信号線で送信される送信データと、スレーブ201からMISO信号線で送信される送信データの内容となる。MOSIにおいては、第1バイトの値はNULL、第2バイトの値は01H、第3バイトの値は00H、であり、MISOにおいては、第1バイトの値は01H、第2バイトの値は00H、第3バイトの値は01H、である。
When the 3-byte communication is completed, the slave 201 notifies the master 101 of the communication end and the communication inhibition by outputting an RDY pulse (f in FIG. 13).
When the master 101 detects the falling edge of the RDY pulse after communication of 3 bytes (f in FIG. 13), the master 101 notifies the slave 201 of communication end and communication prohibition by setting the SS signal line to the high level (FIG. 13). G).
FIG. 14 shows the contents of transmission data transmitted from the master 101 through the MOSI signal line and transmission data transmitted from the slave 201 through the MISO signal line in the communication of FIG. In MOSI, the value of the first byte is NULL, the value of the second byte is 01H, the value of the third byte is 00H, and in MISO, the value of the first byte is 01H and the value of the second byte is 00H. The value of the third byte is 01H.

以上のように、スレーブ201は、送信開始後、マスター101から1バイト目に受信したデータが、受信側であることを示す所定値である場合には、送信動作を継続し、受信側であることを示す所定値でない場合には、送信動作を中止するとともに、マスター101からの送信動作に基づくデータとして受信する受信動作に切り替えるので、マスター101とスレーブ201の両方から同時に通信が開始された場合においても、通信に失敗することなく、安定した通信が可能な同期式シリアル通信システムを実現可能である。   As described above, when the data received in the first byte from the master 101 after transmission starts is a predetermined value indicating that it is the receiving side, the slave 201 continues the transmission operation and is the receiving side. If it is not a predetermined value indicating that the transmission operation is stopped and the reception operation is received as data based on the transmission operation from the master 101, the communication is started simultaneously from both the master 101 and the slave 201. However, a synchronous serial communication system capable of stable communication without failing in communication can be realized.

次に、本実施例における通信エラーの検出方法について、フローチャートを用いて説明する。
図15は、送信側として動作する場合のマスター101のフローチャートである。ステップS1は、送信データを送信データ記憶部104に格納する工程である。ステップS2は、タイマー109をクリアして時間カウントを開始する工程である。ステップS3は、SS信号線をLowレベルにすることにより、通信開始および通信許可をスレーブ201に通知する工程である。ステップS4は、タイマー109の時間カウントが通信タイムアウト時間を経過したかどうかの判定する工程である。通信タイムアウト時間は、スレーブ201がRDYパルスを出力したときのRDY信号線の立下りから、スレーブ201との間で1バイトの通信を経て、スレーブ201が再びRDYパルスを出力するまでの時間(図7のT1)よりも長い時間とする。
Next, a communication error detection method in the present embodiment will be described using a flowchart.
FIG. 15 is a flowchart of the master 101 when operating as a transmission side. Step S <b> 1 is a step of storing transmission data in the transmission data storage unit 104. Step S2 is a step of clearing the timer 109 and starting time counting. Step S3 is a step of notifying the slave 201 of communication start and communication permission by setting the SS signal line to a low level. Step S4 is a step of determining whether or not the time count of the timer 109 has passed the communication timeout time. The communication timeout time is the time from when the RDY signal line falls when the slave 201 outputs the RDY pulse to when the slave 201 outputs the RDY pulse again after one-byte communication with the slave 201 (see FIG. 7 is longer than T1).

ステップS4で通信タイムアウト時間か経過した場合は、スレーブ201からの応答が無いので通信エラーが発生したと判断し、ステップS60へ移行する。ステップS4で通
信タイムアウト時間か経過していない場合は、ステップS5へ移行する。ステップS5は、RDY信号線レベルの立下がりを判定する工程である。立下りでない場合はステップS4へ移行し、立下りである場合はステップS50へ移行する。ステップS50は、タイマー109の時間カウントをクリアする工程である。ステップS6は残りの送信データの有無を判定する工程である。全ての送信データを送信済みで、残り0バイトの場合は、ステップS9へ移行する。未送信の送信データが残っている場合は、ステップS7へ移行する。
If the communication timeout time elapses in step S4, it is determined that a communication error has occurred because there is no response from the slave 201, and the process proceeds to step S60. If the communication timeout time has not elapsed in step S4, the process proceeds to step S5. Step S5 is a step of determining the fall of the RDY signal line level. If it is not falling, the process proceeds to step S4. If it is falling, the process proceeds to step S50. Step S50 is a step of clearing the time count of the timer 109. Step S6 is a step of determining whether or not there is remaining transmission data. If all the transmission data has been transmitted and there are 0 bytes remaining, the process proceeds to step S9. If untransmitted transmission data remains, the process proceeds to step S7.

ステップS7は、SCK信号線クロックを出力し、1バイトの通信を行なう工程である。ステップS8は、2バイト目以降の場合に、前回に送信した1バイトの値と、今回にスレーブ201から受信した1バイトの値との照合結果を判定する工程である。2値が異なる場合はNGと判定し、通信エラーが発生したと判断し、ステップS60へ移行する。2値が等しい場合はOKと判定し、正常であると判断し、ステップS4へ移行する。   Step S7 is a step of outputting the SCK signal line clock and performing 1-byte communication. Step S8 is a step of determining a collation result between the 1-byte value transmitted last time and the 1-byte value received from the slave 201 this time in the case of the second and subsequent bytes. If the two values are different, it is determined as NG, it is determined that a communication error has occurred, and the process proceeds to step S60. If the two values are equal, it is determined to be OK, it is determined to be normal, and the process proceeds to step S4.

ステップS60は、通信終了後に送信データを再送するように再送設定する工程である。再送設定がされている場合、通信終了後、スレーブ201の通信タイムアウトが発生するのに十分な時間が経過後、送信データの再送を開始する。ステップS9は、SS信号線をHighレベルにすることにより、通信終了および通信禁止をスレーブ201に通知する工程である。ステップS10は、タイマー109をクリアして時間カウントを終了する工程である。   Step S60 is a step of performing retransmission setting so that transmission data is retransmitted after communication is completed. If retransmission is set, retransmission of transmission data is started after a sufficient time has elapsed for the communication timeout of the slave 201 to occur after the end of communication. Step S9 is a step of notifying the slave 201 of communication end and communication prohibition by setting the SS signal line to the high level. Step S10 is a step of clearing the timer 109 and ending the time count.

このように、マスター101は、スレーブ201から送信される1バイト目のデータの内容にかかわらず、送信動作を続ける。   In this manner, the master 101 continues the transmission operation regardless of the content of the first byte data transmitted from the slave 201.

図18は、受信側として動作する場合の、スレーブ201のフローチャートである。
スレーブ201は、SS信号線のLowレベルを検知してから、ステップS44の工程において、タイマー209をクリアして時間カウントを開始する。ステップS35は、RDYパルスを出力することにより、通信開始および1バイトの通信準備完了をマスター101へ通知する工程である。ステップ36は、タイマー209の時間カウントが通信タイムアウト時間を経過したかどうかの判定する工程である。通信タイムアウト時間は、1バイトの通信を経て、RDYパルスを出力後、マスター101からSCK信号線のクロックを入力するまでの時間(図7のT2)よりも長い時間とする。
通信タイムアウト時間か経過した場合は、マスター101からの応答が無いので通信エラーが発生したと判断し、ステップS41へ移行する。マスター101のステップS8で、照合結果がNGの場合、マスター101が通信を終了するので、マスター101からの応答が無くなり、通信タイムアウト時間か経過する。通信タイムアウト時間か経過していない場合は、ステップS37へ移行する。
ステップS37は、SCK信号線のクロック入力が発生しているかを判定する工程である。SCK信号線のクロック入力が発生している場合には、ステップS53へ移行する。マスター101がRDY信号線レベルの立下がりを検出してSCK信号線クロックを出力するまでの、SCK信号線のクロック入力が発生していない場合には、ステップS36へ移行する。ステップS53は、タイマー209の時間カウントをクリアする工程である。ステップS38は、SCK信号線のクロックに同期して、1バイトの通信を行なう工程である。
ステップS39は、残りの受信データの有無を判定する工程である。全ての受信データを受信済みの場合は、ステップS40へ移行する。未受信の受信データが残っている場合は、ステップS35へ移行する。ステップS40は、受信データ記憶部205に格納された受信データのうち、コマンドからデータまでをXORしたチェックサムの値と、最終受信バイトの値との照合結果を判定する工程である。2値が異なる場合はNGと判定し、受信データが不正な値であると判断し、ステップS41へ移行する。2値が等しい場合はOKと
判定し、正常であると判断し、ステップS42へ移行する。ステップS41は、受信データ記憶部205に格納された受信データをクリアする、エラー処理の工程である。ステップ42は、RDYパルスを出力することにより、通信終了および通信禁止をマスター101へ通知する工程である。ステップS43は、タイマー209をクリアして時間カウントを終了する工程である。
FIG. 18 is a flowchart of the slave 201 when operating as the receiving side.
After detecting the low level of the SS signal line, the slave 201 clears the timer 209 and starts counting time in the step S44. Step S35 is a step of notifying the master 101 of communication start and 1-byte communication preparation completion by outputting an RDY pulse. Step 36 is a step of determining whether or not the time count of the timer 209 has passed the communication timeout time. The communication timeout time is set to be longer than the time (T2 in FIG. 7) from the output of the RDY pulse through the 1-byte communication to the input of the SCK signal line clock from the master 101.
If the communication timeout time has elapsed, it is determined that a communication error has occurred because there is no response from the master 101, and the process proceeds to step S41. If the collation result is NG in step S8 of the master 101, the master 101 terminates the communication, so there is no response from the master 101 and the communication timeout time elapses. If the communication timeout time has not elapsed, the process proceeds to step S37.
Step S37 is a step of determining whether a clock input of the SCK signal line is generated. When the clock input of the SCK signal line is generated, the process proceeds to step S53. If the clock input of the SCK signal line is not generated until the master 101 detects the fall of the RDY signal line level and outputs the SCK signal line clock, the process proceeds to step S36. Step S53 is a step of clearing the time count of the timer 209. Step S38 is a step of performing 1-byte communication in synchronization with the clock of the SCK signal line.
Step S39 is a step of determining the presence or absence of the remaining received data. If all the received data has been received, the process proceeds to step S40. If unreceived received data remains, the process proceeds to step S35. Step S40 is a step of determining a collation result between the checksum value obtained by XORing the command to the data and the value of the last received byte among the received data stored in the received data storage unit 205. If the two values are different, it is determined as NG, the received data is determined to be an illegal value, and the process proceeds to step S41. If the two values are equal, it is determined to be OK, it is determined to be normal, and the process proceeds to step S42. Step S41 is an error processing step of clearing the reception data stored in the reception data storage unit 205. Step 42 is a step of notifying the master 101 of communication end and communication prohibition by outputting an RDY pulse. Step S43 is a step of clearing the timer 209 and ending the time count.

図17は、送信側として動作する場合のスレーブ201のフローチャートである。ステップS21は、送信データを送信データ記憶部104に格納する工程である。ステップS22は、タイマー209をクリアして時間カウントを開始する工程である。ステップS23は、RDYパルスを出力することにより、通信開始および1バイトの通信準備完了をマスター101へ通知する工程である。ステップ24は、タイマー209の時間カウントが通信タイムアウト時間を経過したかどうかの判定する工程である。通信タイムアウト時間は、1バイトの通信を経て、RDYパルスを出力後、マスター101からSCK信号線のクロックを入力するまでの時間(図9のT2)よりも長い時間とする。通信タイムアウト時間か経過した場合は、マスター101からの応答が無いので通信エラーが発生したと判断し、ステップS61へ移行する。通信タイムアウト時間か経過していない場合は、ステップS25へ移行する。   FIG. 17 is a flowchart of the slave 201 when operating as the transmission side. Step S <b> 21 is a step of storing transmission data in the transmission data storage unit 104. Step S22 is a step of clearing the timer 209 and starting time counting. Step S23 is a step of notifying the master 101 of communication start and 1-byte communication preparation completion by outputting an RDY pulse. Step 24 is a step of determining whether or not the time count of the timer 209 has passed the communication timeout time. The communication time-out time is longer than the time (T2 in FIG. 9) from when the RDY pulse is output through the 1-byte communication to when the clock of the SCK signal line is input from the master 101. If the communication timeout period has elapsed, it is determined that a communication error has occurred because there is no response from the master 101, and the process proceeds to step S61. If the communication timeout time has not elapsed, the process proceeds to step S25.

ステップS25は、SCK信号線のクロック入力が発生しているかを判定する工程である。SCK信号線のクロック入力が発生している場合には、ステップS52へ移行する。マスター101がRDY信号線レベルの立下がりを検出してSCK信号線クロックを出力するまでの、SCK信号線のクロック入力が発生していない場合には、ステップS24へ移行する。ステップS52は、タイマー209の時間カウントをクリアする工程である。ステップS26は、SCK信号線のクロックに同期して、1バイトの通信を行なう工程である。ステップS27は、残りの送信データの有無を判定する工程である。全ての送信データを送信済みの場合は、ステップS28へ移行する。未送信の送信データが残っている場合は、ステップS29へ移行する。   Step S25 is a step of determining whether a clock input of the SCK signal line is generated. When the clock input of the SCK signal line is generated, the process proceeds to step S52. If the clock input of the SCK signal line is not generated until the master 101 detects the fall of the RDY signal line level and outputs the SCK signal line clock, the process proceeds to step S24. Step S52 is a step of clearing the time count of the timer 209. Step S26 is a step of performing communication of 1 byte in synchronization with the clock of the SCK signal line. Step S27 is a step of determining whether or not there is remaining transmission data. If all the transmission data has been transmitted, the process proceeds to step S28. If untransmitted transmission data remains, the process proceeds to step S29.

ステップS28は、RDYパルスを出力することにより、通信終了および通信禁止をマスター101へ通知する工程である。ステップS29は、1バイト目の通信である場合はステップS31へ移行し、2バイト目以降の通信である場合はステップS30へ移行する、判定工程である。ステップS31は、1バイト目の通信でマスター101から受信した値が、受信側であることを示す所定値であるNULLであるかを判定する工程である。NULLである場合はステップS30へ移行し、NULLで無い場合はステップS32へ移行する。ステップS32は、受信側に切り換えるために、送信データ記憶部204に格納された送信データを送信保留データ記憶部208へコピーする工程である。ステップS32から、受信側として通信を継続するために、図18に示す、受信側として動作する場合のスレーブ201の、フローチャートのS35の工程へ移行する(図17のA)。   Step S28 is a step of notifying the master 101 of communication end and communication prohibition by outputting an RDY pulse. Step S29 is a determination process in which the process proceeds to step S31 if the communication is the first byte, and the process proceeds to step S30 if the communication is the second byte or later. Step S31 is a step of determining whether the value received from the master 101 in the first byte communication is NULL, which is a predetermined value indicating the receiving side. If it is NULL, the process proceeds to step S30, and if it is not NULL, the process proceeds to step S32. Step S32 is a step of copying the transmission data stored in the transmission data storage unit 204 to the transmission suspension data storage unit 208 in order to switch to the reception side. From step S32, in order to continue communication as the receiving side, the process proceeds to step S35 in the flowchart of the slave 201 in the case of operating as the receiving side shown in FIG. 18 (A in FIG. 17).

図17のステップ32から移行した(図18のA)ステップS35の工程では、RDYパルスを出力することにより、通信開始および1バイトの通信準備完了をマスター101へ通知する。ステップS35から後は、図18のフローチャートに処理を移し、受信側としての動作を継続する。ステップS30は、2バイト目以降の場合に、前回に送信した1バイトの値と、今回にマスター101から受信した1バイトの値との照合結果を判定する工程である。2値が異なる場合はNGと判定し、通信エラーが発生したと判断し、ステップS61へ移行する。2値が等しい場合はOKと判定し、正常であると判断し、ステップS23へ移行する。ステップS61は、通信終了後に送信データを再送するように再送設定する工程である。再送設定がされている場合、通信終了後、マスター101の通信タイムアウトが発生するのに十分な時間が経過後、送信データの再送を開始する。ステップS34は、タイマー209をクリアして時間カウントを終了する工程である。   In the process of step S35 shifted from step 32 in FIG. 17 (A in FIG. 18), the master 101 is notified of the start of communication and the completion of 1-byte communication preparation by outputting an RDY pulse. After step S35, the process moves to the flowchart of FIG. 18, and the operation as the reception side is continued. Step S30 is a step of determining a collation result between the 1-byte value transmitted last time and the 1-byte value received from the master 101 this time in the case of the second and subsequent bytes. If the two values are different, it is determined as NG, it is determined that a communication error has occurred, and the process proceeds to step S61. If the two values are equal, it is determined to be OK, it is determined to be normal, and the process proceeds to step S23. Step S61 is a step of performing retransmission setting so that transmission data is retransmitted after communication is completed. When retransmission is set, retransmission of transmission data is started after a sufficient time has elapsed for the communication timeout of the master 101 to occur after communication is completed. Step S34 is a step of clearing the timer 209 and ending the time count.

このように、スレーブ201は、送信側として動作を開始しても、ステップS31で、マスター101から送信される1バイト目のデータがNULLでないと判断した場合には、図18のステップS35から受信側として動作を切替えるので、送信側として動作を開始したマスター101は、そのまま送信動作を継続することができ、通信のエラーも発生しない。   As described above, even when the slave 201 starts operating as the transmission side, if it is determined in step S31 that the first byte data transmitted from the master 101 is not NULL, the slave 201 receives the data from step S35 in FIG. Since the operation is switched as the transmission side, the master 101 that has started the operation as the transmission side can continue the transmission operation as it is, and no communication error occurs.

図16は、受信側として動作する場合のマスター101のフローチャートである。マスター101は、スレーブ201が送信側としてRDYパルスを出力してから、RDY信号線の立ち下りエッジを検知すると、ステップS11の工程において、タイマー109をクリアして時間カウントを開始する。ステップS12は、SS信号線をLowレベルにすることにより、通信開始および通信許可をスレーブ201に通知する工程である。ステップS13は、SCK信号線にクロックを出力し、1バイトの通信を行なう工程である。ステップS14は、タイマー109の時間カウントが通信タイムアウト時間を経過したかどうかの判定する工程である。   FIG. 16 is a flowchart of the master 101 when operating as the receiving side. When the master 101 detects the falling edge of the RDY signal line after the slave 201 outputs the RDY pulse as the transmission side, the master 101 clears the timer 109 and starts time counting in the step S11. Step S12 is a step of notifying the slave 201 of communication start and communication permission by setting the SS signal line to a low level. Step S13 is a step of outputting a clock to the SCK signal line and performing 1-byte communication. Step S14 is a step of determining whether or not the time count of the timer 109 has passed the communication timeout time.

通信タイムアウト時間は、スレーブ201がRDYパルスを出力したときのRDY信号線の立下りから1バイトの通信を経て、スレーブ201が再びRDYパルスを出力するまでの時間(図9のT1)よりも長い時間とする。通信タイムアウト時間か経過した場合は、スレーブ201からの応答が無いので通信エラーが発生したと判断し、ステップS18へ移行する。図17におけるスレーブ201のステップS30で、照合結果がNGの場合、スレーブ201が通信を終了するので、スレーブ201からの応答が無くなり、通信タイムアウト時間か経過する。通信タイムアウト時間か経過していない場合は、ステップS15へ移行する。   The communication time-out time is longer than the time (T1 in FIG. 9) from when the slave 201 outputs the RDY pulse to when the slave 201 outputs the RDY pulse again after one-byte communication from the falling edge of the RDY signal line. Time. If the communication timeout time has elapsed, it is determined that a communication error has occurred because there is no response from the slave 201, and the process proceeds to step S18. In step S30 of the slave 201 in FIG. 17, if the collation result is NG, the slave 201 ends the communication, so there is no response from the slave 201, and the communication timeout time elapses. If the communication timeout time has not elapsed, the process proceeds to step S15.

ステップS15は、RDY信号線レベルの立下がりを判定する工程である。立下りでない場合はステップS14へ移行し、立下りである場合はステップS51へ移行する。ステップS51は、タイマー109の時間カウントをクリアする工程である。ステップS16は残りの受信データの有無を判定する工程である。全ての受信データを受信済みで、残り0バイトの場合は、ステップS17へ移行する。未受信の受信データが残っている場合は、ステップS13へ移行する。   Step S15 is a step of determining the fall of the RDY signal line level. If it is not falling, the process proceeds to step S14, and if it is falling, the process proceeds to step S51. Step S51 is a step of clearing the time count of the timer 109. Step S16 is a step of determining the presence or absence of the remaining received data. If all the received data has been received and the remaining 0 bytes, the process proceeds to step S17. If unreceived received data remains, the process proceeds to step S13.

ステップS17は、受信データ記憶部105に格納された受信データのうち、コマンドからデータまでをXORしたチェックサムの値と、最終受信バイトの値との照合結果を判定する工程である。2値が異なる場合はNGと判定し、受信データが不正な値であると判断し、ステップS18へ移行する。2値が等しい場合はOKと判定し、正常であると判断し、ステップS19へ移行する。ステップS18は、受信データ記憶部105に格納された受信データをクリアする、エラー処理の工程である。ステップS19は、SS信号線をHighレベルにすることにより、通信終了および通信禁止をスレーブ201に通知する工程である。ステップS20は、タイマー109をクリアして時間カウントを終了する工程である。   Step S17 is a step of determining a collation result between the checksum value obtained by XORing the command to data among the received data stored in the received data storage unit 105 and the value of the last received byte. If the two values are different, it is determined as NG, the received data is determined to be an illegal value, and the process proceeds to step S18. If the two values are equal, it is determined as OK, it is determined as normal, and the process proceeds to step S19. Step S18 is an error processing step of clearing the reception data stored in the reception data storage unit 105. Step S19 is a step of notifying the slave 201 of communication end and communication prohibition by setting the SS signal line to the high level. Step S20 is a step of clearing the timer 109 and ending the time count.

マスター101の図15の送信処理におけるS60の再送処理、あるいは、マスター101の図16の受信処理におけるS18のエラー処理、を実行するが、マスター101の出力ポートとスレーブ201のリセット端子を接続し、通信エラー発生時にマスター101の前記出力ポートからリセットパルスを出力することにより、スレーブ201をリセットしてもよい。これにより、スレーブ201が、プログラムの暴走などの異常が発生したことに起因して通信エラーが発生している場合にも、スレーブ201を正常な状態に復帰させることが可能である。   The master 101 performs the retransmission process of S60 in the transmission process of FIG. 15 or the error process of S18 in the reception process of FIG. 16 of the master 101, but connects the output port of the master 101 and the reset terminal of the slave 201, The slave 201 may be reset by outputting a reset pulse from the output port of the master 101 when a communication error occurs. As a result, even when the slave 201 has a communication error due to an abnormality such as a program runaway, the slave 201 can be returned to a normal state.

以上のように、本実施例においては、送信側は、送信したデータが次の1バイト通信で受信した受信データと照合することで、通信が正常に行なわれているか判断し、受信側は、受信したデータのチェックサムと、送信側から受信したチェックサムとを照合することで、通信が正常に行なわれているか判断し、また、送信側または受信側の装置に異常が発生して、通信が途切れた場合にも、タイマーの時間カウントが通信タイムアウト時間を経過ことを検知して、通信エラーと判断するので、容易に通信エラーを検出でき、通信エラーによるプログラムの不正処理を未然に防ぐことが可能である。   As described above, in this embodiment, the transmitting side determines whether communication is normally performed by checking the transmitted data with the received data received in the next 1-byte communication. By comparing the checksum of the received data with the checksum received from the transmission side, it is determined whether the communication is performed normally. Even if the timer is interrupted, it is detected that the timer time count has exceeded the communication timeout time, and it is judged as a communication error, so it is possible to easily detect the communication error and prevent unauthorized program processing due to the communication error. Is possible.

本実施例では、RDY信号線を、1バイトデータの通信準備完了を通知する目的と、スレーブ201がマスター101に通信開始を通知する目的とに兼用しているが、RDY信号線とは別に、REQ信号線を追加してもよい。図19は、REQ信号線を追加した場合のブロック図である。図19のブロック図は、図2のブロック図に、REQ信号線を追加した点が異なるだけである。REQ信号線は、スレーブ201の出力端子216と、マスター101の入力端子116に接続される。REQ信号線は、スレーブ201がマスター101に通信開始を通知する信号(第2要求信号)を出力して受信動作を要求する機能を果たす第2信号線として用いられ、通常はHighレベルとする。RDY信号線は、1バイト毎のスレーブ側のデータの通信準備完了を通知するために用いられる。   In this embodiment, the RDY signal line is used both for the purpose of notifying the completion of communication preparation for 1-byte data and for the purpose of notifying the master 101 of the start of communication by the slave 201, but separately from the RDY signal line, A REQ signal line may be added. FIG. 19 is a block diagram when a REQ signal line is added. The block diagram of FIG. 19 is different from the block diagram of FIG. 2 only in that a REQ signal line is added. The REQ signal line is connected to the output terminal 216 of the slave 201 and the input terminal 116 of the master 101. The REQ signal line is used as a second signal line that performs a function of outputting a signal (second request signal) for notifying the master 101 of the start of communication to the master 101 and requesting a reception operation, and is normally at a high level. The RDY signal line is used for notifying completion of communication preparation of slave-side data for each byte.

図20は、REQ信号線を使用してスレーブ201から3バイトの送信を実行する場合のタイミングチャートである。スレーブ201において、マスター101へ通信する必要が発生した場合、送信データを送信データ記憶部204に格納し、通信(第2送信動作)を開始する。まず、スレーブ201は、第2要求信号としてREQ信号線をLowレベルにすることにより、通信開始および受信動作の要求をマスター101へ通知する(図20のb)。マスター101は、REQ信号線のLowレベルを検知すると(図20のb)、SS信号線をLowレベルにしてスレーブ201に対して受信動作開始および通信許可を通知する(図20のa)。これは、図7のaに相当し、以降は図7の実施例のように通信を行なう。ただし、マスター101は受信側として、スレーブ201は送信側として、通信を行なう。マスター101は、通信が終了し、SS信号線がHighレベルになったのを検知すると、REQ信号線をHighレベルにする。以上で、REQ信号線は、通常はHighレベルとしたが、通常がLowレベルで通信時がHighレベルであってもよい。   FIG. 20 is a timing chart in the case of executing transmission of 3 bytes from the slave 201 using the REQ signal line. When it is necessary for the slave 201 to communicate with the master 101, the transmission data is stored in the transmission data storage unit 204 and communication (second transmission operation) is started. First, the slave 201 notifies the master 101 of a request for communication start and reception operation by setting the REQ signal line to a low level as a second request signal (b in FIG. 20). When the master 101 detects the low level of the REQ signal line (b in FIG. 20), the master 101 sets the SS signal line to the low level and notifies the slave 201 of the reception operation start and communication permission (a in FIG. 20). This corresponds to a in FIG. 7, and thereafter, communication is performed as in the embodiment of FIG. 7. However, communication is performed with the master 101 as the receiving side and the slave 201 as the transmitting side. When the master 101 detects that the communication is completed and the SS signal line is at the high level, the master 101 sets the REQ signal line to the high level. As described above, the REQ signal line is normally set to the High level, but it may be set to the Low level for normal communication and to the High level for communication.

REQ信号線を追加した場合において、マスター101から通信を開始する場合は、図7の実施例の通信を行なう。すなわち、マスター101は、SS信号線をLowレベルにすることにより、通信開始および通信許可をスレーブ201に通知する(図7のa)。   When the REQ signal line is added and communication is started from the master 101, the communication of the embodiment of FIG. 7 is performed. That is, the master 101 notifies the slave 201 of communication start and communication permission by setting the SS signal line to the low level (a in FIG. 7).

REQ信号線を追加した場合においても、マスター101とスレーブ201が同時に送信を開始した場合、以下のように双方が送信側として通信を開始する。   Even when the REQ signal line is added, when the master 101 and the slave 201 start transmission at the same time, both start communication as the transmission side as follows.

スレーブ201は、送信側として通信(第2送信動作)を開始するため、第2要求信号としてREQ信号線をLowレベルにすることにより、通信開始および受信動作の要求をマスター101へ通知する。   Since the slave 201 starts communication (second transmission operation) as the transmission side, the slave 201 notifies the master 101 of a request for communication start and reception operation by setting the REQ signal line to a low level as a second request signal.

マスター101は、送信側として通信(第1送信動作)を開始するため、第1要求信号としてSS信号線をLowレベルにすることにより、通信開始および通信許可をスレーブ201に通知する。   Since the master 101 starts communication (first transmission operation) as the transmission side, the master 101 notifies the slave 201 of communication start and communication permission by setting the SS signal line to a low level as a first request signal.

スレーブ201は、SS信号線のLowレベルを検知することにより、マスター101の受信動作の実行を通知する信号(第2要求信号に対する応答)であると判断して、送信側として通信(第2送信動作)を開始し、RDYパルスを出力する。
マスター101は、RDYパルスを検出して、このパルスをスレーブ201の通信準備完
了の信号、すなわち、スレーブ201の受信動作の実行を通知する信号(第1要求信号に対する応答)であると判断して、送信側として通信を開始する。以上の場合においても、マスター101あるいはスレーブ201が、送信開始後、1バイト目に受信したデータが、受信側であることを示す所定値である場合には、送信動作を継続し、受信側であることを示す所定値でない場合には、受信動作に切り替えるので、通信に失敗することなく、安定した通信が可能な同期式シリアル通信システムを実現可能である。
The slave 201 detects the low level of the SS signal line and determines that the signal is a signal (response to the second request signal) notifying the execution of the reception operation of the master 101, and performs communication (second transmission) as the transmission side. Operation) and an RDY pulse is output.
The master 101 detects the RDY pulse and determines that this pulse is a signal indicating that the slave 201 is ready for communication, that is, a signal notifying the execution of the reception operation of the slave 201 (response to the first request signal). Then, start communication as the transmitting side. Even in the above case, if the data received by the first byte after the master 101 or the slave 201 starts transmission is a predetermined value indicating that it is the reception side, the transmission operation is continued, and the data is received on the reception side. If it is not a predetermined value indicating that it is present, the operation is switched to the reception operation, so that it is possible to realize a synchronous serial communication system capable of stable communication without failing in communication.

スレーブ201にREQ信号線を追加した場合の例を説明したが、マスター101だけに、REQ信号線に対応する信号線を追加した場合も同様に、マスター101とスレーブ201の双方が送信側として通信を開始することが起こり得る。この場合も同様に、スレーブ201が、第2送信動作から第1受信動作に切替るように構成することで、通信に失敗せずに、安定した通信が可能である。   The example in which the REQ signal line is added to the slave 201 has been described. Similarly, when the signal line corresponding to the REQ signal line is added only to the master 101, both the master 101 and the slave 201 communicate as the transmission side. It can happen to start. In this case as well, by configuring the slave 201 to switch from the second transmission operation to the first reception operation, stable communication is possible without failing in communication.

このように、少なくとも、マスター101の第1要求信号の信号線とマスター101における受信動作の実行を通知する信号を送信する信号線とが兼用されているか、又は、スレーブ201の第2要求信号の信号線とスレーブ201における受信動作の実行を通知する信号を送信する信号線とが兼用されている場合に、マスター101とスレーブ201の双方が送信側として通信を開始することが起こり得る。本実施例の構成では、第1又は第2信号線と受信動作の実行を通知する信号を送信する信号線とを兼用することで信号線を減らしても、安定した通信をすることができる。   As described above, at least the signal line for the first request signal of the master 101 and the signal line for transmitting the signal for notifying execution of the reception operation in the master 101 are combined, or the second request signal of the slave 201 is used. When the signal line and the signal line for transmitting a signal notifying the execution of the reception operation in the slave 201 are also used, it is possible that both the master 101 and the slave 201 start communication as the transmission side. In the configuration of the present embodiment, stable communication can be performed even if the number of signal lines is reduced by using both the first or second signal line and a signal line for transmitting a signal notifying execution of the reception operation.

本実施例において、受信側が通信する場合の1バイト目が受信側であることを示す所定値としたが、2バイト目以降であってもよい。例えば、通信するデータのフォーマットの、先頭の1バイトまたは複数バイトが、送信側と受信側で通信時に必ず交換する情報である場合、これらを通信した後、送信側はコマンド以降のデータを送信し、受信側は受信側であることを示す所定値以降のデータを通信する。この場合の交換情報とは、電源電圧、センサー入力、運針状態など、マスター及びスレーブが各々必要とする双方の情報である。   In the present embodiment, the first byte when the receiving side communicates is a predetermined value indicating that it is the receiving side, but it may be the second byte or later. For example, if the first byte or multiple bytes of the data format to be communicated is information that must be exchanged at the time of communication between the sending side and the receiving side, after sending these, the sending side sends the data after the command The receiving side communicates data after a predetermined value indicating the receiving side. The exchange information in this case is both information required by the master and the slave, such as power supply voltage, sensor input, and hand movement state.

本実施例において、受信側が通信の1バイト目に受信側であることを示す所定値を送信するが、送信側が通信の1バイト目に送信側であることを示す所定値を送信し、受信側が通信の1バイト目に送信側であることを示す所定値以外の任意の値、または、受信側であることを示す所定値を送信するようにしてもよい。この場合、マスター101とスレーブ201が同時に送信側として通信を開始すると、スレーブ201は、マスター101から1バイト目に受信したデータが、送信側であることを示す所定値でない場合には、送信動作を継続し、送信側であることを示す所定値である場合には、送信動作を中止するとともに、マスター101から送信されるデータを、マスター101からの送信動作に基づくデータとして受信する受信動作に切り替える。   In this embodiment, the receiving side transmits a predetermined value indicating that it is the receiving side in the first byte of communication, but the transmitting side transmits a predetermined value indicating that it is the transmitting side in the first byte of communication. An arbitrary value other than a predetermined value indicating the transmitting side or a predetermined value indicating the receiving side may be transmitted at the first byte of communication. In this case, when the master 101 and the slave 201 start communication as the transmission side at the same time, the slave 201 performs a transmission operation when the data received from the master 101 in the first byte is not a predetermined value indicating that it is the transmission side. The transmission operation is stopped and the data transmitted from the master 101 is received as data based on the transmission operation from the master 101. Switch.

但し、受信側が通信の1バイト目に受信側であることを示す所定値を送信する場合に対して、送信側が通信の1バイト目に送信側であることを示す所定値を送信すると、送信側のデータが1バイト長くなるため、前者の方がこの好ましい。   However, when the receiving side transmits a predetermined value indicating that it is the receiving side at the first byte of communication, the transmitting side transmits a predetermined value indicating that it is the transmitting side at the first byte of communication. The former data is 1 byte longer, so the former is preferable.

本実施例において、スレーブ201が、マスター101から1バイト目に受信したデータが、受信側であることを示す所定値であるNULLと異なることにより、受信側に切り換えて通信を継続するが、マスター101が、スレーブ201から1バイト目に受信したデータが、受信側であることを示す所定値であるNULLと異なることにより、受信側に切り換えて通信を継続するようにしてもよい。この場合、マスター101は、スレーブ201から全データを受信した後に、RDY信号線の立ち下りエッジを検知すると、SS信号線をHighレベルにして通信終了および通信禁止をスレーブ201に通知した後、再びS
S信号線をLowレベルにして、送信データの通信を開始する。
In this embodiment, since the data received by the slave 201 in the first byte from the master 101 is different from NULL, which is a predetermined value indicating the receiving side, the communication is continued by switching to the receiving side. If the data received by the first byte from the slave 201 is different from NULL, which is a predetermined value indicating the receiving side, the communication may be continued by switching to the receiving side. In this case, when the master 101 detects the falling edge of the RDY signal line after receiving all the data from the slave 201, the master 101 sets the SS signal line to the high level and notifies the slave 201 of communication end and communication prohibition, and then again. S
The S signal line is set to low level, and transmission of transmission data is started.

本実施例において、受信側が通信の1バイト目で送信する、受信側であるとこを示す所定値としてNULL(00H)を用いたが、FFHやAAHや55Hなど、コマンドに使用している値以外であれば特にこれに限るものではない。   In this embodiment, NULL (00H) is used as a predetermined value indicating that the receiving side is the receiving side, which is transmitted at the first byte of communication. However, FFH, AAH, 55H, etc. are not used for the command. If so, it is not limited to this.

本実施例において、SSおよびRDY信号線のレベルを検出する方法として、プログラムによるポーリングを例に説明したが、RDY信号線をマスター101の外部割込み入力端子に接続し、SS信号線をスレーブ201の外部割込み入力端子に接続し、レベル変化によって割り込みが発生して、プログラムの割込みハンドラが起動する方法であってもよい。この場合にも、信号線のレベル変化が発生してから、実際に割り込みハンドラが呼び出されるまでには、システム上の様々な要因により遅延時間が発生する。この遅延時間により、同様にマスター101、スレーブ201の双方が送信側として動作を開始することを防ぐことができる。   In this embodiment, as a method for detecting the levels of the SS and RDY signal lines, polling by a program has been described as an example. However, the RDY signal line is connected to the external interrupt input terminal of the master 101, and the SS signal line is connected to the slave 201. A method of connecting to an external interrupt input terminal, generating an interrupt due to a level change, and starting an interrupt handler of the program may be used. Also in this case, a delay time occurs due to various factors on the system from when the level change of the signal line occurs until when the interrupt handler is actually called. This delay time can similarly prevent both the master 101 and the slave 201 from starting operation as the transmission side.

また、本実施例において、SCK信号線は、非通信中の通常状態はLowレベルで、立上がりのタイミングでMOSI信号線とMISO信号線からデータを取り込む設定であるが、通常状態がLowレベルで立下りがデータ取り込み、あるいは、通常状態がHighレベルで立上がりがデータ取り込み、あるいは、通常状態がHighレベルで立下りがデータ取り込みであってもよい。MOSI信号線とMISO信号線に読み書きするデータはLSBからの順であるが、MSBからの順であってもよい。SS信号線は、通信許可がHighレベルで、通信禁止がLowレベルであってもよい。RDY信号線は非通信中の通常状態がLowレベルで、RDYパルスがHighレベルを一定期間だけ出力するものであってもよい。   In this embodiment, the SCK signal line is set to take in data from the MOSI signal line and the MISO signal line at the rising timing in the normal state during non-communication, but the normal state rises at the low level. Data acquisition may be performed when the downstream is High, and data is captured when the rising is in the normal state, or data is captured when the normal is in the High level and the falling is. Data read and written to the MOSI signal line and the MISO signal line are in order from the LSB, but may be in order from the MSB. The SS signal line may have a communication permission at a high level and a communication prohibition at a low level. The RDY signal line may be one in which the normal state during non-communication is a low level and the RDY pulse outputs a high level for a certain period.

100 主情報処理装置
101 マスター(メイン・マイクロコンピュータ)
102 ROM
103 RAM
104 送信データ記憶部
105 受信データ記憶部
106 計時部
107 表示部
108 入力部
109 タイマー
110 シリアル通信部
111 RDY入力端子
112 SS出力端子
113 SCK出力端子
114 MOSI出力端子
115 MISO入力端子
116 REQ入力端子
120 内部クロック発生部
200 従情報処理装置
201 スレーブ(サブ・マイクロコンピュータ)
202 ROM
203 RAM
204 送信データ記憶部
205 受信データ記憶部
206 計時部
207 外部通信部
208 送信保留データ記憶部
209 タイマー
210 シリアル通信部
211 RDY出力端子
212 SS入力端子
213 SCK入力端子
214 MOSI入力端子
215 MISO出力端子
216 REQ出力端子
220 内部クロック発生部
S1 送信データ準備工程
S2 タイマー開始工程
S3 SS信号線レベルLowセット工程
S4 タイムアウト判定
S5 RDY信号線立下り判定
S6 残り送信データ有無判定
S7 1バイト通信工程
S8 データ照合判定
S9 SS信号線レベルHighセット工程
S10 タイマー終了工程
S11 タイマー開始工程
S12 SS信号線レベルLowセット工程
S13 1バイト通信工程
S14 タイムアウト判定
S15 RDY信号線立下り判定
S16 残り受信データ有無判定
S17 チェックサム照合判定
S18 エラー処理工程
S19 SS信号線レベルHighセット工程
S20 タイマー終了工程
S21 送信データ準備工程
S22 タイマー開始工程
S23 RDYパルス出力工程
S24 タイムアウト判定
S25 SCK立上がり判定
S26 1バイト通信工程
S27 残り送信データ有無判定
S28 RDYパルス出力工程
S29 1バイト目判定
S30 データ照合判定
S31 1バイト目受信データのNULL照合判定
S32 受信切換工程
S34 タイマー終了工程
S44 タイマー開始工程
S35 RDYパルス出力工程
S36 タイムアウト判定
S37 SCK立上がり判定
S38 1バイト通信工程
S39 残り受信データ有無判定
S40 チェックサム照合判定
S41 エラー処理工程
S42 RDYパルス出力工程
S43 タイマー終了工程
S50 タイマークリア工程
S51 タイマークリア工程
S52 タイマークリア工程
S53 タイマークリア工程
S60 再送処理工程
S61 再送処理工程
100 Main information processing apparatus 101 Master (main microcomputer)
102 ROM
103 RAM
104 Transmission Data Storage Unit 105 Reception Data Storage Unit 106 Timekeeping Unit 107 Display Unit 108 Input Unit 109 Timer 110 Serial Communication Unit 111 RDY Input Terminal 112 SS Output Terminal 113 SCK Output Terminal 114 MOSI Output Terminal 115 MISO Input Terminal 116 REQ Input Terminal 120 Internal clock generator 200 Slave information processor 201 Slave (sub-microcomputer)
202 ROM
203 RAM
204 Transmission data storage unit 205 Reception data storage unit 206 Timing unit 207 External communication unit 208 Transmission pending data storage unit 209 Timer 210 Serial communication unit 211 RDY output terminal 212 SS input terminal 213 SCK input terminal 214 MOSI input terminal 215 MISO output terminal 216 REQ output terminal 220 Internal clock generator S1 Transmission data preparation step S2 Timer start step S3 SS signal line level low setting step S4 Timeout determination S5 RDY signal line falling determination S6 Remaining transmission data presence determination S7 1 byte communication step S8 Data verification determination S9 SS signal line level high setting step S10 Timer end step S11 Timer start step S12 SS signal line level low setting step S13 1 byte communication step S14 Timeout determination S15 RDY signal line falling determination S 6 Remaining received data presence / absence determination S17 Check sum verification determination S18 Error processing step S19 SS signal line level high setting step S20 Timer end step S21 Transmission data preparation step S22 Timer start step S23 RDY pulse output step S24 Timeout determination S25 SCK rising determination S26 1 Byte communication step S27 Remaining transmission data presence / absence determination S28 RDY pulse output step S29 First byte determination S30 Data verification determination S31 First byte reception data NULL verification determination S32 Reception switching step S34 Timer end step S44 Timer start step S35 RDY pulse output step S36 Time-out determination S37 SCK rising determination S38 1 byte communication process S39 Remaining received data presence determination S40 Checksum collation determination S41 Error processing process S42 RDY Luz output step S43 timer end process S50 timer clear step S51 timer clear step S52 timer clear step S53 timer clear step S60 retransmission processing step S61 retransmission process

Claims (5)

第1情報処理装置と第2情報処理装置と、
前記第1情報処理装置と前記第2情報処理装置との間でシリアル通信によりデータを送受信するための信号線とを有し、
前記第1及び前記第2情報処理装置との間で同期して通信するための同期信号を、前記第1又は前記第2情報処理装置が出力するシリアル通信システムであって、
前記第1情報処理装置は、前記第2情報処理装置にデータを送信する第1送信動作を開始する際に、前記第2情報処理装置に、前記第1情報処理装置から送信されたデータを受信をする第1受信動作の実行を要求する第1要求信号を出力し、
前記第2情報処理装置は、前記第1情報処理装置にデータを送信する第2送信動作を開始する際に、前記第1情報処理装置に、前記第2情報処理装置から送信されたデータを受信する第2受信動作の実行を要求する第2要求信号を出力し、
前記第1情報処理装置は、前記第2受信動作中に、前記第1送信動作で前記2情報処理装置へのデータの送信に用いる信号線を介して、予め定められたデータを送信し、
前記第2情報処理装置は、前記第2送信動作において、前記予め定められたデータを受信しない場合には、前記第2送信動作から前記第1受信動作に切替えることを特徴とするシリアル通信システム。
A first information processing device and a second information processing device;
A signal line for transmitting and receiving data by serial communication between the first information processing device and the second information processing device;
A serial communication system in which the first or the second information processing device outputs a synchronization signal for synchronously communicating with the first and second information processing devices,
When the first information processing device starts a first transmission operation for transmitting data to the second information processing device, the first information processing device receives data transmitted from the first information processing device to the second information processing device. A first request signal for requesting execution of the first reception operation is performed;
When the second information processing device starts a second transmission operation for transmitting data to the first information processing device, the second information processing device receives data transmitted from the second information processing device to the first information processing device. A second request signal for requesting execution of the second reception operation is performed,
The first information processing apparatus transmits predetermined data via a signal line used for transmitting data to the second information processing apparatus in the first transmission operation during the second reception operation,
In the second transmission operation, the second information processing apparatus switches from the second transmission operation to the first reception operation when not receiving the predetermined data.
第1情報処理装置と第2情報処理装置と、
前記第1情報処理装置と前記第2情報処理装置との間でシリアル通信によりデータを送受信するための複数の信号線とを有し、
前記第1及び前記第2情報処理装置との間で同期して通信するための同期信号を、前記第1又は前記第2情報処理装置が出力するシリアル通信システムであって、
前記第1情報処理装置は、前記第2情報処理装置にデータを送信する第1送信動作を開始する際に、前記第2情報処理装置に、前記第1情報処理装置から送信されたデータを受信する第1受信動作の実行を要求する第1要求信号を出力し、
前記第2情報処理装置は、前記第1情報処理装置にデータを送信する第2送信動作を開
始する際に、前記第1情報処理装置に、前記第2情報処理装置から送信されたデータを受信する第2受信動作の実行を要求する第2要求信号を出力し、
前記第1情報処理装置は、前記第1送信動作中に、該第1送信動作で前記2情報処理装置へのデータの送信に用いる信号線を介して、予め定められたデータを送信し、
前記第2情報処理装置は、前記第2送信動作において、前記予め定められたデータを受信した場合には、前記第2送信動作から前記第1受信動作に切替えることを特徴とするシリアル通信システム。
A first information processing device and a second information processing device;
A plurality of signal lines for transmitting and receiving data by serial communication between the first information processing device and the second information processing device;
A serial communication system in which the first or the second information processing device outputs a synchronization signal for synchronously communicating with the first and second information processing devices,
When the first information processing device starts a first transmission operation for transmitting data to the second information processing device, the first information processing device receives data transmitted from the first information processing device to the second information processing device. A first request signal for requesting execution of the first reception operation is performed;
When the second information processing device starts a second transmission operation for transmitting data to the first information processing device, the second information processing device receives data transmitted from the second information processing device to the first information processing device. A second request signal for requesting execution of the second reception operation is performed,
The first information processing apparatus transmits predetermined data via a signal line used for transmitting data to the second information processing apparatus in the first transmission operation during the first transmission operation,
In the second transmission operation, the second information processing apparatus switches from the second transmission operation to the first reception operation when receiving the predetermined data.
前記データを送受信するための信号線は、前記第1情報処理装置が前記第2情報処理装置に、前記第1要求信号を出力する第1信号線と、前記第2情報処理装置が前記第1情報処理装置に、前記第2要求信号を出力する第2信号線とを有し、
前記第2情報処理装置が、前記第1要求信号に対して、前記第2信号線から受信動作の実行を示す信号を送信し、前記第1情報処理装置が、前記第2信号線から、前記受信動作の実行を示す信号を受信することにより前記第1送信動作を実行するように構成するか、又は、
前記第1情報処理装置が、前記第2要求信号に対して、前記第1信号線から受信動作の実行を示す信号を送信し、前記第2情報処理装置が、前記第1信号線から、前記受信動作の実行を示す信号を受信することにより前記第2送信動作を実行するように構成することにより、
前記第1信号線と前記第2信号線の少なくともいずれかを、受信動作の実行を示す信号を送信する信号線と兼用したことを特徴とする請求項1又は2に記載のシリアル通信システム。
The signal line for transmitting and receiving the data includes a first signal line for outputting the first request signal from the first information processing apparatus to the second information processing apparatus, and a first signal line for outputting the first request signal to the second information processing apparatus. A second signal line that outputs the second request signal to the information processing apparatus;
In response to the first request signal, the second information processing apparatus transmits a signal indicating execution of a receiving operation from the second signal line, and the first information processing apparatus transmits the signal from the second signal line. Configured to perform the first transmission operation by receiving a signal indicating execution of a reception operation, or
In response to the second request signal, the first information processing apparatus transmits a signal indicating execution of a receiving operation from the first signal line, and the second information processing apparatus transmits the signal from the first signal line. By performing the second transmission operation by receiving a signal indicating the execution of the reception operation,
The serial communication system according to claim 1, wherein at least one of the first signal line and the second signal line is also used as a signal line for transmitting a signal indicating execution of a reception operation.
前記第2情報処理装置は、前記第1受信動作中に、前記第2送信動作で前記第1情報処理装置へのデータの送信に用いる信号線を介して、前記第1情報処理装置に所定のチェック用データを送信し、
前記第1情報処理装置は、前記第1送信動作中に、前記第2情報処理装置から、前記所定のチェック用データを受信することにより正常にデータが送信されたと判断し、前記所定のチェック用データを受信しない場合に正常にデータが送信されなかったと判断し、
前記第2情報処理装置は、前記第2送信動作から前記第1受信動作に切り替えたときに、前記第2送信動作で前記第1情報処理装置へのデータの送信に用いる信号線から、前記所定のチェック用データを送信することを特徴とする請求項1〜3のいずれか1項に記載のシリアル通信システム。
During the first reception operation, the second information processing device transmits a predetermined signal to the first information processing device via a signal line used for transmitting data to the first information processing device in the second transmission operation. Send check data,
The first information processing apparatus determines that data has been normally transmitted by receiving the predetermined check data from the second information processing apparatus during the first transmission operation, and the predetermined check data If the data is not received, it is determined that the data has not been transmitted normally.
When the second information processing apparatus switches from the second transmission operation to the first reception operation, the second information processing apparatus receives the predetermined signal from a signal line used for transmitting data to the first information processing apparatus in the second transmission operation. The serial communication system according to claim 1, wherein the check data is transmitted.
前記第1送信動作において送信されるデータが複数バイトのデータで構成され、
前記第2情報処理装置は、前記第1受信動作において、前記第1送信動作で送信される第2バイト以降のデータを受信する際に、前記第2送信動作で前記第1情報処理装置へのデータの送信に用いる信号線を介して、所定のチェック用のデータを送信し、
前記第1情報処理装置は、前記第1送信動作において、第2バイト以降のデータを送信する際に、該第2バイト以降のデータの送信とともに、前記第2情報処理装置から送信される前記チェック用データを受信し、
前記第2情報処理装置は、前記第2送信動作において、前記第1情報処理装置から送信される第1バイトのデータが、前記予め定められたデータではない場合に、前記第2送信動作から前記第1受信動作に切替えるとともに、該第1受信動作において、前記第1情報処理装置が前記第2バイト以降のデータを送信するときに、前記所定のチェック用データを送信することを特徴とする請求項1に記載のシリアル通信システム。
The data transmitted in the first transmission operation is composed of a plurality of bytes of data,
When the second information processing apparatus receives data after the second byte transmitted in the first transmission operation in the first reception operation, the second information processing apparatus transmits data to the first information processing apparatus in the second transmission operation. Send data for a predetermined check via the signal line used for data transmission,
In the first transmission operation, when the first information processing apparatus transmits data after the second byte, the check transmitted from the second information processing apparatus together with the transmission of the data after the second byte. Receive data for
In the second transmission operation, when the first byte data transmitted from the first information processing device is not the predetermined data in the second transmission operation, the second information processing device starts from the second transmission operation. Switching to the first reception operation, and in the first reception operation, when the first information processing apparatus transmits data after the second byte, the predetermined check data is transmitted. Item 2. The serial communication system according to Item 1.
JP2012236502A 2012-10-26 2012-10-26 Serial communication system Active JP6004891B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2012236502A JP6004891B2 (en) 2012-10-26 2012-10-26 Serial communication system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2012236502A JP6004891B2 (en) 2012-10-26 2012-10-26 Serial communication system

Publications (2)

Publication Number Publication Date
JP2014086992A JP2014086992A (en) 2014-05-12
JP6004891B2 true JP6004891B2 (en) 2016-10-12

Family

ID=50789652

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2012236502A Active JP6004891B2 (en) 2012-10-26 2012-10-26 Serial communication system

Country Status (1)

Country Link
JP (1) JP6004891B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6552178B2 (en) * 2014-10-23 2019-07-31 株式会社ユニバーサルエンターテインメント Game machine

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0817367B2 (en) * 1989-08-09 1996-02-21 セイコー電子工業株式会社 Data comparison synchronous serial communication system
JPH0563751A (en) * 1991-09-05 1993-03-12 Kyushu Nippon Denki Software Kk Communication system for frame level
GB201102594D0 (en) * 2011-02-15 2011-03-30 Nordic Semiconductor Asa Serial interface

Also Published As

Publication number Publication date
JP2014086992A (en) 2014-05-12

Similar Documents

Publication Publication Date Title
US9813598B2 (en) Light emitting system, light emission control apparatus and control method therefor, communication system and control method therefor and storage medium
CN103312636B (en) Signal conditioning package, serial communication system and device and communication initialization method
JP6210187B2 (en) Integrated circuit device, physical quantity measuring device, electronic device, and moving object
JP2018504714A (en) Voltage mode and current mode device enumeration
JP2013517486A (en) Method and apparatus for monitoring frequency signals
US11216049B2 (en) Bus system
JP6004891B2 (en) Serial communication system
US10986556B2 (en) Circuit for monitoring a data processing system
US20220093068A1 (en) Wireless communication device, electronic device, and wireless communication method
CN110119365B (en) Serial port communication simulation method, cooking utensil and readable storage medium
JP5097516B2 (en) Control signal communication method, optical transceiver system, and optical transceiver device
JP3487458B2 (en) Parallel signal transmission device
KR20050046932A (en) System for checking state of slave devices using i2c bus
JP6359915B2 (en) Semiconductor device, battery monitoring system, and semiconductor device address setting method
KR102104967B1 (en) Duplicated board setting method and the board thereof
CN100531189C (en) method for implementing communication protocol replacement and host interface device
JP6927766B2 (en) Information setting device
JP6744027B2 (en) Terminal device and read control program
JP5801330B2 (en) Device status monitoring method
GB2509234A (en) Electronic tag with error detection for internal data transfer
JP2006229696A (en) Communication device for telemeter
JP2014213675A (en) Network system
US11979170B2 (en) Accessory, method of controlling accessory, electronic device, method of controlling electronic device, communication system, and storage medium
TWI786890B (en) Rs-485 circuit and communication system
KR20210150174A (en) Electronic device using blockchain and a method thereof

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20150513

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20160526

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20160614

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20160728

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20160823

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20160906

R150 Certificate of patent or registration of utility model

Ref document number: 6004891

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313115

S533 Written request for registration of change of name

Free format text: JAPANESE INTERMEDIATE CODE: R313533

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250