Forum: Mikrocontroller und Digitale Elektronik I2C Sensor TPA81: Adresse wechseln?


von Joe (Gast)


Lesenswert?

Hallo zusammen.

Ich habe ein Problem mit einem I2C Gerät, dem Wärmesensor TPA81. Ich 
möchte zwei der Sensoren an einen Bus hängen, und daher die Adresse des 
einen ändern. Das soll laut Datenblatt auch gehen (siehe [1]):

"Changing the I2C Bus Address
To change the I2C address of the TPA81 you must have only one module on 
the bus. Write the 3 sequence commands in the correct order followed by 
the address. Example; to change the address of a TPA81 currently at 0xD0 
(the default shipped address) to 0xD2, write the following to address 
0xD0; (0xA0, 0xAA, 0xA5, 0xD2 ). These commands must be sent in the 
correct sequence to change the I2C address, additionally, No other 
command may be issued in the middle of the sequence. The sequence must 
be sent to the command register at location 0, which means 4 separate 
write transactions on the I2C bus. Additionally, there MUST be a delay 
of at least 50uS between the writing of each byte of the address change 
sequence. ..."

Was genau muss ich denn nun schicken? Ich habe folgendes probiert unter 
Verwendung der I2C (TWI) Master Software Library (siehe [2]):
1
    tempI2C = i2c_start(SLAVE_ADDRESS + I2C_WRITE);
2
      i2c_write(0x00);  // register to write to
3
      i2c_write(0xA0);  // 3 bytes to set the new address
4
      delayus (60);
5
      i2c_write(0xAA);  
6
      delayus (60);
7
      i2c_write(0xA5);  
8
      delayus (60);
9
      i2c_write(0xD2);  // the new address: D2
10
      delayus (60);
11
      i2c_stop();   // terminate connection

Muss ich das Register, in das geschreiben werden soll, jeweils nochmal 
senden, also so:
1
    tempI2C = i2c_start(SLAVE_ADDRESS + I2C_WRITE);
2
      i2c_write(0x00);  // 3 bytes to set the new address
3
      i2c_write(0xA0);  
4
      delayus (60);
5
      i2c_write(0x00);  
6
      i2c_write(0xAA);  
7
      delayus (60);
8
      i2c_write(0x00);  
9
      i2c_write(0xA5);  
10
      delayus (60);
11
      i2c_write(0x00);  
12
      i2c_write(0xD2);  // the new address: D2
13
      delayus (60);
14
      i2c_stop();   // terminate connection

Oder muss die die ganze Transaktion (inkl. i2cstart, i2cstop) immer 
wieder schicken? Oder das ganze mit i2c_rep_start beginnen?

Etwas ratlos,
  Joe

[1] http://www.robot-electronics.co.uk/htm/tpa81tech.htm
[2] http://jump.to/fleury

von Jörg S. (Gast)


Lesenswert?

Wenn ich das richtig verstehe, muss du das Regsiter (0x00) nicht 
angeben, das erkennt er wohl automatisch.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.