Skip to main content
14 votes

Is it a good idea to perform I2C Communication in the ISR?

In the olden days, when we had a single thread of execution, and many sources of interrupts, you kept the ISR as short and quick as possible, so that it is able to keep up with many frequent interrupt ...
Simon Fitch's user avatar
  • 42.3k
11 votes

Is it a good idea to perform I2C Communication in the ISR?

I don't believe it's a good idea, in general. The I2C protocol allows for clock stretching, which means that any I2C device you're trying to talk to can effectively stop your bus, or at least dork ...
Scott Seidman's user avatar
5 votes
Accepted

How can I use AVR microcontroller's SPI and I2C at the same time if they use the same pins?

This ATTINY is not capable of being programmed over SPI. You need TPI for this, which is a two-wire protocol. Only TPIDATA and SDA are shared on PB1, SCK and TPICLK are not on the same pins. This ...
Jeroen3's user avatar
  • 23.6k
5 votes
Accepted

How can I connect 8 I2C modules with entirely different addresses on ESP32?

For using multiple modules on the same I2C bus, you need to check: that no module tries to pull the voltage higher than the maximum allowed voltage for any other module (nb: some modules might allow ...
Sandro's user avatar
  • 7,938
4 votes

Is it a good idea to perform I2C Communication in the ISR?

Well, assuming the I2C bus is running at 100 kbit/s, and you're reading/writing roughly 500 bits, the whole interrupt will take about 5 milliseconds. Do you care if your main program is paused for 5 ...
ilkkachu's user avatar
  • 1,107
3 votes

What happens if I short the MISO line and SCL line?

Bad idea. The I²C device has no idea about the CS line and could happily desturb the data during SPI communication if the pattern on the bus was just right. SPI usage will also violate the timing and ...
Turbo J's user avatar
  • 10.4k
3 votes

Is it a good idea to perform I2C Communication in the ISR?

Egregious examples of systems that disable interrupts for long periods of time: Early Macintoshes, which disabled interrupts for the entire duration of floppy disk operations, thereby preventing the ...
Robin Davies's user avatar
3 votes

Is it a good idea to perform I2C Communication in the ISR?

[General guidelines. We don’t know the nature of the sensor, the nature of the instrument. We’ll make working assumptions.] The general advice is not to do serial communication in an ISR. Don’t ...
Nick Alexeev's user avatar
  • 38.5k
3 votes

Is it a good idea to perform I2C Communication in the ISR?

In time-critical applications the RDY output of the chip/module/whatever can be useful to get the data or initialise a transmission immediately. Otherwise, it's still possible to read the RDY output ...
Rohat Kılıç's user avatar
3 votes

Is it a good idea to perform I2C Communication in the ISR?

It highly depends on the architecture of the processor. As a general rule, you should not put any time-consuming operation in an isr. Some architectures have some measures to prevent any long task in ...
Saadat's user avatar
  • 1,938
2 votes

How can I use AVR microcontroller's SPI and I2C at the same time if they use the same pins?

The MCU would have configuration registers to select either SPI or I2C on the pins you want. You have to do that before you use the SPI driver. You wont be able to use SPI and I2C at the same time on ...
Amit M's user avatar
  • 908
2 votes

Is it a good idea to perform I2C Communication in the ISR?

In general, an ISR should avoid doing anything that would require that it wait a non-trivial amount of time for something to happen. If some action would require that a pin be asserted for at least ...
supercat's user avatar
  • 47.1k
2 votes
Accepted

How to design a flex PCB with 4 I2C sensors?

The main concern PCB-wise is that you stay within the maximum capacitance. You can use an online calculator to estimate the capacitance from the total run. A ground plane will increase noise immunity ...
Spehro 'speff' Pefhany's user avatar
1 vote

How to design a flex PCB with 4 I2C sensors?

Will I have to add pull-up resistors on each of the sensors for all the pins? The datasheet answers your question. See page 6.
Antonio51's user avatar
  • 15k
1 vote

Is it a good idea to perform I2C Communication in the ISR?

As many of the other answers have said, it's generally a bad idea to do anything that stalls, in an ISR. Instead, do the minimum possible that MUST be done RIGHT NOW, and get out. Let some slower ...
AaronD's user avatar
  • 5,686
1 vote
Accepted

Necessary components for a basic I2C circuit

I got the circuit working. My general advice for anyone with a similar issue/level of experience is to learn to use an oscilloscope and what your clock/data signals ought to look like. Problem 1 - ...
R. Mitchell's user avatar
1 vote

PCF8563 not answering ACK, is there something wrong with my circuit?

Any suggestions on what I’m doing wrong ? The OSCI input requires a capacitor to ground (usually a trimmer to calibrate the clock precisely) having a value between 5 pF and 25 pF: - You can check ...
Andy aka's user avatar
  • 467k
1 vote
Accepted

Is my assumption about "Enabling FM+ I2C on lower frequency gives more robustness" correct?

No, you are not necessarily correct. If you need to communicate over a longer bus with more capacitance and stronger pull-ups, you need the devices at both ends of the bus to be able to drive that bus....
Justme's user avatar
  • 165k
1 vote

Is my assumption about "Enabling FM+ I2C on lower frequency gives more robustness" correct?

This assumption is correct. FM+ is an extension to standard I2C, so it is still backward compatible, but can run with longer cables EXOR higher speed.
Stefan Wyss's user avatar
  • 7,725

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