![]() ![]() ![]() (We’ll discuss the protocol below.) Note that the downward transitions are nearly instantaneous, but it takes some time to rise back up to VCC. ![]() Here’s some up-close shots of an I2C conversation. This means that the signal lines can’t be too long, to keep parasitic capacitance at bay. 400 picofarads is the maximum, according to the standard. The optimal choice of pullup resistor varies with line capacitance, desired speed, and the strength of the transistors in the various devices, but 4.7 kOhms is normal. This means that, while a high-to-low transition can be next to instantaneous, a low-to-high transition will always take some time as the line charges back up. ![]() Parasitic capacitance matters a lot in I2C because the devices pull down the signal lines, but they’re pulled back up by resistors (or a constant-current source in higher-performance designs). With SPI and asynchronous serial, this is not much of a concern because the high and low voltage levels are both driven by transistors on board the chips in question. This parasitic capacitance means that the voltage level on the signal line (data or clock) can’t change instantaneously, but some finite current needs to be pumped into the wire to charge up this accidental capacitor. And this means that there’s some small capacitance between the I2C signal lines and the PCB’s ground plane, or any other adjacent signals for that matter. While we normally think of a capacitor as being made of two large conductive plates with a dialectric (or air) between them, the same charge-storage capacity exists between two parallel wires as well. The problem with relying on pullup resistors is “parasitic capacitance”. This sounds good, but can cause problems with high-speed signals and high-capacitance lines. I2C devices can also be constructed with a single transistor per line, because the two lines are pulled up by an external resistor (or resistors). There is a price for this simplicity when interfacing systems that run at different voltages. Whereas SPI gets by with the minimal amount of protocol overhead but pays the price in a florescence of wires, I2C only requires you to lay down two tracks: one for the clock (SCK) and one for data (SDA). Let’s start off by looking at the wires, because that’s where a surprising number of glitches and complications can creep in. Physical Layer Image from Sparkfun’s I2C Tutorial So here’s a guide to making it work when it’s not working. If you need to connect a few cheap temperature sensors to a microcontroller (and their bus addresses don’t clash) I2C is a great choice. I2C was designed to connect up a bunch of slower, cheaper devices without using a lot of copper real estate compared to its closest rival protocol: SPI. I’ve never seen twenty devices on a bus, much less 127.īut still, I2C has its place. Although I2C does reduce the number of signal wires you need, it gets dangerous when you have more than a handful of devices on the same pair of wires, and you’re lucky when they all conform to the same standard. In reality, the tradeoff for using only two wires is a significantly complicated signalling and addressing system that brings both pitfalls and opportunities for debugging. There’s an allowance for multiple clock-masters on the same bus, and a way for slaves to signal that the master needs to wait. On paper, up to 127 devices can be connected together using just two wires (and ground). In principle, it’s a brilliant protocol, and in comparison to asynchronous serial and SPI, it’s very well defined and clearly standardized. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |