EmbeddedRelated.com
Forums

atmega8 as twi-slave

Started by Oliver Joa May 6, 2004
hi,

i try to use the atmega8 as a slave-device on the twi (i2c) bus.
i can send the slave-adress and the atmel reacts on it, but then
it sends SCL to low and the bus is blocked. i have no idea whats
the next step.

does anyone have a working slave-implementation (example-code)?

thanks

regards

olli
>i try to use the atmega8 as a slave-device on the twi (i2c) bus. >i can send the slave-adress and the atmel reacts on it, but then >it sends SCL to low and the bus is blocked. i have no idea whats >the next step.
The ATMega8 is doing exactly what the datasheet says it will do. See the section called "Control Unit" starting on the bottom of page 167. "As long as the TWINT Flag is set, the SCL line is held low. This allows the application software to complete its tasks before allowing the TWI transmission to continue." So, the next step is to do whatever the TWI slave is supposed to do at this point. What you need to do probably depends on the R/W bit that came with the control byte.