Hardware Reference
In-Depth Information
that the I 2 C protocol can send bytes and request bytes. It is up to you to decide
how to inform the slave of your intentions. What solution did you come up with?
Traps and Pitfalls
The I 2 C protocol is rather complex, and as such, problems can arise. They are
normally easily i xed, and most electronic components use the standard I 2 C
revision, simplifying usage.
Voltage Diff erence
Most Arduinos are powered by 5 volts, but some I 2 C circuits can be powered by
3.3 V, sometimes even lower. If you need to use 3.3-V devices (like the example
in this chapter), then you have three choices. You could use a 3.3-V device like
the Arduino Due. This was the solution chosen for this chapter. You could also
use a level shifter, an electronic component that can convert a 3.3-V signal to a
5-V signal. The third option is to use a 5-V device anyway, but there are risks.
The I 2 C is an open drain bus, meaning that power is not supplied by the
components, but rather by the power lines themselves using pull-up resistors.
The Arduino's I 2 C pins have internal pull-up resistors that are automatically
activated, pulling the line to 5 V. If you include external pull-up resistors to
a 3.3-V power rail (like the one supplied by an Arduino), then the end result
will be a voltage level slightly above 3.3 V. Most devices can handle up to 3.6 V
without a problem.
The input voltage is also a problem. The Atmel AVR specii cations say that an
I 2 C input is considered high when it reaches and surpasses 0.7 times the power
voltage. For a 5-volt system, this means the signal must reach 3.5 volts. With two
external pull-up resistors to a 3.3-V rail, this is achieved, but there is little margin
for error. It could work, and in practically all cases, it does, but be aware of the
technical implications. I have never heard of either an I 2 C device or an Arduino
being damaged by this technique, but if you are making a long-term project
or a professional board, you might want to consider using other techniques.
Bus Speed
Numerous bus frequencies exist for I 2 C; the original bus speed was 100 kHz, but
additions allowed 400 kHz, 1 MHz, 3.4 MHz, and 5 MHz speeds. Components
using the Ultra Fast Mode transfer speed (5 MHz) are rare and heavily specialized.
 
Search WWH ::




Custom Search