external interrupt during I2C interface.?

Status
Not open for further replies.

hassanmd

Member level 1
Joined
May 31, 2007
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,554
HEllo:
wat will happened if external interrupt occurs during I2C Or SPI comunication with slave device?
for example my program is in the I2C communication with RTC or EEPROM and in mean time an external interrupt occurs and i consume 10 clock cycle in ISR, then what will happened to I2C communication? is the efect can be changed eirther i use I2C with interrupt or with out interrupt?
thnks.
 

Hi,

It depends on several facts. To minimize conflicts; Use hardware I2C module if available, If your I2C is solely a software function, interrupt will simply spoil the clock signal and then data.

When you use hardware I2C module for Master, and in the middle of transmitting/receiving, if interrupt is occurred; it doesn't affects to current transmitting/receiving byte. However start of next byte will be delayed.

Use of I2C with or without interrupt will not affect much in above "hardware I2C module" scenario; but it's complicated in software-I2C.
Thank you,
 
If your I2C is solely a software function, interrupt will simply spoil the clock signal and then data.
Why? Both SPI and I2C have a fully static clock specification, allowing to suspend the protocol for inifinite time. So there shouldn't be any issues for a master device.
 

Yes, for a Master it can suspend the clock. (Also a slave can do clock-stretching.)

Complexity is when slave use interrupts (eg. I2C between 2 micro-controllers), it may not sense the clock signal inside the interrupt routine. So it need to pull the clock to Low (clock-stretching) before interrupt routine. We can simply avoid it by using hardware-I2C modules.
Thanks
 
it means if i use hardware modules with their respective interrupts enabled . i shouldnt worry! is that wat u say.
 

At the master side, you don't need to think about interrupts.
 

Yes, at master side you shouldn't worry about interrupt. (If that I2C is more time-sensitive in your design, you can use interrupt)

check following link also, I2C Tutorial

Thank you,
 

If you use hardware I2C on the slave I2C side you should not worry if the external interrupt occurs during some I2C event - the hardware will strech the I2C CLOCK in the appropriate moment. The problem will be if you can't process this event during the I2C timeout time - then the master will get timeout event and probably will abort the communication

Now some dark sides of the event "External interrupt with I2C Inteface" - More of the uP on the market have problems with I2C if external interrupt occurs in some particular moments when I2C event happens (with exception of Philips uP). Microchip and Atmel have such problems and if you're not aware how to avoid the problems you can get a project that hangs from time to time or holds the CLOCK line forever. Notice that some of these bugs are not officially listed in the uP manufactures so if you simply follow the uP manufacturer data sheet you'll get troubles. You'll probably blame the external noises or something else. So my advice is - read carefully what people say about this particular uP you'll use with I2C.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…