Posted: Sun Mar 21, 2010 9:46 pm Post subject: I2C Bus Interrupt
I have several Input devices (PCF8574) on the I2C bus. The interrupt tells me when an input has been changed.
In the interrupt routine I would like to know the address of the device with the new input information. Is a command in the BaseCom I2C library that allows me to get the address
or the complete SDA string with all the information (Address and Data Bits)?
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
Posted: Sun Mar 21, 2010 11:42 pm Post subject:
Presumably you have all the PCF8574 devices interrupt lines wire-ORed to a single interrupt pin of the AVR. Then you have no direct way of determining from the IRQ itself which device activated the IRQ, so you must poll each device in turn, using the I2C bus, to find which one set the IRQ.
If you do this, I strongly recommend that you simply set a flag in the IRQ routine, then do the polling in the main loop when the flag is set ( and of course clear the flag). That way you dont waste lots of time in the IRQ doing I2C transfers.
If several devices might generate interrupts at close time intervals, you might need to wire each to a separate IRQ pin on the AVR, that way you dont need to poll, since the ID of the IRQ will then tell you which device generated it. _________________ Adrian Jansen
Computer language is a framework for creativity
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum