Hey all. I'm using standard TWI in an ATMega16. Currently, I have normal interface code, for example:
TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);
while(!(TWCR & (1<<TWINT)));
for my start byte. My problem is that my program gets stuck inside the while loop, waiting for the START to occur. I don't run into this problem until I attach a second device to the bus. Could this be due to violating setup or hold conditions? My application uses a DAC and operates correctly until an extra device is added to the bus (IO expander). After an additional device is added, the program will start operating, but lock up shortly after starting (after the input to the DAC gets past a certain point). Debugging in AVR Studio showed my TWI_Start function was causing the infinite loop. Any ideas?