Woah! Tx!!!
Ich saß ebenfalls jetzt schon 2 Tage an dem Problem!
Aber anscheinend ist dies die Lösung.
Hier mein Schnipsel, damit besser auf AVR-GCC nachvollziehbar:
Code:
void twi_init(void) {
//Bit Rate Register auf 0, damit Slave
TWBR = 0x00;
//Status-Register auf Startwerte
TWSR = 0xFF;
//Adress-Register mit Addresse füllen
TWAR = (TWI_SLAVE_ADDRESS<<TWI_ADRESS_SHIFT);
//Control-Register
TWCR = 0x00
|(1<<TWINT) //Interrupt-Flag löschen
|(1<<TWEA) //Enable Acknowledge Bit aktiv
|(1<<TWEN) //Enable Bit aktiv
|(1<<TWIE); //Interrupt Enable aktiv
}
/*-------------------------------------------------------------------------*/
ISR(TWI_vect)
{
switch(TWSR & TW_STATUS_MASK) {
case TW_SR_SLA_ACK:
break;
case TW_SR_ARB_LOST_SLA_ACK:
break;
case TW_SR_GCALL_ACK:
break;
case TW_SR_ARB_LOST_GCALL_ACK:
break;
case TW_SR_DATA_ACK:
break;
case TW_SR_DATA_NACK:
break;
case TW_SR_GCALL_DATA_ACK:
break;
case TW_SR_GCALL_DATA_NACK:
break;
case TW_SR_STOP:
break;
case TW_NO_INFO:
break;
case TW_BUS_ERROR:
default:
TWCR |= (1<<TWSTO);
break;
}
twi_init();
}
Danke nochmal
Mfg Frank
Lesezeichen