Arduino Interrupts and I2C
-
Having learned a lot from this forum, I wonder if somebody can now enlighten me on how to identify an interrupt as the TWI address match on I2C Slave after it wakens from Sleep, or point me where I can find out?
I could activate a external interrupt from Master to Slave if stuck or if it brings other issues, but I keep finding reference to TWI match with no detail of how the Slave knows why it was wakened...
-
@zboblamont Refer to http://ww1.microchip.com/downloads/en/AppNotes/atmel-2565-using-the-twi-module-as-i2c-slave_applicationnote_avr311.pdf top of page 5:
if a START CONDITION followed by a TWI address matches the address in the Slave’s TWI Address Register (TWAR) the TWINT flag is set, resulting in the execution of the corresponding interrupt (if Global Interrupt and TWI interrupts are enabled).
-
@yveaux Not sure what the second link is but thank you very much for the pointers...
-
@zboblamont avr-libc is the 'base library' which allows c-coding on atmega's. It describes how to use the twi interface and includes some example code to juggle the twi registers of the atmega.
Possibly you can find some arduino library abstracting these details for you, but this is how it works/should be done.