Hot answers tagged

38

1) What happens when the I2C pullups are omitted? There will be no communication on the I2C bus. At all. The MCU will not be able to generate the I2C start condition. The MCU will not be able to transmit the I2C address. Wondering why it worked for 3 months? Read on. 2) The lack of pullups is likely to damage any of those two ICs in my board? Probably ...


37

Some folks are having a hard time visualizing things connected together, so here's a picture: (Serving suggestion) simulate this circuit – Schematic created using CircuitLab I2C is a bus, so like-named signals are connected together. The addressing scheme allows the microcontroller to select which device it's talking to. On the Arduino the 10k pull-...


36

I2C is not designed to be used over long distances but I know of several applications where it is actually used over a distance of about 2 meters. I also know of one case where they had issues with that and it was eventuelly fixed by fixing ground loops I believe. To be sure that it will function, you should use an I2C bus extender like the P82B715. ...


30

Electrically it makes sense because ground is the one common connection to all devices on a IIC bus. That's a lot less of a restriction than forcing power to be the common connection to all IIC devices, as would be required if the lines were driven high and floated low via pulldowns. Note that IIC devices don't all need to be powered from the same net or ...


28

At I2C speeds, vias will cause you absolutely no problems at all. At least, no problems in terms of track resistance, capacitance or inductance. However, if you have a 2 layer board, then using both layers is best done systematically, otherwise you can lead yourself into problems. What many people do is to dedicate one layer of a board to ground. This ...


27

It is very simple. Number of pins and cost of packaging. EEPROM devices are primarily used to store parametric data or characterization constants for a device. The typical scenario is to write very seldom and read typically once each time the host device boots up. For this type of application the relatively slow writing times of EEPROM are of little ...


25

The insane sounding lengths like 10,25, and 100m are perfectly possible, and I use the method often (with UART not I2C, but the method stands) when I need to put stuff together quickly. It's not exactly the best way, though. The key is to know your input voltage threshold. Make sure the voltage drop in the ground lead is well below this, or else a ...


24

I think I've found your problem, and (I know you won't like this) an accurate schematic would have highlighted the problem to (at least some) readers straight away. :-) Looking at the starting voltage on the two pins in your two traces above, that voltage is around +3.3V. That tells me the PIC is powered from that voltage. Then we see the voltage rise to +...


24

In the good old days, TTL drivers were much better at pulling a signal down than pulling it up. Therefore, protocols like I2C, but also interrupt lines, reset, and others, were all implemented using a pull-up with distributed pull-down.


24

The address 6BH can be written with just 7 bits, as binary 1101011. The fact that a number is written in hexadecimal does not necessarily imply that it must be expressed using an integer multiple of 4 bits.


23

Sensor hub arrangement In this scenario, there are two I²C buses. Let's call them local bus and main bus. The purpose of the local bus is to connect a bunch of sensors to a microcontroller (μC). The purpose of the μC is to poll the sensors, aggregate information from them, and detect certain events. A μC in such role is called sensor hub. The sensor ...


23

The software limiting factor is the size of the address used for the slaves: 7-bit or 10-bit, which support 127 and 1023 devices, respectively. Physically, there are two restrictions. First, the physical size of the bus because the bus is only meant for short runs (the inter IC part). If the bus is too large there are capacitive loading and propagation delay ...


22

For fast mode, and resistor pullup, capacitance should be less than 200pF, according to this NXP document I2C-bus specification and user manual. With current source pullups you can go to 400pF, but not with resistors. If your wire is 20pF/30cm and you have another 50pF of stray and input capacitance, you're limited to 2.25m of cable length. Different ...


22

Your 1 meter connection should work fine if you take the following precautions for your particular situation. A. A good ground connection between the two boards is essential. You may be able to fulfill this requirement with your CAT-5 cable. If you run into problems after trying all of the following, run an extra 20 AWG wire along side the CAT-5 cable ( tie ...


21

The library you use, and the libraries it depends on (Wire), enable the internal pull-ups of the ATMega. These are weak pull-ups, and in normal use, supplement any external pull-ups (two resistors in parallel). Due to the relatively high resistance of 20k to 70k, they do not cause much if any issues with external ones in use. What happens when the I2C ...


21

A very common reason to need more than one bus is having devices that run at different speeds. Originally, I²C ran at at a maximum 100 kHz. Later, the speed was increased to a maximum of 400 kHz, and still later, to 1 MHz and above. The gotcha is, since the address of each device is embedded in the I²C protocol, then if you have devices with different ...


21

With both only master can initiate the communication. I²C can however have multiple masters and the nodes can change the roles, so it is a bit more flexible. But saying that slave could initiate communication is still not correct. A common way for a slave to indicate that it wants to communicate to the master is to use an interrupt signal. On many sensors ...


21

Obviously while reading temperature values I cannot use SPI bus, missing almost 10 A/D readouts while I2C is active. Not at all - with many microcontrollers you can put the bytes you want sent into a buffer and return from the interrupt, then arrange to get another interrupt later when it's done. Interrupt handlers should never be waiting for something to ...


21

No, it really shouldn't. Or in fact, it depends who you ask, as it is a matter of opinion and depends on manufacturer and people who write code how they want to represent the I2C address. Basically, there are two different notations: 7-bit notation, with 7-bit value, which does not include the read/write bit 8-bit notation, with 8-bit value, that contains ...


19

Also it could let you support two devices with the same address. Yes most devices let you select maybe the bottom two bits of their address with straps. Recently I had to support 4 devices who each only allowed you to set the LSB of their address with a resistor. Having two ports means no extra cost for me. Maybe I want one to be the master for a bunch ...


19

You have to 'patch' your PCB. I would do as I have tried to draw below: place two pull up resistors (10K) on the existing pads shorting them out. Then a wire from the other ends to the nearest 3V3 connection. I have drawn SMD resistor but you can use the "old fashioned" axial ones too.


18

Trying to do with with IIC is a bad idea. IIC is really meant for communication between chips on a single board. Since the maximum required current to pull a line low is limited, the lines are relatively high impedance (a few kΩ). This means they can pick up noise easily, which is a serious issue when running in unshielded cable in the walls ...


18

Is my adding of the red MCU correct? Not exactly. The MCU is just another member of the bus like the rest of the Devices. There is nothing particularly special about how the MCU operates on the I2C bus. The MCU can recognize when either line is high or low, and the MCU can pull on either (or both) of the lines itself in order to communicate with all the ...


18

Let's start with the HAL_I2C_Master_Transmit() function. If you check its declaration: HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout); Minor problem with 2nd parameter, the slave device address. The slave device address is b1010000 if we complete it to 8bit format, ...


17

So far I understand, Intel processors use specialized CPU instructions (IN/OUT) to communicate with peripherals. Uh, this might have been true in the 1970s and 1980s, but really wouldn't even be very useful for an I²C peripheral, and incredibly intrusive for the programming of the CPU. So, instead, there's some peripherals attached to a much, much faster ...


16

These "hardware addressing" pins are not for addressing words in the RAM, but rather to select the address of the whole device on the IIC bus. The manufacturer realizes that you might want to have several of these chips on the same IIC bus, which means they each need a different IIC bus address. These pins allow you to pick one of 8 pre-defined addresses ...


16

Look closer... There is only a single pair of pull-up resistors for each bus. Your diagram shows four separate I2C buses. The multiplexer and the repeater isolates the segments. Thus, since you only have one bus, you only need two resistors: One for SCL and one for SDA.


16

An EEPROM is the usual solution. The RAM SPD (Serial Presence Detect) function uses an EEPROM on an I2C bus. The chips are remarkably inexpensive, for example the Microchip AT34C02D is $0.03 in 100 quantity at Digikey (factory price is 0.13 each, as Abe Karplus mentions, so that's a clearance price). For your application you might not need to program the ...


15

While I think this would work, I'd not see the immediate advantage of having disconnectedable pullups; I'm sure you have a good reason! Be a bit careful: A diode in reverse bias is a capacitor. At let's say 3.3V of your bus, with the jumper open, that means that for example if SDA is low and SCL gets high, then one of the diodes is in forward, one in ...


15

Maybe overkill if it was working before, but an option is to use an I2C to Differential converter such as PCA9615, LTC4331, etc. If making the resistors smaller don't work or you need to extend the cable, consider not using I2C directly. Not only the range will be extended but you will also have better noise immunity.


Only top voted, non community-wiki answers of a minimum length are eligible