Gast
#867161
hallo..
habe folgendes problem:
wenn der srf02 außer reichweite misst, dann kommt er nicht weiter
char i2c_read(char address, char reg)
{
char read_data = 0;
TWCR = 0xA4;
while(!(TWCR & 0x80));
TWDR = address;
TWCR = 0x84;
while(!(TWCR & 0x80));
TWDR = reg;
TWCR = 0x84;
while(!(TWCR & 0x80));
TWCR = 0xA4;
while(!(TWCR & 0x80));
TWDR = address+1;
TWCR = 0xC4;
while(!(TWCR & 0x80));
TWCR = 0x84;
while(!(TWCR & 0x80)); //--> kommt nicht weiter
read_data = TWDR;
TWCR = 0x94;
return read_data;
}
was könnte ich machen, damit er diesen schritt überspringt ?
oder soll ich nach einer gewissen zeit abbrechen ?
mfg