dear all,
I am not able to set the configuration registers of the converter chip ADS122C04 using arduino via I2C.
Arduino has the Wire libary for i2c communication. The code contains the following
1-reset the chip (one byte)
2-write register command (WREG) and register data (figure 59 of the data sheet) for all four registers
3- start conversion (one byte)
In sum, ten (10) bytes are sent in one i2c frame using an array of bytes as follows:
//--------------------------------------------------------------------
int ADR_THeiz_Austritt = 0x40; //hex Adress of the device
byte InitArray[10] = {6, 64, 54, 68, 10, 72, 5, 76, 112, 8}; //configuration array
Wire.beginTransmission(ADR_THeiz_Austritt); // talk to Slave
Wire.write(InitArray,10); // bytes array is sent to slave on ACK handshaking
status = Wire.endTransmission(); //status see https://www.arduino.cc/en/Reference/WireEndTransmission
Serial.print("Status Initialisierung = ");
Serial.println(status);
//--------------------------------------------------------------------
status is a byte, which indicates the status of the transmission:
0:success
1:data too long to fit in transmit buffer
2:received NACK on transmit of address
3:received NACK on transmit of data
4:other error
after configuration, when reading the value of e.g. register 0, the result was 0 !!
A second attempt was performed with a for loop
//--------------------------------------------------------------------
for (int i=0; i<10; i++)
{
Wire.beginTransmission(ADR_THeiz_Austritt);
Wire.write(InitArray[i]);
//delay(10);
status = Wire.endTransmission();
Serial.print("status Initialisierung ");
Serial.print(i); //print the array element no
Serial.println(status); //print the status of transmision
}
//--------------------------------------------------------------------
the print function result was the following: 00, 10, 23, 30,43,50,63,70,83,90 which means:
i=0, InitArray[i]=6, status =0 --> Reset of chip successfull
i=1, InitArray[i]=64, status =0 --> adressing Register 0 successfull
i=2, InitArray[i]=54, status =3 --> value for Register 0 not transmitted !! (the same applies for all registers)
i=9, InitArray[i]=8, status =0 --> start chip successfull
My question: do you know why I am not able to put a value in the registers?
thanks a lot!
ilyes