JP4244844B2 - Serial communication method and communication apparatus - Google Patents
Serial communication method and communication apparatus Download PDFInfo
- Publication number
- JP4244844B2 JP4244844B2 JP2004106094A JP2004106094A JP4244844B2 JP 4244844 B2 JP4244844 B2 JP 4244844B2 JP 2004106094 A JP2004106094 A JP 2004106094A JP 2004106094 A JP2004106094 A JP 2004106094A JP 4244844 B2 JP4244844 B2 JP 4244844B2
- Authority
- JP
- Japan
- Prior art keywords
- time
- data
- reception
- unit
- edge
- 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.)
- Expired - Fee Related
Links
Images
Landscapes
- Synchronisation In Digital Transmission Systems (AREA)
- Dc Digital Transmission (AREA)
Description
本発明は、通信ラインを介してシリアルデータの送受信を行うシリアル通信方法及び通信装置に関する。 The present invention relates to a serial communication method and a communication apparatus for transmitting / receiving serial data via a communication line.
従来より、通信ラインを介して接続された複数の通信装置が相互にシリアルデータを送受信できるよう構成されたシリアル通信システムとして、例えば車両に搭載された複数の電子制御装置(以下「ECU」という)が相互にデータ通信を行うことにより、車両の各部を制御するよう構成された車載シリアル通信システムが知られている。 Conventionally, as a serial communication system configured such that a plurality of communication devices connected via a communication line can transmit and receive serial data to each other, for example, a plurality of electronic control devices (hereinafter referred to as “ECUs”) mounted on a vehicle. There are known in-vehicle serial communication systems configured to control each part of a vehicle by performing data communication with each other.
この車載シリアル通信システムにおける通信フォーマットの一例を図16に示す。図16は、一般的な調歩同期式シリアル通信の通信フォーマットであり、複数バイトのデータによって一つのフレームが構成される。そして、例えばあるECUがこの1フレーム分のデータを通信ライン上に送出すると、他のECUはそれを受信することになるが、このとき、通信ラインが所定ビット(例えば10ビット)以上連続してHighレベル(以下「Hレベル」という)状態となったときに、送信元ECUからの1フレーム分のデータ送信が終わったこと、即ち通信ラインがアイドル状態になったことを検出するようにしている。 An example of a communication format in this in-vehicle serial communication system is shown in FIG. FIG. 16 shows a communication format of general asynchronous serial communication, and one frame is composed of a plurality of bytes of data. For example, when one ECU sends out the data for one frame on the communication line, the other ECUs receive it. At this time, the communication line continues for a predetermined bit (for example, 10 bits) or more. When a high level (hereinafter referred to as “H level”) state is reached, it is detected that the transmission of one frame of data from the transmission source ECU has ended, that is, the communication line has entered an idle state. .
アイドル状態が検出されると、各ECUは受信したデータに基づいて所定の処理を行う。そして、何らかの応答をすべきECUが存在する場合、そのECUは、応答すべきデータを上記同様のフォーマットにて通信ライン上へ送出する。 When the idle state is detected, each ECU performs a predetermined process based on the received data. Then, when there is an ECU that should make some response, the ECU sends the data to be sent to the communication line in the same format as described above.
また、一つのフレームを構成する1バイトデータはいずれも、図16に示すように、ビット0〜ビット7までの8ビットからなるNRZ(ノンリターンゼロ)方式の有効データと、その先頭に付加されるLow レベル(以下「Lレベル」という)のスタートビットと、その末尾に付加されるHレベルのストップビットとからなるフォーマットにて構成されている。
In addition, as shown in FIG. 16, each 1-byte data constituting one frame is added to the head of NRZ (non-return zero) type effective data consisting of 8 bits from
ところで、この種のシリアル通信システムを構成する各ECUは、上記のシリアル通信動作と、そのECUの通信以外の動作とを制御するために、マイクロコンピュータ(以下「マイコン」という)を備えている。そして、このようなマイコンとして、上述したアイドル状態の検出を行うためのハードウェアを備えたものが知られている(例えば、非特許文献1参照。)。 By the way, each ECU constituting this type of serial communication system includes a microcomputer (hereinafter referred to as “microcomputer”) in order to control the serial communication operation and operations other than the communication of the ECU. As such a microcomputer, one having hardware for detecting the above-described idle state is known (for example, see Non-Patent Document 1).
図17に、アイドル状態の検出をハード的に行うよう構成されたマイコンの一例を示す。図示の如く、マイコン100は、プログラムを記憶するROM102と、ROM102に記憶されたプログラムを実行するCPU101と、CPU101による演算結果などを一時記憶するRAM103と、通信ラインL1上のシリアルデータを受信バッファ107及びデータ入力ポートP2を介して受信すると共にデータ出力ポートP1及び送信バッファ106を介して通信ラインL1上へシリアルデータを送信する通信部104と、を備えている。尚、以下の説明では、受信バッファ107を介してデータ入力ポートP2へ入力されるデータを受信データRxD、通信部104からデータ出力ポートP1を介して送信バッファ106へ送出されるデータを送信データTxDという。
FIG. 17 shows an example of a microcomputer configured to perform hardware detection of an idle state. As shown in the figure, the
そして、通信部104は、データ入力ポートP2に入力される受信データRxDに基づいてアイドル状態の検出を行うアイドル検出部108を備えている。このアイドル検出部108は、マイコン100がもともと備えているハードウェアである。そのため、このマイコン100を使用するユーザは、アイドル検出部108の検出結果を利用してシリアル通信制御用のプログラムを組むことができる。
しかしながら、シリアル通信を制御するマイコンは、必ずしも上記マイコン100のようにアイドル状態をハード的に検出できるよう構成されているとは限らず、そのようなハードウェアを備えていないマイコンも存在する。
However, the microcomputer that controls the serial communication is not necessarily configured to detect the idle state in hardware like the
仮にそのようなアイドル状態の検出を行うハードウェアを備えていないマイコンを用いてシリアル通信やその他の各種制御を行いたい場合、そのままの(デフォルトの)状態ではマイコンはアイドル状態を検出できず、データの受信終了、即ち図16で説明した1フレームの受信終了を判定できない。そのため、正常な通信が行われているにも拘わらず、通信エラーが生じて通信が出来なくなる場合が発生する。 If you want to perform serial communication and other various controls using a microcomputer that does not have hardware that detects such an idle state, the microcomputer cannot detect the idle state in the same (default) state, and data , That is, the end of reception of one frame described with reference to FIG. 16 cannot be determined. For this reason, there is a case where a communication error occurs and communication cannot be performed even though normal communication is performed.
本発明は上記課題に鑑みなされたものであり、複数の通信装置間でシリアル通信を行うにあたり、通信ラインのアイドル状態を検出して正常なシリアル通信を行えるようにすることを目的とする。 The present invention has been made in view of the above problems, and an object of the present invention is to enable normal serial communication by detecting an idle state of a communication line when performing serial communication between a plurality of communication devices.
上記課題を解決するためになされた請求項1記載の発明は、通信ラインを介して接続された複数の通信装置相互間でシリアルデータの送受信を行うシリアル通信方法であって、通信装置は、シリアルデータの受信開始後、所定のタイミング毎に、該タイミングから所定の判定時間が経過するまでの間に受信データのエッジが検出されたか否かを判定する。そして、該判定時間が経過するまでの間にエッジが検出されなかった場合であって、且つ、該判定時間経過時の通信ラインの論理レベルがアクティブレベルではない場合に、通信ラインがアイドル状態であると判定する。
The invention of
つまり、上記判定時間中にエッジが検出された場合は、少なくともその判定時間中にはまだ単位データの受信が行われていたものと考えられるが、アイドル状態のときはエッジ変化がない(例えばHレベル持続)ため、判定時間中にエッジが検出されなかった場合はアイドル状態と判定する。
但し、上記判定時間中にエッジが検出されなかった場合であっても、例えば、その判定時間中にアクティブレベルのビットデータのみを連続して受信したということも考えられる。そのような場合、データ受信中であるにも拘わらずその間はエッジが検出されない。
そこで本発明(請求項1)では、判定時間が経過するまでの間にエッジが検出されなかった場合であって、且つ、該判定時間経過時の通信ラインの論理レベルがアクティブレベルではない場合に、アイドル状態と判定するのである。
That is, if an edge is detected during the determination time, it is considered that the unit data has been received at least during the determination time, but there is no edge change in the idle state (for example, H Therefore, if no edge is detected during the determination time, it is determined to be in an idle state .
However, even when an edge is not detected during the determination time, for example, it may be considered that only bit data of an active level is continuously received during the determination time. In such a case, an edge is not detected during the reception of data.
Therefore, in the present invention (Claim 1), when the edge is not detected before the determination time elapses and the logical level of the communication line at the time of the determination time elapses is not the active level. The idle state is determined.
従って、上記方法によれば、判定時間中のエッジの有無を所定のタイミング毎に判定し、その判定結果に基づいてアイドル状態であるか否かの判定を行うため、通信ラインのアイドル状態を検出して正常なシリアル通信を行うことが可能となる。
また、判定時間中に論理レベルがアクティブレベルのビットのみを複数連続して受信したことによりエッジが検出されなくても、その論理レベルに基づいてアイドル状態とは判定されないため、アイドル状態の検出をより正確に行うことが可能となる。
Therefore, according to the above method, the idle state of the communication line is detected in order to determine the presence / absence of an edge during the determination time at each predetermined timing, and to determine whether the state is the idle state based on the determination result. Thus, normal serial communication can be performed.
In addition, even if an edge is not detected due to continuous reception of only a plurality of bits whose logical level is the active level during the determination time, the idle state is not determined based on the logical level. It becomes possible to carry out more accurately.
尚、検出対象のエッジは、例えば立ち上がりエッジ又は立ち下がりエッジのいずれかとしてもよいし、立ち上がり・立ち下がりの両エッジとしてもよく、単位データを構成する各ビットのフォーマットや上記タイミングをどこにするか等を考慮して適宜決めればよい。また、判定時間についても、例えば、その判定時間中に単位データのうち数ビット分のデータが受信される程度の長さにするなど、データフォーマットに応じて適宜設定すればよい。上記タイミングについても、例えば単位データの受信を終了する毎とするなど、アイドル状態か否かを適切に判定できる限り適宜設定すればよい。 The edge to be detected may be, for example, either a rising edge or a falling edge, or both rising and falling edges. Where is the format of each bit constituting the unit data and the timing described above? It may be determined appropriately in consideration of the above. In addition, the determination time may be set as appropriate according to the data format, for example, to be long enough to receive several bits of unit data during the determination time. The timing may be set as appropriate as long as it can be appropriately determined whether or not it is in an idle state, for example, every time reception of unit data ends.
ここで、例えば上記請求項1記載のシリアル通信方法において、上記タイミングを例えば単位データの受信終了時としたとき、通信速度によっては、その受信終了時から判定時間経過時までの間にエッジが発生してもそれを検出できない場合が考えられる。即ち、例えば単位データ受信終了時の受信割込処理によって判定時間内のエッジ検出を開始するよう構成されている場合、受信終了と同時に受信割込処理を開始できるとは限らず、受信終了時から所定期間経過後に受信割込処理が開始されることも考えられる。そのような場合に、通信速度が高速であることに起因して次の単位データのうち数ビットを既に受信した後に受信割込処理が開始されると、その受信した数ビットにエッジが発生していてもそれは検出されないことになる。
Here, for example, in the serial communication method according to
そこで、通信速度に関係なくアイドル状態を正確に検出するためには、例えば請求項2記載のシリアル通信方法を用いるとよい。即ち、請求項2記載のシリアル通信方法は、シリアルデータが、所定ビット数のデータを単位データとして、複数の単位データからなるデータフレームとして構成されており、通信装置は、受信データのエッジを検出する毎に該検出時刻を記憶しておく。そして、単位データを受信する毎に、該受信の終了時直前に検出されたエッジの検出時刻と、該エッジから該単位データ受信終了時までの受信ビット数とに基づいて、該単位データの受信終了時刻を算出する。 Therefore, in order to accurately detect the idle state regardless of the communication speed, for example, the serial communication method according to claim 2 may be used. That is, in the serial communication method according to claim 2 , the serial data is configured as a data frame including a plurality of unit data, with the data having a predetermined number of bits as unit data, and the communication device detects an edge of the received data. The detection time is stored every time. Each time the unit data is received, the reception of the unit data is performed based on the detection time of the edge detected immediately before the end of the reception and the number of received bits from the edge to the end of the reception of the unit data. Calculate the end time.
そして、上記受信終了時刻に、少なくとも、データギャップ時間及び単位データのデータ長に対応した時間を加えた時刻を、アイドル判定時刻として設定し、受信終了時刻からアイドル判定時刻までの間に単位データを受信しなかった場合に、通信ラインがアイドル状態であると判定する。ここで、データギャップ時間とは、単位データの受信終了時から次の単位データの受信開始時までの時間である。 Then, a time obtained by adding at least the data gap time and the time corresponding to the data length of the unit data to the reception end time is set as an idle determination time, and unit data is set between the reception end time and the idle determination time. If not received, it is determined that the communication line is idle. Here, the data gap time is the time from the end of reception of unit data to the start of reception of the next unit data.
即ち、1ビットあたりのデータ長(時間)は予めわかっているため、単位データ受信中のエッジ検出時刻を記憶しておけば、そのエッジ検出時刻に、そのエッジからその単位データ受信終了までのビット数に相当する時間を加えることにより、単位データの受信終了時刻が正確に算出できる。そして、算出した受信終了時刻に対し、さらに、データギャップ時間及び一つの単位データのデータ長に対応した時間を加えれば、次の単位データの受信終了時刻が正確に算出されることになり、この時刻をアイドル判定時刻とするのである。 That is, since the data length (time) per bit is known in advance, if the edge detection time during unit data reception is stored, the bits from that edge to the end of the unit data reception are stored at that edge detection time. By adding a time corresponding to the number, the reception end time of the unit data can be accurately calculated. Then, if the time corresponding to the data gap time and the data length of one unit data is further added to the calculated reception end time, the reception end time of the next unit data is accurately calculated. The time is set as the idle determination time.
つまり、請求項1の方法のようにある期間(判定時間)内のエッジの有無をみるのではなく、単位データの受信終了時刻と、その次の単位データの受信終了時刻に相当するアイドル判定時刻とを正確に算出して、両時刻の間の単位データ受信の有無をみるのである。この両時刻は、通信速度に関係なく正確に算出されるものである。
That is, instead of looking at the presence or absence of an edge within a certain period (determination time) as in the method of
従って、上記方法によれば、アイドル判定に関わる各時刻を正確に算出し、その算出した各時刻に基づいてアイドル状態の判定を行うようにしているため、通信速度が高速になってもその判定を正確に行うことができる。 Therefore, according to the above method, each time related to the idle determination is accurately calculated, and the determination of the idle state is performed based on each calculated time. Therefore, even if the communication speed becomes high, the determination Can be done accurately.
尚、データギャップ時間は、例えば数ビット分の時間である場合や、或いは、ゼロの場合(つまり複数の単位データが間隔を空けずに連続して送受信される場合)など、シリアル通信のフォーマットによって種々考えられる。 Note that the data gap time depends on the serial communication format, for example, when it is a time of several bits, or when it is zero (that is, when a plurality of unit data are continuously transmitted and received without any interval). There are various possibilities.
次に、請求項3記載の発明は、通信相手の装置と通信ラインを介して接続され、相互にシリアルデータを送受信可能な通信装置であり、通信ラインを介して受信したデータのエッジを検出するエッジ検出手段を備えている。 Next, the invention described in claim 3 is a communication device that is connected to a communication partner device via a communication line and can transmit / receive serial data to / from each other, and detects an edge of data received via the communication line. Edge detection means is provided.
そして、アイドル判定手段が、シリアルデータの受信開始後所定のタイミング毎に動作して、該タイミングから予め設定した判定時間が経過するまでの間にエッジ検出手段によってエッジが検出されなかった場合であって、且つ、判定時間経過時の通信ラインの論理レベルがアクティブレベルではない場合に、通信ラインがアイドル状態であると判定する。 This is a case where the edge determining means operates at a predetermined timing after the start of serial data reception and no edge is detected by the edge detecting means until a predetermined determination time elapses from the timing. In addition, when the logical level of the communication line when the determination time has elapsed is not the active level, it is determined that the communication line is in an idle state.
このように構成された通信装置によれば、判定時間中のエッジ検出の有無に基づいてアイドル状態か否かが判定され、また、例えば判定時間中にアクティブレベルのビットのみが継続することによってエッジが検出されなくても、それを誤ってアイドル状態と誤判定することがないため、請求項1記載のシリアル通信方法が実現され、請求項1と同様、通信ラインのアイドル状態を検出して正常なシリアル通信を行うことが可能となる。そして、例えばアイドル状態の判定を行うハードウェアは持たないもののエッジ検出手段は備えているマイコンに対しては、アイドル判定手段として機能させるためのプログラムをそのマイコンに実行させることで、アイドル状態の判定をソフト的に行うことが可能となる。
According to the communication apparatus configured in this way, it is determined whether or not the idle state is based on the presence or absence of edge detection during the determination time, and, for example, only the bits of the active level are continued during the determination time. even but not detected, since no erroneous determination that erroneously it idle, the serial communication method according to
そして、上記請求項3記載の通信装置は、より具体的には例えば請求項4に記載のように構成することができる。即ち、判定時間を計時するための計時手段と、エッジ検出手段によりエッジが検出されたとき、該検出された旨の情報を保持する検出状態保持手段と、を備えたものであって、アイドル判定手段は、計時開始部と、検出状態初期化部と、エッジ判定部と、レベル判定部と、を備えている。 More specifically, the communication device according to the third aspect can be configured as described in the fourth aspect, for example. That is, a timing means for measuring the determination time, and a detection state holding means for holding information indicating that the edge is detected when the edge is detected by the edge detection means, the idle determination The means includes a timing start unit, a detection state initialization unit, an edge determination unit, and a level determination unit.
計時開始部は、上記タイミング毎に計時手段による前記判定時間の計時を開始させ、検出状態初期化部は、上記タイミング毎に検出状態保持手段を初期化する。そして、エッジ判定部は、計時手段による計時が終了した時の検出状態保持手段に保持されている情報に基づいて、判定時間中にエッジが検出されたか否かを判定する。レベル判定部は、計時手段による計時終了時の通信ラインの論理レベルを判定する。 The timing start unit starts counting the determination time by the timing unit at each timing, and the detection state initialization unit initializes the detection state holding unit at each timing. Then, the edge determination unit determines whether or not an edge is detected during the determination time based on information held in the detection state holding unit when the timing by the timing unit is completed. The level determination unit determines the logical level of the communication line at the time when the time measuring means ends.
尚、エッジ判定部によってエッジの検出が判定されたときは、そのことのみをもってまだアイドル状態ではないと判定できるため、上記レベル判定部による判定は、エッジ判定部によりエッジ検出が判定されなかった場合にのみ行うようにしてもよい。 Note that when edge detection is determined by the edge determination unit, it can be determined that it is not yet in an idle state. Therefore, the determination by the level determination unit is performed when edge detection is not determined by the edge determination unit. You may make it carry out only to.
また、シリアルデータが、所定ビット数のデータを単位データとして、複数の単位データからなるデータフレームとして構成されている場合には、上記タイミングは、例えば請求項5に記載のように、各単位データの受信終了時にするとよい。このようにすれば、単位データを受信終了する毎にアイドル状態の判定が行われることになり、より効率的な判定が可能となる。 Further, when the serial data is configured as a data frame composed of a plurality of unit data, with the data having a predetermined number of bits as unit data, the timing is determined by each unit data as described in claim 5 , for example. At the end of the reception. In this way, the idle state is determined each time reception of unit data is completed, and more efficient determination is possible.
ところで、エッジ検出手段が検出するエッジは、既述の通り例えば立ち上がりエッジとしてもよいし、立ち下がりエッジとしてもよいが、一般的なシリアル通信のフォーマットは、単位データが、アクティブレベル(Lレベル)のスタートビットと、複数ビットからなる実データと、インアクティブレベル(Hレベル)のストップビットとにより構成される。 By the way, the edge detected by the edge detecting means may be, for example, a rising edge or a falling edge as described above. However, in a general serial communication format, unit data is an active level (L level). Start bits, actual data including a plurality of bits, and inactive level (H level) stop bits.
この場合に、例えば実データ部分が全てアクティブレベル(Lレベル)のときは、ストップビット開始時の立ち下がりエッジ以外は立ち下がりエッジが生じないことになる。そのため、上記請求項5のように単位データの受信終了時毎にアイドル判定手段が動作するよう構成した場合に、エッジ検出手段が立ち下がりエッジを検出するようにすると、データ受信中であるにも拘わらず立ち下がりエッジが検出されないことによって、アイドル状態であると誤判定してしまうおそれがある。 In this case, for example, when all the actual data portions are at the active level (L level), no falling edge occurs except for the falling edge at the start of the stop bit. For this reason, when the idle determining means operates every time when the reception of the unit data is completed as in claim 5 , if the edge detecting means detects the falling edge, the data is being received. Nevertheless, the falling edge is not detected, so that it may be erroneously determined to be in the idle state.
そこで、単位データの受信終了時毎にアイドル判定手段が動作するよう構成した場合、エッジ検出手段は、請求項6に記載のように立ち上がりエッジを検出するものであるとよい。このようにすれば、アイドル状態の誤判定を抑止することが可能となる。 Therefore, when the idle determination unit is configured to operate every time when reception of unit data is completed, the edge detection unit may detect a rising edge as described in claim 6 . In this way, erroneous determination of the idle state can be suppressed.
また、請求項5又は6記載の通信装置のように、単位データの受信終了時毎にアイドル判定手段が動作するよう構成した場合、判定時間は、例えば請求項7記載のように、単位データの受信終了時から次の単位データの受信開始時までの時間であるデータギャップ時間以上であって、且つ、データギャップ時間に単位データのデータ長に対応した時間を加えた時間以下にするとよい。 In addition, when the idle determination unit is configured to operate every time when reception of unit data is completed, as in the communication device according to claim 5 or 6 , the determination time is, for example, as shown in claim 7 , It may be set to be equal to or longer than the data gap time, which is the time from the end of reception to the start of reception of the next unit data, and less than the time obtained by adding the time corresponding to the data length of the unit data to the data gap time.
つまり、単位データの受信終了時から、次の単位データの受信終了時までの間に判定時間を設定するのである。このようにすれば、単位データを受信する毎に、その受信終了後の次の単位データについてその受信の有無が判定されることになるため、アイドル状態の判定をより的確に行うことができる。 That is, the determination time is set between the end of reception of unit data and the end of reception of the next unit data. In this way, every time unit data is received, the presence / absence of reception of the next unit data after the end of the reception is determined, so that the idle state can be determined more accurately.
次に、請求項8記載の通信装置は、通信相手の装置と通信ラインを介して接続され、相互にシリアルデータを送受信可能な通信装置であって、シリアルデータは、所定ビット数のデータを単位データとして、複数の単位データからなるデータフレームとして構成されており、受信データのエッジを検出して該検出時の時刻を記憶するエッジ時刻記憶手段を備えたものである。 Next, the communication device according to claim 8 is a communication device which is connected to a communication partner device via a communication line and can transmit / receive serial data to / from each other, and the serial data is a unit of data of a predetermined number of bits. The data is configured as a data frame composed of a plurality of unit data, and includes an edge time storage means for detecting an edge of received data and storing the time at the time of detection.
そして、単位データを受信する毎に、第1時刻算出手段が、エッジ時刻記憶手段の記憶内容に基づいて該受信終了前における最後にエッジが検出された時刻である最新エッジ検出時刻を取得して、該最新エッジ検出時刻と、該最後に検出されたエッジから該単位データの受信終了時までの受信ビット数とに基づいて、該単位データの受信終了時刻を算出する。 Each time the unit data is received, the first time calculation means obtains the latest edge detection time that is the last time the edge was detected before the end of reception based on the stored contents of the edge time storage means. The unit data reception end time is calculated based on the latest edge detection time and the number of received bits from the last detected edge to the end of reception of the unit data.
さらに第2時刻算出手段が、上記算出された受信終了時刻に少なくとも、データギャップ時間と単位データのデータ長に対応した時間とを加えた時刻を、アイドル判定時刻として算出する。そして、アイドル判定手段が、上記受信終了時刻からアイドル判定時刻までの間に単位データが受信されなかった場合に、通信ラインがアイドル状態であると判定する。データギャップ時間は、既述の通り単位データの受信終了時から次の単位データの受信開始時までの時間である。 Further, the second time calculating means calculates a time obtained by adding at least the data gap time and the time corresponding to the data length of the unit data to the calculated reception end time as the idle determination time. The idle determination means determines that the communication line is in an idle state when no unit data is received between the reception end time and the idle determination time. As described above, the data gap time is the time from the end of reception of unit data to the start of reception of the next unit data.
このように構成された通信装置によれば、第1・第2時刻算出手段によって算出された正確な受信終了時刻及びアイドル判定時刻に基づいてアイドル判定手段が判定を行うため、請求項2記載のシリアル通信方法が実現され、請求項2と同様、通信ラインのアイドル状態を検出して正常なシリアル通信を行うことができ、しかも通信速度が高速になっても正確にアイドル判定を行うことが可能となる。そして、例えばアイドル状態の判定を行うハードウェアは持たないもののエッジ時刻記憶手段は備えているマイコンに対しては、第1時刻算出手段、第2時刻算出手段、及びアイドル判定手段として機能させるためのプログラムをそのマイコンに実行させることで、アイドル状態の判定をソフト的に行うことが可能となる。 According to the communication apparatus configured for idling determination means makes the determination based on accurate reception end time and idle determination time calculated by the first and second time calculation means, according to claim 2, wherein A serial communication method is realized, and as in claim 2 , it is possible to perform normal serial communication by detecting the idle state of the communication line, and also to accurately perform idle determination even when the communication speed is increased. It becomes. For example, for a microcomputer that does not have hardware for determining an idle state but has an edge time storage means, it functions as a first time calculation means, a second time calculation means, and an idle determination means. By causing the microcomputer to execute the program, it becomes possible to determine the idle state in software.
上記構成の通信装置(請求項8)は、より具体的には、例えば請求項9に記載のように構成できる。即ち、設定した時刻になるとその旨を示す信号を出力する計時手段を備えており、さらにアイドル判定手段は、時刻設定部と受信判定部とを備えている。時刻設定部は、単位データの受信を終了する毎に、第2時刻算出手段により算出されたアイドル判定時刻を計時手段に設定し、受信判定部は、計時手段からアイドル判定時刻になったことを示す信号が出力されたときに、該アイドル判定時刻の設定時から該信号の出力時までの間に単位データが受信されたか否かを判定する。そして、受信判定部により受信されなかったと判定された場合に、通信ラインがアイドル状態であると判定する。 More specifically, the communication device having the above configuration (Claim 8 ) can be configured as described in Claim 9 , for example. That is, it includes a time measuring unit that outputs a signal indicating that when the set time comes, and the idle determination unit further includes a time setting unit and a reception determination unit. The time setting unit sets the idle determination time calculated by the second time calculating unit in the time measuring unit every time reception of the unit data ends, and the reception determination unit confirms that the idle determination time has come from the time measuring unit. When the signal shown is output, it is determined whether or not unit data has been received between the time when the idle determination time is set and the time when the signal is output. And when it determines with the reception determination part not having received, it determines with a communication line being an idle state.
また、請求項8又は9記載の通信装置において、エッジ時刻記憶手段は、立ち上がりエッジを検出した時の時刻を記憶するとよい。このようにすれば、請求項6の通信装置の場合と同様、通信中であるにも拘わらずエッジ検出時刻が記憶されない場合が生じるのをより確実に防止でき、アイドル状態の誤判定を抑止することが可能となる。 In the communication device according to claim 8 or 9 , the edge time storage means may store the time when the rising edge is detected. In this way, as in the case of the communication device of claim 6 , it is possible to more reliably prevent the case where the edge detection time is not stored despite communication being performed, and to suppress erroneous determination of the idle state. It becomes possible.
以下に、本発明の好適な実施形態を図面に基づいて説明する。
[第1実施形態]
図1は、本発明が適用された実施形態の車載シリアル通信システムの概略構成を示すブロック図である。図1に示す如く、本実施形態の車載シリアル通信システムは、主として車両の盗難を防止するために必要なデータを登録するためのものであり、車両に搭載されたツール10、エンジンECU20、及びイモビECU30が、シリアルデータ通信用の通信ラインL1にそれぞれ接続されている。
Preferred embodiments of the present invention will be described below with reference to the drawings.
[First Embodiment]
FIG. 1 is a block diagram showing a schematic configuration of an in-vehicle serial communication system according to an embodiment to which the present invention is applied. As shown in FIG. 1, the in-vehicle serial communication system of the present embodiment is mainly for registering data necessary for preventing theft of the vehicle, and includes a
ツール10は、マイコン11に記憶されている暗証コードなどを送信バッファ12を介して通信ラインL1上へ送出すると共に、通信ラインL1上を伝送されるシリアルデータを受信バッファ13を介してマイコン11に入力するよう構成されている。
The
エンジンECU20は、図示しない車両のエンジンを制御するECUであって、通信ラインL1上を伝送されるシリアルデータが受信バッファ23を介してマイコン21へ入力されると共に、マイコン21から出力されたシリアルデータが送信バッファ22を介して通信ラインL1上へ送出されるよう構成されている。
The engine ECU 20 is an ECU for controlling an engine of a vehicle (not shown), and serial data transmitted on the communication line L1 is input to the
イモビECU30は、盗難防止等のセキュリティに関わる各種制御を行うECUであり、通信ラインL1上を伝送されるシリアルデータが受信バッファ33を介してマイコン31へ入力されると共に、マイコン31から出力されたシリアルデータが送信バッファ32を介して通信ラインL1上へ送出されるよう構成されている。
The
本実施形態の車載シリアル通信システムにおいて通信ラインL1上を伝送されるシリアルデータのフォーマットは、図16に示したフォーマットと同様であり、複数の1バイトデータによって一つのフレーム(データフレーム)が構成される。そのため、上記暗証コードを始め、ツール10や各ECU20,30から通信ラインL1上へ送出されるシリアルデータはいずれも図16に示すフォーマットとなる。尚、フレームを構成する各1バイトデータは本発明の単位データに相当するものである。また本実施形態では、フレームを構成する各1バイトデータの間隔(本発明のデータギャップ間隔)はほぼゼロであって連続して送信される。
The format of serial data transmitted on the communication line L1 in the in-vehicle serial communication system of this embodiment is the same as the format shown in FIG. 16, and one frame (data frame) is composed of a plurality of 1-byte data. The For this reason, the serial code sent from the
そして、本実施形態におけるイモビ登録処理時のフレームの流れ、即ち、ツール10から暗証コードが送信されることによってその暗証コードが各ECU20,30に登録される際の通信ラインL1上のフレームの流れは、図3に示すようになる。即ち、まずツール10から暗証コードを含むフレームが通信ラインL1上に送出される。このフレームは、イモビECU30内のマイコン31に対して暗証コードの登録を行うよう要求するものである。
And the flow of the frame at the time of immobilization registration processing in this embodiment, that is, the flow of the frame on the communication line L1 when the personal identification code is registered in each
イモビECU30は、ツール10からの上記フレームを受信すると、そのフレームの内容に従って暗証コード登録などの各種処理を行う。そして、登録後に、登録した旨を示すデータ及び登録した暗証コードを、ツール10に対する応答データ(フレーム)として通信ラインL1上へ送出する。
When the
エンジンECU20は、ツール10からイモビECU30への上記フレームに対しては実質的な処理を行わず、イモビECU30からツール10への応答データを受信することによって、暗証コードの登録を行う。そして、その登録後に、ツール10に対して応答データ(フレーム)を返す。
The engine ECU 20 does not perform substantial processing on the frame from the
上記のような暗証コード登録等の所定の処理が行われることにより、盗難防止システムが機能するようになる。即ち、暗証コードの記憶された電子キーが図示しないキーシリンダに挿入されたときに、イモビECU30内のマイコン31及びエンジンECU20内のマイコン21にて暗証コードの照合等が行われるのだが、ここではその説明は省略する。
By performing predetermined processing such as password code registration as described above, the anti-theft system comes to function. That is, when an electronic key in which a password is stored is inserted into a key cylinder (not shown), the password is verified by the
上記のようなシリアルデータの送受信は、いずれもツール10、各ECU20,30が備える各マイコン11,21,31により制御される。以下、これら各マイコンにおけるシリアル通信のための構成について説明するが、ツール10及び各ECU20,30が備える各マイコン11,21,31は、シリアル通信を制御するための構成及び動作のみに着目すれば、基本的にはいずれも同じものである。そのため、代表としてイモビECU30が備えるマイコン31を例に挙げて説明する。
Transmission / reception of serial data as described above is controlled by the
イモビECU30に設けられているマイコン31は、図2に示すように、プログラムを記憶するROM42と、ROM42に記憶されたプログラムを実行するCPU41と、CPU41による演算結果などを一時記憶するRAM43と、通信ラインL1上のシリアルデータを受信バッファ33及びデータ入力ポートP2を介して受信すると共にデータ出力ポートP1及び送信バッファ32を介して通信ラインL1上へシリアルデータを送信する通信部45と、受信データRxDのエッジを検出するエッジ検出部46と、CPU41からの指令に基づいて計時を行うと共に設定した計時時間が経過したときにタイマ割込処理要求W2を発生するタイマ44と、上記各部を接続するバス47と、を備えている。
As shown in FIG. 2, the
通信部45は、一般的な調歩同期式のシリアル通信インタフェースであり、図示しない受信用レジスタと送信用レジスタとを有している。そして、CPU41によって上記送信用レジスタに1バイト(=8ビット)のデータが書き込まれると、そのデータを有効データとする調歩同期式フォーマットのシリアルデータ(つまり図16で説明した構成の全10ビットからなる1バイトデータ)を、送信データTxDとして送信バッファ32へ順次出力して通信ラインL1に送出する。
The
さらに、通信部45は、通信ラインL1上を伝送される上記10ビット構成のシリアルデータ(1バイトデータ)を上記受信用レジスタによって受信し、その受信が終了すると(つまり、受信用レジスタに上記1バイトデータが格納されると)、受信割込処理要求W1を発生する。
Further, the
このため、CPU41は、通信部45の送信用レジスタに1バイトデータを書き込むことで、そのデータを通信ラインL1上へ送信でき、また、通信部45から受信割込処理要求W1が発生した時に、通信部45の受信用レジスタから1バイト(8ビット)の有効データをRAM43などに転送することで、受信データを取得することができる。
For this reason, the
エッジ検出部46には、受信バッファ33を介して受信した受信データRxDが、エッジ検出ポートP3を介して取り込まれる。そして、受信データRxDにエッジが発生すると、その旨を保持するよう構成されている。本実施形態では、立ち上がりエッジを検出するよう構成されている。具体的には、図4に示すように、1バイトデータを受信終了する毎に立ち上がり検出状態がLレベルにリセットされ、その後、立ち上がりエッジが発生するとそれを検出して立ち上がり検出状態がHレベルとなる。以後、再びリセットされるまではHレベル状態が保持される。
The
ここで、例えば他のマイコンから所定のデータ(フレーム)が送信され、それをイモビECU30のマイコン31が受信するとき、フレームを構成する各1バイトデータの受信については上記説明した通りに行われるが、受信したデータに基づいてCPU41が実際に処理を行うのは、1フレーム分の1バイトデータを全て受信した後である。そのため、フレームの受信開始後、マイコン31においては、そのフレームを全て受信完了したこと、即ち通信ラインL1がアイドル状態になったことを判定する必要がある。
Here, for example, when predetermined data (frame) is transmitted from another microcomputer and is received by the
図17で説明した従来のマイコン100の場合は、既述の通り通信部104内に予めアイドル状態検出用のハードウェアであるアイドル検出部108を備えていたため、CPU41は、このアイドル検出部108の検出結果に基づいてアイドル状態になったか否かを容易に知ることができた。
In the case of the
しかし、本実施形態のマイコン11,21,31はいずれも、アイドル状態を検出するためのハードウェアを備えていないものである。そのため、このマイコン31を用いてシリアル通信を行うためには、ユーザ等が何らかの方法でアイドル状態の判定を行えるよう、ハード的又はソフト的な対策を行う必要がある。
However, none of the
そこで本実施形態では、マイコン31がはじめから備えている、エッジ検出部46やタイマ44等を利用して、ソフト的にアイドル状態の判定を行うようにしている。つまり、アイドル状態の判定を行うためのプログラムをROM42(例えばEEPROM等の電気的に書き換え可能なROM)に組み込むことで、CPU41がアイドル状態の判定を行うようにしている。
Therefore, in this embodiment, the
次に、本実施形態の車載シリアル通信システムの通信動作のうち、特にアイドル状態の判定動作について、図4に基づいて説明する。但し図4では、説明の簡略化のために、データギャップ時間がゼロの二つの1バイトデータからなる1フレームを受信する場合を例示している。 Next, among the communication operations of the in-vehicle serial communication system of the present embodiment, the idle state determination operation will be described with reference to FIG. However, in FIG. 4, for the sake of simplification of explanation, a case where one frame composed of two 1-byte data whose data gap time is zero is illustrated.
図4に示すように、一つ目の1バイトデータの受信が時刻t1にて終了すると、通信部45が受信割込処理要求W1を発生する。これを受けたCPU41は、エッジ検出部46における立ち上がりエッジ検出状態をリセットすると共に、タイマ44を所定の判定時間Tにセットする。その後、二つ目の1バイトデータを受信するが、本例では、スタートビットを含む最初の5ビットがLレベルであって6ビット目にHレベルとなり、立ち上がりエッジが発生する(時刻t2)。そのため、この時刻t2にて立ち上がりエッジ検出状態がHレベルとなる。
As shown in FIG. 4, when reception of the first 1-byte data ends at time t1, the
その後、タイマ44にセットされた判定時間Tが経過して時刻t3になると、タイマ44はタイマ割込処理要求W2を発生する。これを受けたCPU41は、そのときの立ち上がりエッジ検出状態をみて、Hレベルである(つまりタイマ計時期間中に立ち上がりエッジが発生した場合)か、又は、Lレベルであるものの通信ラインL1の論理レベル即ち受信データRxDの論理レベルがアクティブレベル(Lレベル)か、のいずれかに該当するならば、まだデータ受信中であると判定する。
Thereafter, when the determination time T set in the
そして、この2番目の1バイトデータが時刻t4にて受信終了すると、時刻t1の時と同様、再び受信割込処理要求W1によって、立ち上がりエッジ検出状態のリセット及びタイマ44のセットがなされる。その後、判定時間Tが経過して時刻t5になると、タイマ割込処理要求W2によってCPU41は立ち上がりエッジ検出状態をみるが、このとき、本例では既に当該フレームの受信が終わっているため、時刻t4以後は立ち上がりエッジは生じていない。しかも、通信ラインL1はインアクティブ状態(Hレベル)である。これにより、CPU41は、当該フレームの受信が完了して通信ラインL1がアイドル状態になっているものと判定し、受信完了フラグをONにする。
When the reception of the second 1-byte data is completed at time t4, the rising edge detection state is reset and the
次に、上記説明したアイドル状態の判定を実現するためにマイコン31で実行される処理について、図5及び図6に基づいて説明する。尚、図5及び図6に示す処理はいずれも、マイコン31のCPU41が実行するものであり、その各処理のプログラムはROM42に記憶されている。
Next, a process executed by the
まず図5は、CPU41が、通信部45によって受信割込処理要求W1が発生された時(つまり、通信部45の受信用レジスタに1バイトデータが受信された時であって、図4の例では時刻t1及び時刻t4)に実行を開始する受信割込処理を示すフローチャートである。
First, FIG. 5 shows a case where the
この受信割込処理が開始されると、まずステップ(以下「S」と略す)110にて、エッジ検出部46における立ち上がりエッジ検出状態を初期してLレベルとする。そして、S120にてタイマ44を判定時間Tにセットした後、続くS130にて、受信した1バイトデータに対する処理(例えば受信用バッファからRAM43への転送等)を行う。
When the reception interrupt process is started, first, in step (hereinafter abbreviated as “S”) 110, the rising edge detection state in the
なお、S120でタイマ44にセットする判定時間Tは、次の1バイトデータの受信開始時からその1バイトデータの受信終了時まで間でその判定時間Tが経過するような範囲内で適宜決めればよい。つまり、例えば図4の時刻t1でセットしたときに、次の1バイトデータの受信開始時刻(本例ではほぼ時刻t1)からその受信終了時刻t4までの間で判定時間Tが経過するようにすればよい。
Note that the determination time T set in the
本実施形態では、次の1バイトデータの略中心を狙ってタイマ44をセットするようにしているが、もちろんこれは一例であって、例えば1バイトデータの終了間際を狙って設定してもよい。但し、1バイトデータの受信終了間際にセットすると、タイマ割込処理によって受信割込処理が遅れるなどの影響が生じるおそれがある。そのため、好ましくは本例のように次の1バイトデータの略中心を狙ってタイマ44のセット(判定時間Tのセット)をするとよい。
In the present embodiment, the
次に図6は、タイマ割込処理を示すフローチャートである。このタイマ割込処理は、上記の受信割込処理(図5)のS120にてタイマ44にセットされた判定時間Tが経過したとき(図4の例では時刻t3及び時刻t5)にタイマ44が発生するタイマ割込処理要求W2をCPU41が受けたときに、CPU41により実行が開始される。
Next, FIG. 6 is a flowchart showing the timer interrupt process. This timer interrupt process is performed when the determination time T set in the
このタイマ割込処理が開始されると、まずS210にて、エッジ検出部46における立ち上がりエッジ検出状態をみる。このとき、立ち上がりエッジが検出されていれば、そのままこの割込処理を終了するが、検出されていない場合は、S220に進む。S220では、通信ラインL1の論理レベルがLレベルであるか否か判断し、Lレベルであれば、データ受信中と判断してそのままこの割込処理を終了するが、Hレベルならば、S230に進む。
When this timer interruption process is started, first, in S210, the rising edge detection state in the
S230に進んだ場合は、上記判定時間Tの間に立ち上がりエッジが一切検出されず、しかもその判定時間T経過時に通信ラインL1がインアクティブ状態であることから、データ(フレーム)の受信が完了してアイドル状態になっているものと判断して、受信完了フラグをセットする。そして、続くS240にて、受信完了処理(受信したフレームに基づく各種処理)及び送信準備処理などを行う。 When the process proceeds to S230, no rising edge is detected during the determination time T, and since the communication line L1 is inactive when the determination time T has elapsed, reception of data (frame) is completed. The reception completion flag is set by determining that the idle state is established. In subsequent S240, reception completion processing (various processing based on the received frame), transmission preparation processing, and the like are performed.
以上説明したように、本実施形態の車載シリアル通信システムでは、シリアル通信制御用の各マイコン11,21,31が、1バイトデータの受信を終了する毎に受信割込処理を実行してタイマ44を判定時間Tにセットし、その判定時間T経過後にタイマ割込処理によってアイドル状態であるか否かの判定を行う。そして、その判定は、まず判定時間Tの間に立ち上がりエッジが発生したか否かを判定し、発生しなかった場合はさらに通信ラインL1の論理レベルを見ることにより行う。
As described above, in the in-vehicle serial communication system according to the present embodiment, each of the
そのため、本実施形態の車載シリアル通信システムによれば、アイドル状態を検出するためのハードウェアを備えていないマイコンであっても、マイコンが備えているエッジ検出部46やタイマ44等の機能を利用してソフト的にアイドル状態の判定を行うことができ、シリアル通信を正常に行うことができる。
Therefore, according to the in-vehicle serial communication system of the present embodiment, even if the microcomputer does not have hardware for detecting the idle state, the functions such as the
また、1バイトデータを受信終了した時から判定時間Tが経過するまでの間の立ち上がりエッジの有無を検出するようにし、次の1バイトデータの中心付近で判定時間Tが経過するようにタイマ44をセットしており、しかも判定時間T経過時の通信ラインL1の論理レベルをもアイドル状態の判定材料としているため、データ受信中であれば確実にその旨を検出することができ、受信終了後は確実にアイドル状態であることを判定できる。
In addition, the presence or absence of a rising edge from the end of reception of 1-byte data until the determination time T elapses is detected, and the
ここで、本実施形態の構成要素と本発明の構成要素の対応関係を明らかにする。本実施形態において、各マイコン11,21,31はいずれも本発明の通信装置に相当し、エッジ検出部46は本発明のエッジ検出手段及び検出状態保持手段に相当し、CPU41は本発明(請求項3)のアイドル判定手段に相当し、タイマ44は本発明(請求項4)の計時手段に相当する。
Here, the correspondence between the components of the present embodiment and the components of the present invention will be clarified. In the present embodiment, each of the
また、図5の受信割込処理において、S110の処理は本発明の検出状態初期化部が実行する処理に相当し、S120の処理は本発明の計時開始部が実行する処理に相当する。また、図6のタイマ割込処理において、S210の処理は本発明のエッジ判定部が実行する処理に相当し、S220の処理は本発明のレベル判定部が実行する処理に相当する。 In the reception interrupt process of FIG. 5, the process of S110 corresponds to the process executed by the detection state initialization unit of the present invention, and the process of S120 corresponds to the process executed by the time measurement starting unit of the present invention. In the timer interrupt process of FIG. 6, the process of S210 corresponds to the process executed by the edge determination unit of the present invention, and the process of S220 corresponds to the process executed by the level determination unit of the present invention.
[第2実施形態]
上記第1実施形態では、マイコン31が備える立ち上がりエッジ検出機能(エッジ検出部46)をアイドル状態の判定に利用する例について説明したが、マイコンの種類によっては、データ受信中であるか否かをハード的に判定する機能(以下「受信中判定機能」という)を備えたものもある。そこで本実施形態では、上記のように受信中判定機能を備えたマイコンにおいて、その機能を利用してアイドル状態の判定を行うようにしている。以下詳しく説明する。
[Second Embodiment]
In the first embodiment, the example in which the rising edge detection function (edge detection unit 46) provided in the
図7に、本実施形態のマイコン50の概略構成を示す。本実施形態のマイコン50も、図2に示したマイコン31と同様、図1の車載シリアル通信システムを構成するツール10及び各ECU20,30においてシリアル通信を制御するために設けられるものであり、通信部53を除けば、ハード構成は基本的に図2のマイコン31と同じである。そのため、図2のマイコンと同じ構成要素には同じ符号を付し、その説明を省略する。尚、本実施形態のマイコン50も、図2のマイコン31と同じくエッジ検出部46を備えているものの、アイドル状態の判定に関与しないため、本実施形態では図示を省略している。
FIG. 7 shows a schematic configuration of the
そして、マイコン50が備える通信部53が図2の通信部45と異なる点は、受信中判定部54によって上記受信中判定機能がハード的に実現されていることである。CPU51は、この受信中判定部54の判定内容をみることによって、データ(1バイトデータ)の受信中であるか否か判断することができる。具体的には、図8(詳細は後述)に示すように、1バイトデータのスタートビットを検出したときに受信中フラグがセットされ、ストップビットを検出して1バイトデータの受信を終了したときに受信中フラグがクリアされる。
The
そして、本実施形態では、上記のようにマイコン50がはじめから備えている、タイマ44や受信中判定部54等を利用して、ソフト的にアイドル状態の判定を行うようにしている。つまり、アイドル状態の判定を行うためのプログラムをROM52に組み込むことで、CPU51がアイドル状態の判定を行うようにしている。
In the present embodiment, the
次に、本実施形態の車載シリアル通信システムの通信動作のうち、特にアイドル状態の判定動作について、図8に基づいて説明する。図8も、第1実施形態の図4と同様、説明の簡略化のために、データギャップ時間がゼロの二つの1バイトデータからなる1フレームを受信する場合を例示している。 Next, among the communication operations of the in-vehicle serial communication system according to the present embodiment, an idle state determination operation will be described with reference to FIG. FIG. 8 also illustrates a case where one frame made up of two 1-byte data with a data gap time of zero is received for the sake of simplicity, as in FIG. 4 of the first embodiment.
図8に示すように、一つ目の1バイトデータの受信が始まると、時刻t1にて受信中フラグがセットされる。そして、この1バイトデータが終了すると、受信中フラグがクリアされると共に、通信部53が受信割込処理要求W1を発生する。これを受けたCPU51は、タイマ44を所定の判定時間Tにセットする。
As shown in FIG. 8, when reception of the first 1-byte data starts, a receiving flag is set at time t1. When this 1-byte data is completed, the receiving flag is cleared and the
その後、二つ目の1バイトデータを受信するため、時刻t3にて受信中フラグが再びセットされる。そして、タイマ44にセットされた判定時間Tが経過して時刻t4になると、タイマ44はタイマ割込処理要求W2を発生する。これを受けたCPU51は、受信中フラグの状態をみて、受信中であるか否かを判断する。ここで、時刻t4では受信中フラグがセットされているため、まだ受信中であると判断する。
Thereafter, in order to receive the second 1-byte data, the receiving flag is set again at time t3. When the determination time T set in the
そして、この2番目の1バイトデータが時刻t5にて受信終了すると、時刻t2の時と同様、受信中フラグがクリアされると共に、受信割込処理要求W1によってタイマ44がセットされる。その後、判定時間Tが経過して時刻t6になると、タイマ割込処理要求W2によってCPU51は受信中フラグをみるが、このとき、データは受信されておらずフラグはクリアされた状態である。そのため、CPU51は、当該フレームの受信が完了して通信ラインL1がアイドル状態になっているものと判定し、受信完了フラグをONにする。
When the reception of the second 1-byte data is completed at time t5, the receiving flag is cleared and the
次に、上記説明したアイドル状態の判定を実現するためにマイコン50で実行される処理について、図9及び図10に基づいて説明する。尚、図9及び図10に示す処理はいずれも、マイコン50のCPU51が実行するものであり、その各処理のプログラムはROM52に記憶されている。
Next, processing executed by the
まず図9は、CPU51が、通信部53によって受信割込処理要求W1が発生された時(つまり、通信部53の受信用レジスタに1バイトデータが受信された時であって、図8の例では時刻t2及び時刻t5)に実行を開始する受信割込処理を示すフローチャートである。
First, FIG. 9 shows a case where the
この受信割込処理が開始されると、まずS310にて、タイマ44を判定時間Tにセットする。そして、続くS320にて、受信した1バイトデータに対する処理(例えば受信用バッファからRAM43への転送等)を行う。なお、S310でタイマ44にセットする判定時間Tは第1実施形態と同様である。
When this reception interrupt process is started, first, the
次に図10は、タイマ割込処理を示すフローチャートである。このタイマ割込処理は、上記の受信割込処理(図9)のS310にてタイマ44にセットされた判定時間Tが経過したとき(図8の例では時刻t4及び時刻t6)にタイマ44が発生するタイマ割込処理要求W2をCPU51が受けたときに、CPU51により実行が開始される。
Next, FIG. 10 is a flowchart showing the timer interrupt process. This timer interrupt process is performed when the determination time T set in the
このタイマ割込処理が開始されると、まずS410にて、受信中フラグがセットされているか否か、即ち、1バイトデータの受信中であるか否かを判断する。このとき、受信中フラグがセットされていれば、そのままこの割込処理を終了するが、セットされていない場合は、データ(フレーム)の受信が完了してアイドル状態になっているものと判断して、S420に進み、受信完了フラグをセットする。そして、続くS430にて、受信完了処理及び送信準備処理などを行う。 When this timer interrupt process is started, first, in S410, it is determined whether or not a receiving flag is set, that is, whether or not 1-byte data is being received. At this time, if the receiving flag is set, the interrupt processing is terminated as it is, but if it is not set, it is determined that the reception of data (frame) is completed and the idle state is set. In S420, the reception completion flag is set. In subsequent S430, reception completion processing, transmission preparation processing, and the like are performed.
以上説明したように、本実施形態では、車載シリアル通信システムを構成するシリアル通信制御用のマイコン50が、1バイトデータの受信を終了する毎に受信割込処理を実行してタイマ44を判定時間Tにセットし、その判定時間T経過後にタイマ割込処理によってアイドル状態であるか否かの判定を行う。その判定は、判定時間Tが経過した時の受信中フラグをみることにより行う。
As described above, in this embodiment, the serial
そのため、本実施形態の車載シリアル通信システムによれば、アイドル状態を検出するためのハードウェアを備えていないマイコンであっても、マイコンが備えている受信中判定機能(受信中判定部54)等を利用してソフト的にアイドル状態の判定を行うことができ、シリアル通信を正常に行うことができる。 Therefore, according to the in-vehicle serial communication system of the present embodiment, even if the microcomputer does not have hardware for detecting the idle state, the receiving determination function (receiving determination unit 54) included in the microcomputer, etc. Can be used to determine the idle state in software, and serial communication can be performed normally.
しかも、判定時間が経過した時の受信のみに基づいてアイドル状態の判定を行うようにしているため、処理負荷のより軽減されたアイドル状態判定が可能となる。 In addition, since the idle state is determined based only on reception when the determination time has elapsed, it is possible to determine the idle state with a reduced processing load .
[第3実施形態]
上記第1実施形態では、1バイトデータ受信終了時に発生する受信割込処理要求W1を受けてCPU41が受信割込処理を実行し、これにより立ち上がりエッジ検出状態のリセット及びタイマ44のセットを行うようにした。しかし、受信割込処理は受信割込処理要求W1を受けたときに即実行できるとは限らず、所定の割込待ち時間の経過後に実行が開始されるおそれもある。このような割込待ち時間等によって受信割込処理の開始が遅れると、既に次の1バイトデータの受信が始まっているにも拘わらず受信割込処理がまだ実行されないことになり、受信割込処理が開始されるまでの立ち上がりエッジを検出できずにアイドル状態の判定を誤るおそれがある。
[Third Embodiment]
In the first embodiment, the
この問題は、通信速度がより高速になるほど生じるおそれが大きくなり、非常に高速な通信になると、場合によっては、次の1バイトデータのうち既に数ビットが受信された時点で、その前の1バイトデータに対する受信割込処理が開始されるということも起こりうる。 This problem is more likely to occur as the communication speed becomes higher, and in the case of very high speed communication, in some cases, when several bits of the next one-byte data are already received, the previous 1 It is possible that reception interrupt processing for byte data is started.
そこで、本実施形態では、通信速度が高速になってもアイドル状態の判定を安定して正確に行うことができるよう、1バイトデータの受信終了時刻を正確に算出し、その受信終了時刻における受信状態(受信処理待ち状態)をみることによって、アイドル状態の判定を行うようにしている。以下、詳しく説明する。 Therefore, in the present embodiment, the reception end time of 1-byte data is accurately calculated and received at the reception end time so that the idle state can be determined stably and accurately even when the communication speed becomes high. The idle state is determined by checking the state (waiting for reception processing). This will be described in detail below.
図11に、本実施形態のマイコン60の概略構成を示す。本実施形態のマイコン60も、図2に示したマイコン31と同様、図1の車載シリアル通信システムを構成するツール10及び各ECU20,30においてシリアル通信を制御するために設けられるものであり、タイマ63の構成及びインプットキャプチャモジュール72を備えていることを除けば、ハード構成は基本的に図2のマイコン31と同じである。そのため、図2のマイコンと同じ構成要素には同じ符号を付し、その説明を省略する。尚、本実施形態では、エッジ検出部46にて立ち上がりが検出されると立ち上がりエッジ割込処理要求W3が発生する。
FIG. 11 shows a schematic configuration of the
本実施形態のマイコン60が備えるタイマ63は、当該マイコンの内部クロックによって常時カウントアップされるフリーランカウンタ(以下「FRC」という)71と、後述するCPU61の演算によって得られる時刻情報がCPU61によりセットされるアウトプットコンペアレジスタ(以下「OCR」という)74と、FRC71のカウント値である現在時刻とOCR74にセットされた時刻情報とを比較し、両者が一致したときにタイマ割込処理要求W2を発生する比較器75とを備えている。尚、本実施形態において「時刻」とは、FRC71のカウント値をいう。
In the
また、本実施形態のマイコン60は、受信データRxDの立ち上がりエッジを検出してその検出時のFRC71の値を記憶するインプットキャプチャモジュール(以下「ICM」という)72を備えている。即ち、受信バッファ33を介して入力される受信データRxDは、データ入力ポートP2及びエッジ検出ポートP3のほか、インプットキャプチャ入力ポートP4を介してICM72にも入力される。そして、ICM72は、立ち上がりエッジを検出すると、その検出時のFRC71の値をインプットキャプチャレジスタ(以下「ICR」という)73に記憶する。このICR73の値は、立ち上がりエッジが検出される毎に更新される。そのため、ICR73には、常に最新の立ち上がりエッジ検出時刻が記憶されていることになる。
Further, the
そして、本実施形態では、上記のようにマイコン60がはじめから備えている、タイマ63やICM72、エッジ検出部46等を利用して、ソフト的にアイドル状態の判定を行う尾運している。つまり、アイドル状態の判定を行うためのプログラムをROM62に組み込むことで、CPU60がアイドル状態の判定を行うようにしている。
In the present embodiment, as described above, using the
次に、本実施形態の車載シリアル通信システムの通信動作のうち、特にアイドル状態の判定動作について、図12に基づいて説明する。図12も、第1実施形態の図4と同様、説明の簡略化のために、データギャップ時間がゼロの二つの1バイトデータからなる1フレームを受信する場合を例示している。 Next, among the communication operations of the in-vehicle serial communication system according to the present embodiment, an idle state determination operation will be described with reference to FIG. Similarly to FIG. 4 of the first embodiment, FIG. 12 exemplifies a case where one frame composed of two 1-byte data having a data gap time of zero is received for the sake of simplicity.
図12に示すように、一つ目の1バイトデータの受信が始まると、ICM72にて立ち上がりエッジが検出される毎に、その検出時刻(FRC71の値)がICR73に記憶される。具体的には、時刻t1,t2,t3にFRC71の値がICR72に取り込まれ記憶される。そして、この1バイトデータの受信が終了した時に、ICR73に記憶されている時刻(つまり時刻t3)と、その時刻t3から受信終了時までのビット長(ここでは1ビット分の時間)とに基づいて、受信終了時刻t4を算出する。
As shown in FIG. 12, when reception of the first 1-byte data starts, every time a rising edge is detected by the
尚、受信終了時に割込処理等によってFRC71の値を取り込むことによっても、受信終了時刻を得ることが可能ではあるが、既述のように受信終了と同時に割込処理を開始してすぐにFRC71の値を取り込むのは非常に困難である。そのため、割込処理によって得られる時刻は、程度の差こそあれ、実際に受信終了した時刻より遅れた時刻となる。そこで本実施形態では、ICR73に記憶されている正確なエッジ検出時刻に、そのエッジ検出時刻から受信終了時までのビット長を加えることにより、正確な受信終了時刻を得るようにしている。このときICR73に記憶されている時刻t3は、言い換えれば、受信終了前における最後に立ち上がりエッジが検出されたときの時刻である。
Although it is possible to obtain the reception end time by fetching the value of the
そして、算出した正確な受信終了時刻t4に対し、更に、1バイトデータ長に対応した時間(つまり10ビット分の時間)を加えることにより、次に1バイトデータを受信したならばその1バイトデータの受信がちょうど終了するであろう次回受信終了時刻(NextTime1)を得る。そして、得られた次回受信終了時刻NextTime1をOCR74にセットする。
Then, by adding a time corresponding to the 1- byte data length (that is, a time corresponding to 10 bits) to the calculated accurate reception end time t4, if 1- byte data is received next, the 1- byte data Next reception end time (NextTime1) is obtained, which will just end reception. Then, the next reception
そして、次の1バイトデータについても、立ち上がりエッジが検出されるたびにその検出時刻がICR73に記憶される。一方、比較器75では、OCR74にセットされている次回受信終了時刻NextTime1と、周期的にカウントアップされるFRC71の値とが比較されており、当該1バイトデータの受信の終了とほぼ同じタイミング(時刻t8)で、両者の差が0となってタイマ割込処理要求W2が発生する。勿論、受信終了によって受信割込処理要求W1も発生する。そして、各割込処理要求W1,W2が発生すると、それぞれ割込処理待ちであることを示すフラグ(受信割込待ちフラグ及びタイマ割込待ちフラグ)をセットする。
As for the next 1- byte data, the detection time is stored in the
CPU61は、ほぼ同時に発生する受信割込処理要求W1とタイマ割込処理要求W2のうち、まず先に受けた要求に対してその割込処理を実行する。即ち、例えば受信割込処理要求W1がわずかながら早かった場合は、受信割込処理から実行することになり、その間、タイマ割込処理は待ちの状態となる。
The
そして、タイマ割込処理が先に行われる場合は、その割込処理の中で受信割込待ち中か否かを判断して、受信割込待ち中ならば、そのタイマ割込処理を終了して受信割込処理を実行する。一方、受信割込処理においては、上述した時刻t4の時の処理と同様、受信終了した時刻を算出すると共に、その算出した受信終了時刻を元に次回受信終了時刻NextTime2を算出してOCR74に設定し、タイマ割込待ちフラグをクリアする。
If timer interrupt processing is performed first, it is determined whether or not reception interrupt is waiting in the interrupt processing, and if it is waiting for reception interrupt, the timer interrupt processing is terminated. Receive interrupt processing. On the other hand, in the reception interrupt process, similar to the process at time t4 described above, the reception end time is calculated, and the next reception end time NextTime2 is calculated based on the calculated reception end time and set in the
その後、時刻t9(=NextTime2)になると、タイマ割込処理が実行されるが、このとき、既にデータ受信は終了していて受信割込待ちフラグはセットされていないため、アイドル状態と判定して受信完了フラグをセットする。 After that, at time t9 (= NextTime2), timer interrupt processing is executed. At this time, since data reception has already been completed and the reception interrupt wait flag has not been set, it is determined to be in an idle state. Set the reception completion flag.
つまり、受信割込処理が先に実行される場合は、次回受信終了時刻NextTimeの算出及びOCR74へのセットが行われてタイマ割込処理は行われない。逆に、タイマ割込処理が先に実行される場合、受信割込待ち中ならば受信割込処理に移行するが、受信割込待ち中でなければ、アイドル状態と判定するのである。
That is, when the reception interrupt process is executed first, the next reception end time NextTime is calculated and set in the
次に、上記説明したアイドル状態の判定を実現するためにマイコン60で実行される処理について、図13〜図15に基づいて説明する。尚、図13〜15に示す処理はいずれも、マイコン60のCPU61が実行するものであり、その各処理のプログラムはROM62に記憶されている。
Next, processing executed by the
まず図13は、エッジ検出部46により立ち上がりエッジが検出されたときに発生する立ち上がりエッジ割込処理要求W3によってCPU61が実行する、立ち上がりエッジ割込処理を示すフローチャートである。この処理が開始されると、S610にて、変数「INTTIME」として、ICR73に取り込まれている時刻をRAM43に設定する。立ち上がりエッジが発生したときは、ICM72においてもその検出時刻がICR73に取り込まれる。要するに、立ち上がりエッジが検出されるたびに、その検出された正確な時刻であるICR73の値が、立ち上がりエッジ割込処理によってRAM43に格納されるわけである。
First, FIG. 13 is a flowchart showing a rising edge interrupt process executed by the
次に図14は、CPU61が、通信部45によって受信割込処理要求W1が発生された時(図12の例では時刻t4及び時刻t8)に実行を開始する受信割込処理を示すフローチャートである。但し、タイマ割込処理(図15)が実行中のときは割込処理待ち状態となって、タイマ割込処理終了後に実行が開始される。
Next, FIG. 14 is a flowchart showing a reception interrupt process that is started when the
この受信割込処理が開始されると、まずS510にて、受信した1バイトデータを取得する。そしてS520で、その取得した1バイトデータのビット列に基づき、最上位ビットから連続して並んでいる「1」(Hレベルビット)の数を変数「N」に設定する。例えば、図12における最初の1バイトデータは、「01100010」となっている。そのため、最上位ビットから連続して並んでいる「1」の数はゼロであり、その場合はN=0に設定する。次の1バイトデータの場合は「11101011」となっているため、N=3に設定する。 When this reception interrupt process is started, first, the received 1-byte data is acquired in S510. In S520, the number of “1” s (H level bits) continuously arranged from the most significant bit is set in the variable “N” based on the acquired bit string of 1-byte data. For example, the first 1-byte data in FIG. 12 is “01100010”. Therefore, the number of “1” s continuously arranged from the most significant bit is zero, and in this case, N = 0 is set. In the case of the next 1-byte data, “11101111” is set, so N = 3 is set.
このように「N」を設定した後は、S530にて受信終了時刻を算出する。具体的には、N+1、即ちその最後の立ち上がりエッジから受信終了時までのビット数に、1ビット分の時間を積算することにより、その最後の立ち上がりエッジから受信終了時までの時間を得る。さらにその得られた時間を、「INTTIME」の値、即ち受信終了前における最後の立ち上がりエッジ検出時刻に加算することにより、受信終了時刻が得られる。 After setting “N” in this way, the reception end time is calculated in S530. Specifically, the time from the last rising edge to the end of reception is obtained by adding the time for one bit to N + 1, that is, the number of bits from the last rising edge to the end of reception. Further, the reception end time is obtained by adding the obtained time to the value of “INTTIME”, that is, the last rising edge detection time before the end of reception.
図12で説明すれば、例えば最初の1バイトデータ受信終了時における時刻t4の算出は、その直前における立ち上がりエッジ検出時刻t3に、その後のビット数(1ビット)分の時間を加算することにより行われる。また、次の1バイトデータ受信終了時における時刻t8の算出は、その直前における立ち上がりエッジ検出時刻t7と、その後のビット数(4ビット)分の時間を加算することにより行われる。 Referring to FIG. 12, for example, the calculation of the time t4 at the end of the reception of the first 1- byte data is performed by adding the subsequent number of bits (1 bit) to the rising edge detection time t3 immediately before that. Is called. Also, the calculation of the time t8 at the end of reception of the next 1- byte data is performed by adding the rising edge detection time t7 immediately before that and the time corresponding to the number of bits (4 bits) thereafter.
S540では、上記S530にて算出された受信終了時刻に10ビット分の時間(つまり1バイトデータの時間)を加算することにより、次回受信終了時刻NextTimeを算出する。この次回受信終了時刻NextTimeは本発明のアイドル判定時刻に相当するものである。これにより、例えば図12における時刻t4の受信割込処理では、次回受信終了時刻NextTime1が算出されることになり、時刻t8の受信割込処理では、次回受信終了時刻NextTime2が算出されることになる。 In S540, the next reception end time NextTime is calculated by adding the time of 10 bits (that is, the time of 1-byte data) to the reception end time calculated in S530. This next reception end time NextTime corresponds to the idle determination time of the present invention. Thus, for example, in the reception interrupt process at time t4 in FIG. 12, the next reception end time NextTime1 is calculated, and in the reception interrupt process at time t8, the next reception end time NextTime2 is calculated. .
このようにして次回受信終了時刻NextTimeを算出した後は、S550に進み、タイマ割込待ちフラグがセット中であるか否か判断する。そして、セットされていなければそのままS570へ進み、セット中ならばS560にてそのフラグをクリアした後、S570へ進む。そしてS570で、S540で算出した次回受信終了時刻NextTimeをOCR74にセットし、続くS580にて受信割込待ちフラグをクリアして、この受信割込処理を終了する。
After calculating the next reception end time NextTime in this way, the process proceeds to S550, and it is determined whether or not the timer interruption waiting flag is being set. If it is not set, the process proceeds to S570 as it is. If it is being set, the flag is cleared in S560, and then the process proceeds to S570. In step S570, the next reception end time NextTime calculated in step S540 is set in the
次に図15は、タイマ割込処理を示すフローチャートである。このタイマ割込処理は、FRC71の値が上記の受信割込処理(図14)のS570でOCR74にセットされた時刻に一致したときに比較器75が発生するタイマ割込処理要求W2を、CPU61が受けたときに、CPU61により実行が開始される。但し、受信割込処理(図14)が実行中のときは割込処理待ち状態となって、受信割込処理終了後に実行が開始される。
Next, FIG. 15 is a flowchart showing the timer interrupt process. In this timer interrupt process, a timer interrupt process request W2 generated by the
このタイマ割込処理が開始されると、まずS710にて、受信割込待ちフラグがセットされているか否かを判断する。上記の如く、受信割込処理要求W1とタイマ割込処理要求W2はほぼ同時に発生するため、仮にわずかの差でタイマ割込処理が先に実行された場合であっても、このS710の処理が行われるときには既に受信割込待ちフラグがセットされた状態にある。そのため、データ受信中である限り、このS710では肯定判定されてS740へ進み、タイマ割込待ちフラグをクリアしてこのタイマ割込処理を終了することになる。 When this timer interrupt process is started, it is first determined in S710 whether or not a reception interrupt wait flag is set. As described above, the reception interrupt processing request W1 and the timer interrupt processing request W2 are generated almost simultaneously. Therefore, even if the timer interrupt processing is executed first with a slight difference, the processing of S710 is performed. When it is performed, the reception interrupt waiting flag is already set. Therefore, as long as data is being received, an affirmative determination is made in S710 and the process proceeds to S740, where the timer interrupt wait flag is cleared and the timer interrupt process is terminated.
一方、フレーム受信を完了した後の場合(例えば図12の時刻t9)、受信割込待ちフラグはクリアされているため、アイドル状態と判定してS720に進み、受信完了フラグをセットする。そして、続くS730にて受信完了処理及び送信準備処理を実行した後、S740に進む。 On the other hand, when the frame reception is completed (for example, at time t9 in FIG. 12), since the reception interrupt waiting flag is cleared, it is determined as an idle state and the process proceeds to S720 to set the reception completion flag. Then, after the reception completion process and the transmission preparation process are executed in S730, the process proceeds to S740.
以上説明したように、本実施形態では、車載シリアル通信システムを構成するシリアル通信制御用のマイコン60が、1バイトデータの受信を終了する毎に受信割込処理を実行して、その受信終了時刻を正確に算出し、延いては次の1バイトデータの受信終了時刻である次回受信終了時刻NextTimeを算出してOCR74にセットする。そして、そのセットした次回受信終了時刻NextTimeとなったときに受信割込待ちフラグがセットされているか否かによって、アイドル状態の判定を行う。
As described above, in this embodiment, the serial
そのため、本実施形態の車載シリアル通信システムによれば、アイドル状態を検出するためのハードウェアを備えていないマイコンであっても、マイコンが備えているインプットキャプチャ機能(ICM72)やアウトプットコンペア機能(タイマ63)等を利用してソフト的にアイドル状態の判定を行うことができ、シリアル通信を正常に行うことができる。 Therefore, according to the in-vehicle serial communication system of this embodiment, even if the microcomputer does not have hardware for detecting an idle state, the input capture function (ICM72) and output compare function ( The idle state can be determined by software using the timer 63) and the like, and serial communication can be normally performed.
ここで、本実施形態の構成要素と本発明の構成要素の対応関係を明らかにする。本実施形態において、ICM72は本発明のエッジ時刻記憶手段に相当し、CPU61は本発明のアイドル判定手段に相当し、タイマ63は本発明の計時手段に相当する。また、図14の受信割込処理において、S520及びS530の処理はいずれも本発明の第1時刻算出手段が実行する処理に相当し、S540の処理は本発明の第2時刻算出手段が実行する処理に相当し、S570の処理は本発明の時刻設定部が実行する処理に相当する。また、図15のタイマ割込処理において、S710の処理は本発明の受信判定部が実行する処理に相当する。
Here, the correspondence between the components of the present embodiment and the components of the present invention will be clarified. In this embodiment, the
尚、本発明の実施の形態は、上記実施形態に何ら限定されるものではなく、本発明の技術的範囲に属する限り種々の形態を採り得ることはいうまでもない。
例えば、上記第1実施形態及び第3実施形態においてエッジ検出を行う際の、検出対象のエッジは、立ち上がりエッジとしたが、これに限るものではなく、例えば立ち下がりエッジとしてもよい。但し、アイドル状態の判定をより確実に行うためには、立ち上がりエッジにするのが好ましい。
The embodiment of the present invention is not limited to the above-described embodiment, and it goes without saying that various forms can be adopted as long as it belongs to the technical scope of the present invention.
For example, the edge to be detected when performing edge detection in the first embodiment and the third embodiment is a rising edge, but is not limited thereto, and may be a falling edge, for example. However, in order to more reliably determine the idle state, it is preferable to use a rising edge.
また、上記各実施形態では、1バイトデータが10ビットからなるものであって、その1バイトデータが複数連続して送受信されるものとして説明したが、1バイトデータを構成するビット数は10ビット以外でもよく、また、その1バイトデータが所定間隔で送受されるものであってもよい。 In each of the above embodiments, one byte data is composed of 10 bits, and a plurality of one byte data are continuously transmitted and received. However, the number of bits constituting one byte data is 10 bits. In addition, the 1-byte data may be transmitted and received at a predetermined interval.
更に、上記各実施形態では、3つのECU相互間でシリアルデータを送受信する場合を例に挙げて説明したが、いうまでもなく、通信ラインL1に接続されるECUの数(詳細にはシリアル通信を制御するマイコンの数)やその種類等は特に限定されない。 Further, in each of the above embodiments, the case where serial data is transmitted and received between three ECUs has been described as an example, but it goes without saying that the number of ECUs connected to the communication line L1 (specifically, serial communication) The number of microcomputers that control the above and the type thereof are not particularly limited.
10・・・ツール、11,21,31,50,60,100・・・マイコン、12,22,32・・・送信バッファ、13,23,33・・・受信バッファ、20・・・エンジンECU、30・・・イモビECU、41,51,61・・・CPU、42,52,62・・・ROM、43・・・RAM、44,63・・・タイマ、45,53・・・通信部、46・・・エッジ検出部、47,56,64・・・バス、54・・・受信中判定部、71・・・フリーランカウンタ(FRC)、72・・・インプットキャプチャモジュール(ICM)、73・・・インプットキャプチャレジスタ(ICR)、74・・・アウトプットコンペアレジスタ(OCR)、75・・・比較器、108・・・アイドル検出部、L1・・・通信ライン、P1・・・データ出力ポート、P2・・・データ入力ポート、P3・・・エッジ検出ポート、P4・・・インプットキャプチャ入力ポート
DESCRIPTION OF
Claims (10)
前記通信装置は、前記シリアルデータの受信開始後、所定のタイミング毎に、該タイミングから所定の判定時間が経過するまでの間に受信データのエッジが検出されたか否かを判定し、該判定時間が経過するまでの間に前記エッジが検出されなかった場合であって、且つ、該判定時間経過時の前記通信ラインの論理レベルがアクティブレベルではない場合に、前記通信ラインがアイドル状態であると判定する
ことを特徴とするシリアル通信方法。 A serial communication method for transmitting and receiving serial data between a plurality of communication devices connected via a communication line,
The communication device determines whether or not an edge of the received data is detected at a predetermined timing after the start of reception of the serial data until a predetermined determination time elapses from the timing. If the edge is not detected before the time elapses, and the logic level of the communication line is not an active level when the determination time has elapsed, the communication line is in an idle state. A serial communication method characterized by determining.
前記シリアルデータは、所定ビット数のデータを単位データとして、複数の前記単位データからなるデータフレームとして構成されており、さらに、前記単位データの受信終了時から次の単位データの受信開始時までの時間をデータギャップ時間として、
前記通信装置は、
受信データのエッジを検出する毎に該検出時刻を記憶しておき、
前記単位データを受信する毎に、該受信の終了時直前に検出された前記エッジの検出時刻と、該エッジから該単位データ受信終了時までの受信ビット数とに基づいて、該単位データの受信終了時刻を算出し、
該受信終了時刻に、少なくとも、前記データギャップ時間及び前記単位データのデータ長に対応した時間を加えた時刻を、アイドル判定時刻として設定し、
前記受信終了時刻から前記アイドル判定時刻までの間に前記単位データを受信しなかった場合に、前記通信ラインがアイドル状態であると判定する
ことを特徴とするシリアル通信方法。 A serial communication method for transmitting and receiving serial data between a plurality of communication devices connected via a communication line,
The serial data is configured as a data frame composed of a plurality of the unit data, with data having a predetermined number of bits as unit data, and further, from the end of reception of the unit data to the start of reception of the next unit data. Time as data gap time
The communication device
Each time an edge of received data is detected, the detection time is stored,
Each time the unit data is received, the reception of the unit data is performed based on the detection time of the edge detected immediately before the end of the reception and the number of received bits from the edge to the end of the reception of the unit data. Calculate end time,
A time obtained by adding at least the time corresponding to the data gap time and the data length of the unit data to the reception end time is set as an idle determination time,
A serial communication method comprising: determining that the communication line is in an idle state when the unit data is not received between the reception end time and the idle determination time .
前記通信ラインを介して受信したデータのエッジを検出するエッジ検出手段と、 Edge detection means for detecting an edge of data received via the communication line;
前記シリアルデータの受信開始後、所定のタイミング毎に動作するよう構成され、該タイミングから予め設定した判定時間が経過するまでの間に前記エッジ検出手段によってエッジが検出されなかった場合であって、且つ、該判定時間経過時の前記通信ラインの論理レベルがアクティブレベルではない場合に、前記通信ラインがアイドル状態であると判定するアイドル判定手段と、 It is configured to operate every predetermined timing after the reception of the serial data, and when the edge is not detected by the edge detection means until a predetermined determination time elapses from the timing, And an idle determination means for determining that the communication line is in an idle state when the logical level of the communication line is not an active level when the determination time has elapsed,
を備えていることを特徴とする通信装置。 A communication apparatus comprising:
前記判定時間を計時するための計時手段と、 A timing means for timing the determination time;
前記エッジ検出手段によりエッジが検出されたとき、該検出された旨の情報を保持する検出状態保持手段と、 When an edge is detected by the edge detection means, detection state holding means for holding information indicating that the edge has been detected;
を備え、 With
前記アイドル判定手段は、 The idle determination means includes
前記タイミング毎に、前記計時手段による前記判定時間の計時を開始させる計時開始部と、 For each of the timings, a timing start unit that starts timing of the determination time by the timing means,
前記タイミング毎に、前記検出状態保持手段を初期化する検出状態初期化部と、 A detection state initialization unit that initializes the detection state holding means at each timing;
前記計時手段による計時終了時の前記検出状態保持手段に保持されている情報に基づいて、前記判定時間中にエッジが検出されたか否かを判定するエッジ判定部と、 An edge determination unit that determines whether or not an edge is detected during the determination time based on information held in the detection state holding unit at the end of timing by the timing unit;
前記計時手段による計時終了時の前記通信ラインの論理レベルを判定するレベル判定部と、 A level determination unit that determines a logical level of the communication line at the time of completion of timing by the timing unit;
を備えていることを特徴とする通信装置。 A communication apparatus comprising:
前記シリアルデータは、所定ビット数のデータを単位データとして、複数の前記単位データからなるデータフレームとして構成されており、
前記タイミングは、前記各単位データの受信終了時である
ことを特徴とする通信装置。 The communication device according to claim 3 or 4 ,
The serial data is configured as a data frame composed of a plurality of the unit data, with data having a predetermined number of bits as unit data.
The timing is when reception of the unit data ends.
A communication device.
前記エッジ検出手段は立ち上がりエッジを検出することを特徴とする通信装置。 The communication device according to claim 5 ,
The communication device according to claim 1, wherein the edge detecting means detects a rising edge .
前記判定時間は、前記単位データの受信終了時から次の単位データの受信開始時までの時間であるデータギャップ時間以上であって、且つ、前記データギャップ時間に前記単位データのデータ長に対応した時間を加えた時間以下である
ことを特徴とする通信装置。 The communication device according to claim 5 or 6,
The determination time is equal to or longer than a data gap time that is a time from the end of reception of the unit data to the start of reception of the next unit data, and corresponds to the data length of the unit data in the data gap time. A communication device characterized in that it is less than or equal to the time added .
前記シリアルデータは、所定ビット数のデータを単位データとして、複数の前記単位データからなるデータフレームとして構成されており、さらに、前記単位データの受信終了時から次の単位データの受信開始時までの時間をデータギャップ時間として、
受信データのエッジを検出して該検出時の時刻を記憶するエッジ時刻記憶手段と、
前記単位データを受信する毎に、前記エッジ時刻記憶手段の記憶内容に基づいて該受信終了前における最後にエッジが検出された時刻である最新エッジ検出時刻を取得し、該最新エッジ検出時刻と、前記最後に検出されたエッジから該単位データの受信終了時までの受信ビット数とに基づいて、該単位データの受信終了時刻を算出する第1時刻算出手段と、
該第1時刻算出手段により算出された受信終了時刻に、少なくとも、前記データギャップ時間と前記単位データのデータ長に対応した時間とを加えた時刻を、アイドル判定時刻として算出する第2時刻算出手段と、
前記受信終了時刻から前記アイドル判定時刻までの間に前記単位データが受信されなかった場合に、前記通信ラインがアイドル状態であると判定するアイドル判定手段と、
を備えていることを特徴とする通信装置。 A communication device connected to a communication partner device via a communication line and capable of transmitting and receiving serial data to and from each other.
The serial data is configured as a data frame composed of a plurality of the unit data, with data having a predetermined number of bits as unit data, and further, from the end of reception of the unit data to the start of reception of the next unit data. Time as data gap time
Edge time storage means for detecting an edge of received data and storing the time at the time of detection;
Every time the unit data is received, the latest edge detection time, which is the time when the edge was last detected before the end of reception based on the stored contents of the edge time storage means, is obtained, and the latest edge detection time, First time calculating means for calculating the reception end time of the unit data based on the number of received bits from the last detected edge to the end of reception of the unit data;
Second time calculation means for calculating, as idle determination time, a time obtained by adding at least the data gap time and a time corresponding to the data length of the unit data to the reception end time calculated by the first time calculation means. When,
Idle determination means for determining that the communication line is in an idle state when the unit data is not received between the reception end time and the idle determination time;
A communication apparatus comprising:
設定した時刻になるとその旨を示す信号を出力する計時手段を備え、
前記アイドル判定手段は、
前記単位データの受信を終了する毎に、前記第2時刻算出手段により算出された前記アイドル判定時刻を前記計時手段に設定する時刻設定部と、
前記計時手段から、前記時刻設定部により設定されたアイドル判定時刻になったことを示す信号が出力されたときに、該アイドル判定時刻の設定時から該信号の出力時までの間に前記単位データが受信されたか否かを判定する受信判定部と、
を備え、該受信判定部により受信されなかったと判定された場合に、前記通信ラインがアイドル状態であると判定する
ことを特徴とする通信装置。 The communication device according to claim 8 ,
It has time measuring means to output a signal indicating that when the set time is reached,
The idle determination means includes
A time setting unit that sets the idle determination time calculated by the second time calculating means in the time measuring means each time reception of the unit data is terminated;
When the signal indicating that the idle determination time set by the time setting unit is reached is output from the time measuring unit, the unit data is set between the time when the idle determination time is set and the time when the signal is output. A reception determination unit that determines whether or not
And determining that the communication line is in an idle state when it is determined that the reception determination unit has not received the communication line .
前記エッジ時刻記憶手段は、立ち上がりエッジを検出した時の時刻を記憶することを特徴とする通信装置。 The communication device according to claim 8 or 9, wherein
The edge time storage means stores a time when a rising edge is detected .
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2004106094A JP4244844B2 (en) | 2004-03-31 | 2004-03-31 | Serial communication method and communication apparatus |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2004106094A JP4244844B2 (en) | 2004-03-31 | 2004-03-31 | Serial communication method and communication apparatus |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JP2005295132A JP2005295132A (en) | 2005-10-20 |
| JP4244844B2 true JP4244844B2 (en) | 2009-03-25 |
Family
ID=35327589
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2004106094A Expired - Fee Related JP4244844B2 (en) | 2004-03-31 | 2004-03-31 | Serial communication method and communication apparatus |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP4244844B2 (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| EP2207308B1 (en) * | 2007-11-02 | 2018-03-14 | Cypress Semiconductor Corporation | Signal processor unit and communication device |
-
2004
- 2004-03-31 JP JP2004106094A patent/JP4244844B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JP2005295132A (en) | 2005-10-20 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US10742675B2 (en) | Fraudulent message detection device, electronic control apparatus equipped with fraudulent message detection device, fraudulent message detection method, and fraudulent message detection program | |
| JP4617440B2 (en) | Data communication system or method thereof | |
| CN102072822B (en) | Vehicle diagnosing apparatus | |
| TWI408931B (en) | Data communication device, communication control method, and program | |
| CN113452770B (en) | Data synchronization method, device, computer equipment and storage medium | |
| KR101972457B1 (en) | Method and System for detecting hacking attack based on the CAN protocol | |
| JP2704144B2 (en) | Serial data transmission device and control method therefor | |
| JP4244844B2 (en) | Serial communication method and communication apparatus | |
| CN117290128A (en) | 485 bus-based data transmission method, device, equipment and medium | |
| JP2002351813A5 (en) | ||
| JP2000339117A (en) | Data communication device | |
| WO2013182053A1 (en) | Sensor access detection method, device and system | |
| JP4316045B2 (en) | Data confirmation method between transmission and reception in a ball game machine | |
| US20150373212A1 (en) | Information processing apparatus, information processing system, method of controlling the information processing apparatus, and storage medium | |
| JP2013104358A (en) | Vehicle control system and vehicle control device | |
| US20200366522A1 (en) | Communication Method And Communication Device For Multi-Machine Communication System And Multi-Machine Communication System | |
| KR100253446B1 (en) | Data transmission system for transmitting data between plural microcomputer application instruments | |
| JP6525843B2 (en) | INFORMATION PROCESSING APPARATUS, SERVER, SLEEP CONTROL METHOD, AND COMPUTER PROGRAM | |
| JP7679772B2 (en) | COMMUNICATION SYSTEM, INFORMATION SENDING NODE, AND INFORMATION RECEIVING NODE | |
| US11816060B2 (en) | UART interface circuit and UART data capturing method | |
| CN116684449B (en) | Automobile diagnostic method, cloud platform and storage medium | |
| JP2007049297A (en) | Communication system and control method thereof | |
| JPH11163868A (en) | Communication device and reception detection method | |
| JP3440930B2 (en) | Error detection method for interrupt processing | |
| JP2010191569A (en) | Data transfer system and retry control method |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20060525 |
|
| A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20080111 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20080916 |
|
| A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20081117 |
|
| 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: 20081216 |
|
| A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20081229 |
|
| R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120116 Year of fee payment: 3 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130116 Year of fee payment: 4 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140116 Year of fee payment: 5 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| LAPS | Cancellation because of no payment of annual fees |