I2C (inter IC) was invented by Philips Semiconductor (now named NXP). It is typically used to attach low-speed peripherals to processors/micro-controllers.
Since 2006, no licensing fees are required to implement I2C protocol, but fees are still required to obtain I2C addresses, allocated by NXP.
I2C bus (SDA, SCL)
- both outputting and inputting signals on the wire are possible (it can sense the voltage level of the wire).
- open-drain, or open-collector
- masters and slaves can only drive these lines low, or leave them open;
- each line requires a pull-up resistor on it, to pull the line up to VCC, if no I2C device is pulling it down.
more on pull-up resistor:
- without a pull-up resistor, he device is not able to generate the I2C start condition.
- sometimes, there is no external pull-up, but an internal pull-up can be enabled.
- lack of pull-up will not damage either IC, as PNP transistor is being used.
- resistor selection: start with 4.7K, and adjust down if necessary.
- note: a small resistor might be too weak for I2C pull up (it might still work, depending on the I2 speed, etc).
I2C bus transaction
- Usually, the slaves are in the idle condition, monitoring the SDA and SCLK lines for the start condition and the correct transmitted address.
- the clock signal is always generated by the current bus master.
- start condition: a high to low transition on SDA while SCL remains high, then pulls the SCL low.
- Following the start condition, the address bits are transferred from MSB down to LSB.
- A logic 0 on the LSB of the first byte means a “write”; a logic 1 means a “read”.
- The first 8 clock cycles are used for slave address, then the 9th is for slave ACK.
- The slave, if it recognizes its address, it responds by pulling the data line low during the ninth clock pulse – this is known as an acknowledge bit.
- A data transfer is terminated by a stop condition: a low to high transition on SDA, while SCL is high.
example #1: (the slave 0x70 doesn’t respond)
# irecv -n/dev/i2c0 -a0x70 -l1 // 0111 0000 –> 1110 0001 DCMD_I2C_SENDRECV, send STOP.
example #2 (the slave 0x6c works well)
# irecv -n/dev/i2c4 -a0x6c -l1 // 0110 1100 –> 1101 1001 DCMD_I2C_SENDRECV, send STOP, too.
Data recvd: 15h // 0001 0101
The purpose of pull up/down is to insure that a circuit has a default value (high, or low), given no other input:
a pull up resistor (connect to a power supply) pulls the line high;
a pull down resistor(connect to ground) pulls the line down.
Pull-up resistor pull-down
MON_INT_N is connected to OM5_GPIO8_233. INT2 pad can be configured as active high; GPIO is configured as input (internal pull up/pull down disabled; high level detection).
When MON drives 3.3V (high), the downside of R14130, closer to MON, is 2.5V due to 1.8V (R13993) pull-up.
Note: INT2 pad can be configured to open-drain, too. I assume that the “NB” resisters are there, in case the pad is configured as open drain?
An alternate to tri-state logic is open drain output:
- the output signal is applied to the base of an internal NPN transistor.
- it controls the transistor switching.
- The emitter is grounded internally.
- The real output will be on the collector — open collector (the output is taken from between the collector and the emitter). The output would be either
- low, when the transistor is on, as the output is forced to nearly 0 volt; or
- nothing (no current flows), also called “high-Z”, high impedance, when the transistor is off.
In practice, a pull-up or pull-down resistor is required, to keep the digital output in a defined logic state. An external pull-up resistor can be used to raise the output voltage when the transistor is turned off.
The advantage of open drain circuit:
- all the devices can pull the signal line low, but can not drive it high.
- avoid conflicts where one device drives the line high, while another tries to pull it low.
- inactive devices would not try to hold the line high.
- pull up resistor can be external, no need to be connected to the chip supply voltage.
High impedance (hi-Z, tri-stated, floating) means the output is not being driven to any defined logic level (neither logical high, nor low).
The use of high impedance: allow multiple circuits to share the same output line. When you enable the output (pull the line OE to low, or write to a reg), the output will drive it respective loads (0, or 1). Otherwise, it is in high-impedance.
- A pull-up resistor can be used to try to pull the wire to high and low voltage levels. When devices are inactive, they tri-state their outputs. When all the devices on the bus have done this, the pull-up resistor will pull the line up. If a dvice wants to communicate, it drives the line low.
the device document says it “employs high-impedance CMOS on all signals pins. Voltage on any signal pin that exceeds the ranges can induce destructive latch-up (a type of short circuit in IC)”.
All BT656_D(x) pins are connected to imx_CSI1_DAT(12~19). At the rightmost, it is 3V3DC connected. The decoder uses 3.3V, 1.8V.
To pull the line/pin in a defined status/level when there is no signal output,
- For non-used pins (maybe used by other component), e.g MX_CSI1_DAT(1), R10845 is NB (for pull down), R10872 is 4K7(pull up), which effectively pull up the line (3.3V).
- For pins being used: MX_CSI1_DAT(12), R10184 is 10K,
- which effectively pulls down the line when there is no signal coming;
- when the device outputs signals (drive 3.3V or 1.8V on the pin), the line will be high???
State of Transistor
- If there is zero current though it, the transistor is in “CUTOFF” state.
- If there is maximum current through it, called “saturation”.
- Anywhere between saturated and cutoff is called “active” mode.
An example of common Emitter
1. Solar cell serves as a light sensor: by using a solar cell to provide 1V (> 0.7V),
- With the solar cell darkened, the transistor behave as an open switch between collector and emitter.
- When the solar cell is powered, electrons will flow from the emitter through to the base, up to the left side of the lamp, back to he positive side of the battery —A closed switch
2. Common emitter can e used to produce an output voltage derived from the input signal, rather than a specific output current.
- With the solar cell darkened, the transistor behave as an open switch between collector and emitter. there is maximum voltage drop between collector and emitter.
- When the solar cell is fully powered, minimum voltage drop between collector and emitter.
- For an amlifier to work properly, it must be biased on on the time (not just when a signal is present).
- “On” means current is flowing through the transistor (VB = 0.6 ~ 07V). Usually, a CD circuit is used to achive the biasing.
Bipolar transistor consists of two PN-junctions — two diodes back to back.
How it works: when you apply a small current to the base (from emitter to base, for NPN type), a much larger current can flow through the transistor (from emitter to collector, for NPN type)
- One of them is usually grounded.
The choice between NPN and PNP is really arbitrary: all that matters is that the proper current directions are maintained.
- To get transistors to work,
- For NPN, collector must be more positive in voltage than emitter.
- For PNP, collector must be more negative in voltage than emitter.
- IB + IC = IE,
- IC is almost equal to IE, as the base current is very small.
- IC = bIB, b is called the current gain, typically 20 ~ 200
- Base(small) current is the only current that goes through the base wire of the transistor.
- Collector(large)current is the only current that goes through the collector wire of the transistor.
- emitter current is the sum of the base and collector current.
Diode blocks current in one direction while letting current flow in another direction.
junction diodes are common: put a pice of N type silicon next to a piece of P type silicon.
- N material has excess negative charge (electrons);
- P material has excess positive material (holes).
- Diode is forward biased when Vanode > Vcathode (usually 0.7Volts, needed to start the hole-electron combination process at the junction).
- Conducts current strongly.
- Voltage drop across diode is (almost) independent of diode current.
- Effective resistance (impedance) of diode is small.
- Diode is reverse biased when Vanode < Vcathode.
- Conducts current very weakly (perhaps 10 microamps)
- Diode current is (almost) independent of voltage, until breakdown (the junction breaks down and lets current through if you apply enough reverse voltage).
- Effective resistance (impedance) of diode is very large.