Hi!
I am currently experiencing a really odd I2C problem on a Atmega32u4 based card. I'm trying to use a TLV493D connected by I2C. I know from this thead that before using this device, I have to set the powermode :
Wire.beginTransmission(HallAddressWrite); // Address the sensor
Wire.write(configReg); // Address the Configuration register
Wire.write(powerMode); // Set the Power Mode to Low
errorCode = Wire.endTransmission(); // Stop transmitting
But each time I'm trying to write on the TLV493D register, the device simply disappear from I2C bus ! I know it sounds strange, but I can demonstrate it with a modified version of default I2C scanner default I2C scanner
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
Serial.println("Beginning write test...");
Wire.beginTransmission(address);
// no register writing
errorCode = Wire.endTransmission();
Serial.print("Test ended with code : ");
Serial.println(errorCode);
Serial.println("SECOND Beginning write test...");
Wire.beginTransmission(address); // Address the sensor
Wire.write(0x00); // Address the Configuration register
Wire.write(0x05); // Set the Power Mode to Low
errorCode = Wire.endTransmission();
Serial.print("Test ended with code : ");
Serial.println(errorCode);
nDevices++;
}
which gives the output:
I2C device found at address 0x5E !
Beginning write test...
Test ended with code : 0
SECOND Beginning write test...
Test ended with code : 0
And next scan doesn't find anything. As you can see, I don't lost my device when I don't write anything. But it disappears from my bus as soon as I write something (here, it's for setting low power mode, but any value will do the same).
More informations :
- My code is correct. I know that because I don't have any problem when using an Arduino Uno or Arduino Mega. Unfortunately, I don't have an Arduino Leonardo to see if my problem comes from Atmega32u4.
- My wiring is correct. I checked the signal on SDA and SCL pin on the TLV493D with an oscilloscope and everything is as expected : 3.3V and 100kHz.
- I also have a SRF02 on my I2c bus : it is working as expected.
- I don't think my TLV493D is damaged. In deed, I thought it was because of that. So I changed it for another one but the problem is still here.
- I noticed than when beginning an I2C transmission at address 0x00, I am able to see my TLV493D again. But it is pointless since I have to set power mode again and thus, it disappears from bus once again.
- I checked supply voltage and it stays constant at 3.3V. So I don't think I a have tension drop tht would provok TLV493D reset
Thank you.