cancel
Showing results for 
Search instead for 
Did you mean: 

TMP102 Configuration Register Read/Write fail

rasem
Visitor

I need help to setup TMP102 alarm function. My board is NUCLEO-F439ZI

Reading the temperature is working fine.

uint8_t TMP102_ADDR = 0x48 << 1;

uint8_t REG_TEMP = 0x00;

uint8_t buf[12];

buf[0] = REG_TEMP;

ret = HAL_I2C_Master_Transmit(&hi2c2, 0x90, buf, 1, 10);    // OK

ret = HAL_I2C_Master_Transmit(&hi2c2, 0x90, 0x00, 1, 10);   //OK

ret = HAL_I2C_Master_Receive(&hi2c2, 0x90, buf, 2 , 10);    //OK

reads the temperature correctly. Buf[0] and buf[1]has correct temperature data.

 

I am trying to setup the alarm function. Reading/writing the Limit registers are failing.

Datasheet states that Thigh=80C, and Tlow=70C. After Reset.

I am reading the Thigh registers, with the following code:

uint8_t reghi = 0x03;

ret = HAL_I2C_Master_Transmit(&hi2c2, TMP102_ADDR, reghi, 1, 10); // fail

is sending 0x00 on reghi. I verified by scope.

ret = HAL_I2C_Master_Transmit(&hi2c2, TMP102_ADDR, 0x03, 1, 10);  //fail     

it is sending 0x00 to configuration register.

The only way to send the right value accomplished by:

Unit8_t reghi = 0x03;

buf[0] = reghigh;

ret = HAL_I2C_Master_Transmit(&hi2c2, TMP102_ADDR, buf, 1, 10); OK.

Sending 0x03 to select the Thigh register. Verified by scope.

 

Now I want to read the value of Thigh.

ret = HAL_I2C_Master_Receive(&hi2c2, TMP102_ADDR, buf, 2 , 100);

The value in buf[0] = 0x00;

The value in buf{1] = 0x00;

I verified it in Debug mode.

 

The same problem when I write two bytes to Thigh and read it back

It gives 0x00 for both bytes.

If anybody tried to set the alarm successfully in TMp102, please help.

Thanks,

Rasem

1 REPLY 1

Yeah, because it want a POINTER, the address of variable, and not the number/constant itself..

uint8_t reghi = 0x03;

ret = HAL_I2C_Master_Transmit(&hi2c2, TMP102_ADDR, reghi, 1, 10); // fail

is sending 0x00 on reghi. I verified by scope.

ret = HAL_I2C_Master_Transmit(&hi2c2, TMP102_ADDR, 0x03, 1, 10);  //fail     

it is sending 0x00 to configuration register.

The only way to send the right value accomplished by:

 

uint8_t reghi = 0x03;
ret = HAL_I2C_Master_Transmit(&hi2c2, TMP102_ADDR, (void *)&reghi, 1, 10); // pass via pointer
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..