Hallo,
Ich möchte das mein mega8 I2C Master beim einschalten guckt welche
Slaves eingeschaltet sind. Dazu soll er einfach nur alle Adressen von
0x10 bis 0x1F prüfen.
Mein Problem ist das wenn ich folgenden Code ausführe fängt ein Slave an
zu spinnen und hängt sich bei jedem zweiten mal auf auf (Zieht dabei
beide Signalleitungen auf low).
1 | uint8_t i;
|
2 | for(i = 0x10; i <= 0x1F; ++i)
|
3 | {
|
4 | temp_buffer[0] = (i<<TWI_ADR_BITS)|(0<<TWI_READ_BIT);
|
5 | TWI_Start_Transceiver_With_Data(temp_buffer, 1);
|
6 | while(TWI_Transceiver_Busy());
|
7 | _delay_us(50);
|
8 | }
|
Das ist noch minimal Code, er hängt sich direkt beim ersten Durchlauf
bei TWI_Transceiver_Busy() auf weil die Leitungen auf low sind.
Wenn ich den Code mitten im Betrieb laufen lassen (taster/uart)
funktioniert alles wunderbar.
Der Slave der den Fehler verursacht hat TWAR = 0x10 (Addrese).
Ich verwende den Code aus App note AVR311 und AVR315.