Hot answers tagged

10

But I wonder how does this handshaking takes place between a Master and Slave when the Slave is sender and the Master is receiver and only the Slave (sender) knows when there is no more data to send to the receiver? This isn't supposed to happen. i2c is a very defined protocol and each slave device should be known to each master. Typically, the master ...


6

For any distance over which I2C is a viable means of communication, and certainly within a single PCB, there is no need for any trace length matching constraint between SCL and SDA. It won't have any noticeable effect on the signal integrity or timing margins.


5

These Callback functions are called from the I2C interrupt handler. You shouldn't make other API calls from them. HAL_I2C_Master_Transmit_IT() check timeouts etc which might not work from an interrupt handler. This might a reason for slow execution, but regardless it's bad practice. A safer route is to set a global (and volatile) variable, and check for it ...


4

Let us say a Slave or Master is sending multiple bytes to the receiver on I2C bus and the number of bytes is not defined before hand. So then how will the sender tell the receiver that it has no more data to send? If Master is the sender, then he knows how many bytes have to be sent. Master will signal the end of his data transfer by sending a STOP ...


4

Those are the two options. If slave receiver does not accept more data it can NAK the byte, but master is still responsible for sending the stop condition. For a slave transmitter, it can't signal anything to stop, it must be known beforehand, or it could be encoded in the data, e.g. text string is terminated with a zero so slave can transmit zeroes until ...


3

Those addresses are also in hex. 0x1F means the same as 1Fh. The XXh notation comes from Intel assembly syntax (source) Those addresses are used to identify a device register in the I2C transaction and are orthogonal to the address of the device on the bus. In particular, the device address is given on page 17, as a function of how a certain pin is ...


3

You only need one pair of pull-up resistors for entire bus. Adding them at each node will create too strong pull-up. This, consequently, answers your other concerns - you can connect pull-ups to any 3.3V source and be OK. However, there is a caveat - most MCU and other I2C devices have maximum pin voltage specified relative to VCC, e.g. "VCC + 0.5V". This ...


3

I suggest you read AN10710 by NXP, which discusses the P82B715 I2C Bus Extender. This should cope with 15m of cable, particularly if you run I2C at less than the maximum speed.


3

I2C arbitration works at the datalink level. I2C uses open-drain connections: SDA is low if any device pulls it low, but SDA is high only when all devices are not pulling it low. So during I2C slave address where two masters are transmitting, if one master pulls SDA low while the other master wants SDA high, then the open-drain datalink resolves the conflict ...


3

There isn't anything in the i2c protocol that solves this problem. You can make it work, but you will use some software to do it. Since i2c was designed for hardware communication, usually involving fixed size registers, nothing was provided to handle variable-length data. I found this out myself and have had to solve the same problem you are considering. ...


3

The I2C interface is a de facto standard that is now controlled by NXP. Search for the NXP "I2C-bus specification and user manual", UM10204. The standard specifies a data bit setup time before the rising edge of the clock and a data hold time after the falling edge of the clock, so a receiver could potentially use either edge of the clock, or could use a ...


2

Data transfer- The state of SDA(high or low) can change only when SCL is low. This means SDA must be stable when SCL high. Sampling is done while the SCL going 0 to 1 state. Changing SDA when SCL is low provides some timing margin for accurate sampling. As for I2C itself is a mutual interface standard. Both sides(TX and RX) can control the SDA line in ...


2

I'm going to digest your entire post little by little... Let us say a Slave or Master is sending multiple bytes to the receiver on I2C bus and the number of bytes is not defined before hand. But it should be defined. If random information was being sent or received, you'll never be able to interpret it. So then how will the sender tell the receiver ...


2

A few notes: Getting the right pull up values is vital, particularly for SDA. Different devices can sink different amounts of current. I have seen setups that generate extra 1s in the data because of a too small pull-up resistor, after switching to a smaller sensor chip. The smaller geometries meant it could not pull the bus down to a clean zero. ...


2

According to Section 4.2 the ESP32 datasheet, any GPIO pin can be configured as an I2C pin. There are two I2C interfaces (I2CEXT0 and I2CEXT1), and they can operate in either master or slave mode at up to 400kHz. Just make sure you don't use any pins that your module uses for another purpose. For instance, some ESP32 modules have status LEDs or external ...


1

0x29 is one of the available I2C addresses, it has nothing to do with the internal register addresses. The trailing h is just another way of designating a hex number (03h is the same as 0x03).


1

Most forms of wired communication over that sort of distance use differential signalling, which is inherently more robust to attenuation, ground level shift and electromagnetic interference. There are several ICs available designed for exactly this application - EE.SE discourages product recommendation questions and answers so I won't give specific examples, ...


1

A good way to get distance over a cable is to not use I2C protocol. I2C has to support bidirectional flow on the SDA line that does not have convenient method to support the direction changeover for the signalling. Same holds true for the SCL line if the target device does clock stretching. A better way to attack this is to use the ASYNC UART port of the ...


1

It's possible there is an error in the datasheet and the SCL/SDA and INT pins should not be pulled above VDDIO because of protection diodes. That would exactly explain the symptoms you are seeing. The datasheet refers to pullups to VDDIO (which, as you know, is limited to about 2V) in several places. I suggest you contact the manufacturer and confirm. To ...


1

About the question about PE2-PE0 being a waste of pins. Maybe not because the master who lost the arbitration may need to retry the transmission. To understand better the use of these pins, you should go deeper in the device datasheet (as opposed to the App Note.) Hopefully this will help you to understand point 5 and 6 I am assuming you are familiar with ...


1

"Two devices can't communicate at the same time, right? And are the two devices slaves? or masters?" Two devices can communicate at the same time on the same bus (with eachother), but not more, no matter their role. On I2C, only the master(s) can start communcations. If a masters wants to do so, he can check wether the SDA pin is pulled low (for the ...


1

Fortunately or unfortunately, it's up to you to come up with a protocol for this scenario as you control both sides. Like you say, the slave can only respond to transfers initiated by the master. Your master then needs to poll the slave (ask for data on a recurring schedule), unless you have another way for the slave to communicate when data is ready. (The ...


1

Overall I will have single Slave device (an I2C MCU) and no Master. I want to see if I can make to to send data without any master giving it a command or ACK/NACK or START/STOP signal. That's not possible for an I2C Slave. Any device which did that, wouldn't be I2C-compliant. From this comment: I want to do this only for my test setup. I will see the ...


1

It seems your asking if you MCU can (also) be a Master on the I2C bus. Of course, there can be multiple Master devices on the I2C bus. But then your MCU needs to be paying attention to the bus, so it does not try to send while another Master is sending


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