LoginSignup
26
13

More than 1 year has passed since last update.

そのI2C、どこまで対応してますか?

Last updated at Posted at 2020-12-21

はじめに

I2C(アイ・スクエアド・シー、アイ・アイ・シー、アイ自乗シー)はフィリップス社で開発された2線式のシリアルバスです1。2線式にも関わらず多彩な機能をサポートしておりテレビチューナや各種センサーなど安価なシステムの開発に貢献してきました。
かつてはフィリップス社へのデバイス登録とライセンス料の支払いが必要でしたが、2004年8月に特許が失効していることもあり、現在はロイヤリティフリーでどなたでも自由に使うことができます。半面、ここまで対応していればI2C対応を名乗れるという認証プロセスもないことから、一口にI2Cに対応しているといってもいろいろなレベルがあるようです。
例えば、電気的仕様は満足せずに、I2Cプロトコル(通信フォーマット)のみに対応しているデバイスも数多く存在します。

そこで、I2C仕様の中で何が必須機能なのか、対応してないかもしれない仕様はどれかについて調べてみました。

I2C仕様と歴史

現在、I2Cの仕様書はNXPセミコンダクターズ社のサイトにて配布されています。I2Cの仕様は、より高速なモードの追加だけでなく例えば400kHzのモードであっても少しずつ仕様が変化しています。にもかかわらず、I2Cの対応バージョンを明記しているデバイスはまれなようです。(通常は問題にならないと思いますが)
I2Cの仕様2の変遷について気になったものを簡単に表にまとめました。削除された仕様変更は省略しています。
また、用語の変更、一覧表や誤記の修正、Fast-mode以外の変更内容などについては抜き出してないものがあります。
詳細は Appendix をご参照ください。
なお、従来のマスター/スレーブは、Rev.7.0からコントローラ/ターゲットに変更されたので、本文中の記載はコントローラ/ターゲットで統一します。

Revision Date low-speed mode Standard-mode Fast-mode Fast-mode Plus Hs-mode Ultra Fast-mode specifier
Original 1982 - - - - Philips
v1.0 1992 - 〇*1 〇*1 - - - Philips
v2.0 1998 - 〇*2 〇*2 - - Philips
v2.1 2000 - - - Philips
v.3 20070619 - 〇*3*4 〇*3*4 〇*4 NXP
v.4 20120213 - 〇*5*6 〇*6 NXP
v.5 20121009 - NXP
v.6 20140404 - NXP
v.7.0 20211001 - NXP
max speed 10kbit/s 100kbit/s 400kbit/s 1Mbit/s 3.4Mbit/s 5Mbit/s

*1: 10ビットアドレスの追加。Standard-modeは除くように読めるが、のちのバージョンでは区別されていないようだ。
*2: I/O段の特性仕様を追加、$t_{of}$を追加。
*3: $t_{HD;DAT}$のMaxを$t_{VD;DAT}$に移動、$t_{VD;ACK}$仕様を追加。
*4: バスクリア(SDAをLOWにしているデバイスは9クロックでSDAを開放する)手順、DeviceID仕様を追加。
*5: $t_r$のMinを変更。
*6: $t_{of}およびt_f$のMinをバス・ラインの静電容量規定からVDD電圧規定に変更。

I2Cバスプロトコル機能の適用について

I2C仕様書の v.3 から、[必須、オプション、適用不可] の区分けが明記されるようになりました。
仕様書から抜粋した表を以下に示します。よく使われる Standard-mode、Fast-mode、Fast-mode Plus について示したものです。

このリビジョンでマルチコントローラに非対応のものを単一コントローラと呼ぶようになりマルチコントローラが必須でないことも明確になったと思います。またクロックストレッチをオプションと書きながら、わざわざ[2]の注釈があるのは、使用するデバイスによっては必須になる(waitでも回避可能)ためだと思います。

M = 必須、 O = オプショ ン、 n/a = 適用不可

機能 単一コントローラ マルチコントローラ ターゲット[1]
スタートコンディション M M M
ストップコンディション M M M
アクノリッジ M M M
同期化 n/a M n/a
調停 n/a M n/a
クロックストレッチ O[2] O[2] O
7ビットターゲットアドレス M M M
10ビットターゲットアドレス O O O
ゼネラルコールアドレス O O O
ソフトウェアリセット O O O
スタートバイト n/a O[3] n/a
デバイスID n/a n/a O

[1] ターゲットとして機能するコントローラにも該当。
[2] クロックストレッチは、一部のターゲットが備える機能です。システムにクロックをストレッチ(SCLをLOWにホールド)できるターゲットがない場合、これを処理できるようにコントローラを設計する必要はありません。
[3] 「ビットバンギング」(ソフトウェアエミュレーション)マルチコントローラシステムの場合はスタートバイトを用いることができます。

対応してないかもしれない代表的なI2C仕様

さて、先の表にあるように一部の機能はオプションですので、使いたい機能をこの表でチェックしていけばよいでしょう。
単一コントローラのみか、マルチコントローラに対応しているか、ターゲット動作に対応しているのか、必要な機能に対応しているかなどです。
例えばSCL端子が入力専用ではなく、双方向端子になっているターゲットデバイスを使うには、クロックストレッチの管理が必要かもしれません。
このようなデバイスを制御するのに、SCL端子が出力専用端子になっているコントローラデバイスでは、クロックストレッチに対応することができないので注意が必要になります。

この先は、この表には載っていないものの重要だと思われるのに、あまり守られていない仕様について紹介します。

絶対定格

電源オフ時のバスライン

I2C仕様には、

・Fast-modeデバイスへの電力供給がオフになった場合、SDAおよびSCL のI/Oピンはバスラインが遮断されないようにフロート状態にすること

という記載があります。このときI2Cバスにつながった端子には外部からプルアップ抵抗を通して電圧がかかりますが、多くのマイコンでは電源オフ時に、I/O端子に電圧を加えることを禁止していますので、この仕様には対応できないことになります。

I/O端子の電気的仕様

専用のI2C端子を持たないマイコン製品でよくあることですが、I/O端子の電気的仕様がI2C仕様を満たしていないかもしれません。この場合、I2Cバスの電気的仕様だけではなく、デバイスの仕様も満たすように基板を設計する必要があります。
以下にFast-modeでの値を例示しながら説明していきます。

VOL規定

I2C仕様では、VDDが2Vを超える場合のシンク電流3mAのとき、LOWレベル出力電圧(VOL)は0.4V以下となっています。この規定を満足しないデバイスではプルアップ抵抗の値などに注意が必要です。一般的な計算式から求まる抵抗値よりシビアな調整が必要かもしれません。I/O端子のドライブ能力が変えられる場合はドライブ能力をあげた方がVOLに余裕を持てるかもしれません。また、MACNICAさんのHPにはより確実な解決策が載っています34

VIL、VIH規定

I2C仕様では、入力をLOWと判断する電圧である「LOWレベル入力電圧(VIL)」は 0.3×VDD以下、入力をHIGHと判断する電圧である「HIGHレベル入力電圧(VIH)」は 0.7×VDD以上です。また、VILは-0.5V以上、VIHはVDD+0.5V以下との規定もあります。これらの規定を満足しないデバイスでは、基板上で電圧などをモニターしたりして、信号の反射や雑音余裕に気を使って回路定数を決めるなど、より注意深い設計が必要になるかもしれません。

信号のタイミング

信号タイミングについては、デバイスで固定されている場合とプログラマブルな場合があります。特に難しいと思うパラメータを紹介します。

スパイクフィルタ

Fast-modeにおいて、入力フィルタで抑制する必要のあるスパイクのパルス幅$t_{SP}$ は0~50nsと規定されています。このスパイクが曲者で、IEEE規格などであれば試験方法の規定などで合格ラインとするスパイクの頻度や位置なども規定されたりするものですがI2Cにはありません。発生頻度は離散的であると仮定したとしてもSDAとSCLの両方の信号の変化エッジ付近に存在しても正常に通信を行えるかどうかは、デバイス設計者(やノイズフィルタ幅がプログラマブルであればソフトウェア設計者)の腕の見せ所だと思います。

データホールド時間

データホールド時間$t_{HD;DAT}$は、0ns以上と規定されています。デバイスの設計者視点では、内部クロックで取り込んだ際に発生するメタステーブルなどで、取り込んだ後のSCLとSDAのタイミングが前後することがありますし、先のスパイク規定の影響でさらにタイミングに余裕をもった回路設計が必要という難しい部分ですので、攻めた使い方は避けた方がよいです。デバイスや設定によっては、STOPコンディションやRESTARTコンディションと誤認識して誤動作する可能性があります。可能であれば、データホールド時間が0nsにならないように余裕を持ったタイミングで使う方が安全です。

おわりに

I2Cの気になっていた仕様についてまとめてみました。
例えば、ESP32であればI/O端子の電気的仕様をちっとも満たしていません5
I2Cは仕様を100%満たしていなくても、認証機関があるわけでもなく、通信デバイスのように相互接続認証があるわけでもないので、うまく使いこなせればお金もかからず便利に使えるお手軽さもあります。
私はポイントを押さえれば、つなぐだけで簡単に使えるそんなI2Cが好きです。
この記事が、I2Cの選び方や使い方のヒントになれば幸いです。

Appendix

Revision history抜粋
歴代6の「I2C-bus specification and user manual 」から引用した内容をそのまま添付します。

Rev
Date
Description
Version 1.0
1992
This version of the 1992 I2C-bus specification includes the following modifications:
· Programming of a slave address by software has been omitted. The realization of this feature is rather complicated and has not been used.
· The “low-speed mode” has been omitted. This mode is, in fact, a subset of the total I2C-bus specification and need not be specified explicitly.
· The Fast-mode is added. This allows a fourfold increase of the bit rate up to 400 kbit/s. Fast-mode devices are downwards compatible i.e. they can be used in a 0 to 100 kbit/s I2C-bus system.
· 10-bit addressing is added. This allows 1024 additional slave addresses.
· Slope control and input filtering for Fast-mode devices is specified to improve the EMC behaviour.
NOTE: Neither the 100 kbit/s I2C-bus system nor the 100 kbit/s devices have been changed.
Version 2.0
1998/12
The I2C-bus has become a de facto world standard that is now implemented in over 1000 different ICs and licensed to more than 50 companies. Many of today’s applications, however, require higher bus speeds and lower supply voltages. This updated version of the I2C-bus specification meets those requirements and includes the following modifications:
· The High-speed mode (Hs-mode) is added. This allows an increase in the bit rate up to 3.4 Mbit/s. Hs-mode devices can be mixed with Fast- and Standard-mode devices on the one I2C-bus system with bit rates from 0 to 3.4 Mbit/s.
· The low output level and hysteresis of devices with a supply voltage of 2 V and below has been adapted to meet the required noise margins and to remain compatible with higher supply voltage devices.
· The 0.6 V at 6 mA requirement for the output stages of Fast-mode devices has been omitted.
· The fixed input levels for new devices are replaced by bus voltage-related levels.
· Application information for bi-directional level shifter is added."
Version 2.1
Rev.03
20070619
Many of today’s applications require longer buses and/or faster speeds. Fast-mode plus was introduced to meet this need by increasing drive strength by as much as 10× and increasing the data rate to 1 Mbit/s while maintaining downward compatibility to Fast-mode and Standard-mode speeds and software commands.
Modifications:
• Re-ordered sections and clarified several requirements
• Added description of Fast-mode Plus (Fm+) specifications
• Added description of the Device ID Field
• Added Bus Clear procedures
• Moved level shifting information to a separate application note (AN10441)
• Clarified the process of sizing Rp
• Added limits for tVD;DAT and tVD;ACK
Rev. 4
20120213
Update user manual.
Modifications:
• The format of this document has been redesigned to comply with the new identity guidelines of NXP Semiconductors.
• Legal texts have been adapted to the new company name where appropriate.
• Table “Document information”: added keywords “Ultra Fast-mode”, “UFm”, “USDA” and “USCL”
• New Section 3.1 created and (old) sections 3.1 to 3.17 are moved under this new section and renumbered to Section 3.1.1 to Section 3.1.17.
• Section 3.1.12 “Reserved addresses”, added descriptive line below title of Table 3
• Added (new) Table 4 “Assigned manufacturer IDs”
• Added (new) Section 3.2 “Ultra Fast-mode I2C-bus protocol”
• Added (new) Section 4.6 “Display Data Channel (DDC)”
• added (new) Section 5.4 “Ultra Fast-mode”
• Table 9 “Characteristics of the SDA and SCL I/O stages”:
– symbol Vhys: deleted condition “VDD > 2 V”; deleted condition “VDD < 2 V” and its values
– symbol VOL3 replaced with symbol VOL2; added (new) Table note [3]
– parameter description for tof corrected from “output fall time from VIHmax to VILmax” to “output time from VIHmin to VILmax”.
– tof Min values for Fast-mode and Fast-mode Plus are changed to “20 ns (VDD / 5.5 V)”
• Table 10 “Characteristics of the SDA and SCL bus lines for Standard, Fast, and Fast-mode Plus I2C-bus devices[1]”:
– tr Min value for Fast-mode changed from “20 + 0.1Cb ns” to “20 ns”
– tf Min values for Fast-mode and Fast-mode Plus are changed to “20 ns (VDD / 5.5 V)”
• Table 11 “Characteristics of the SDAH, SCLH, SDA and SCL I/O stages for Hs-mode I2C-bus devices”: second Condition for VOL changed from “VDD < 2 V” to “VDD ≤ 2 V”
• Added (new) Section 6.3 “Ultra Fast-mode devices”.
• Section 7.1 “Pull-up resistor sizing”, third paragraph changed from “... is a function of the rise time minimum (tr) ...” to “... is a function of the rise time maximum (tr) ...”
Rev. 5
20121009
User manual; fifth release
Modifications:
• Section 3.1.7 “Clock synchronization”, first paragraph, first sentence changed from “idle bus”to “free bus”
• Section 3.1.8 “Arbitration”, third paragraph, second sentence changed from “the bus is idle”to “the bus is free”
• Section 3.1.12 “Reserved addresses”:
– Table 3 “Reserved addresses”, slave address 1111 1XX: R/$\overline{W}$ bit changed from “X” to “1”; description changed from “reserved for future purposes” to “device ID”
– deleted (old) third paragraph
• Section 3.1.17 “Device ID”:
– in numbered list following second paragraph: “START command” changed to “START condition”
– in numbered list following second paragraph: “STOP command” changed to “STOP condition”
– in Remark paragraph: “NACK command” changed to “NACK”
– Table 4 “Assigned manufacturer IDs” updated
• Section 3.2.8 “10-bit addressing”:
– fifth paragraph (bullet item): “NA1” changed to “$\overline{W}$” in third sentence; deleted “(NA2)” from fourth sentence
– Figure 29 “A master-transmitter addresses a slave-receiver with a 10-bit address” modified
• Section 3.2.9 “Reserved addresses in UFm”: deleted (old) third paragraph
• Section 7.2.1 “Reduced fSCL”, third paragraph corrected from “30 % to 30 %, or 70 % to 70 %”to “30 % to 70 %, or 70 % to 30 %”
Rev. 6
20140404
User manual; sixth release
Modifications:
• Figure 41 “Rp(max) as a function of bus capacitance” updated (recalculated)
• Figure 42 “Rp(min) as a function of VDD” updated (recalculated)
Rev. 7.0
20211001
User manual; seventh release
Modifications:
• Updated Table 5 (著者註:Assigned manufacturer IDs)
• Updated the terms ""master/slave"" to ""controller/target"" throughout to align with MIPI I3C
specification and NXP's Inclusive Language Project
• Added Section 9 (著者註:Overview of MIPI I3C)

免責事項

本記事の正確性については努力しておりますが、当方は利用者が当記事の情報を用いて行う一切の行為について何ら責任を負うものではありません。本記事の情報の利用、内容によって、利用者にいかなる損害、被害が生じても、著者は一切の責任を負いません。ご自身の責任においてご利用いただきますようお願いいたします。

商標について

本記事に掲載されている商品またはサービスなどの名称は、各社の商標または登録商標です。


  1. I2C - Wikipedia 

  2. I2C-bus specification and user manual 

  3. I2CバスのVOL規定を確認していますか? 

  4. I2Cバスの通信エラーを改善する方法 

  5. ESP32 Series Datasheet 

  6. THE I2C-BUS SPECIFICATION VERSION 2.0, VERSION 2.1 および I2C-bus specification and user manual Rev.03, Rev.4, Rev.5, Rev.6, Rev.7.0 

26
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
13