Hi,
I have a nearly working implementation of MAXIM DS 1621 I2C Digital Thermometer in SimulIDE. I am testing the DS1621 as an I2C slave with an Arduino Mega as I2C master. I have problem reading 16 bits from the slave, I only get 8 bits. It looks like a problem of ACK from the master after reading the first byte. A work around is to make twice 8 bits read at consecutive addresses but this does not work on the real chip.
I use the Wire library on the Arduino and when I request two bytes as said in the data sheet , I only get the msbyte; The code is :
When requesting 1 byte twice it works fine on SimulIDE but not on the real chip. The code is:
I have tried looking in the examples but I only found 8 bits reading.
Is it a limitation of the simulator or do I have done something wrong in my implementation maybe of writeByte() function on the slave ? do I have to handle the change of SDA state (to make an NACK instead of ACK) in the slave writeByte() function ?
Note that except this 16 bits read all other I2C modes are working fine.
I have a nearly working implementation of MAXIM DS 1621 I2C Digital Thermometer in SimulIDE. I am testing the DS1621 as an I2C slave with an Arduino Mega as I2C master. I have problem reading 16 bits from the slave, I only get 8 bits. It looks like a problem of ACK from the master after reading the first byte. A work around is to make twice 8 bits read at consecutive addresses but this does not work on the real chip.
I use the Wire library on the Arduino and when I request two bytes as said in the data sheet , I only get the msbyte; The code is :
- Code:
Wire.beginTransmission(Address);
Wire.write(0xAA);
Wire.endTransmission();
Wire.requestFrom(Address,2);
if (Wire.available()) msbyte = Wire.read();
delayMicroseconds(100);
if (Wire.available()) lsbyte = Wire.read();
When requesting 1 byte twice it works fine on SimulIDE but not on the real chip. The code is:
- Code:
Wire.beginTransmission(Address);
Wire.write(0xAA);
Wire.endTransmission();
Wire.requestFrom(Address,1);
if (Wire.available()) msbyte = Wire.read();
Wire.beginTransmission(Address);
Wire.write(0xAB);
Wire.endTransmission();
Wire.requestFrom(Address,1);
if (Wire.available()) lsbyte = Wire.read();
I have tried looking in the examples but I only found 8 bits reading.
Is it a limitation of the simulator or do I have done something wrong in my implementation maybe of writeByte() function on the slave ? do I have to handle the change of SDA state (to make an NACK instead of ACK) in the slave writeByte() function ?
Note that except this 16 bits read all other I2C modes are working fine.