cancel
Showing results for 
Search instead for 
Did you mean: 

lsm303agr magneto temperature offset

Egbert
Associate

Looking in the example code for the lsm303agr I noticed a function:

 

 

/**
  * @brief  Enables the magnetometer temperature compensation.[set]
  *
  * @PAram  ctx    Read / write interface definitions.(ptr)
  * @PAram  val    Change the values of comp_temp_en in reg CFG_REG_A_M
  * @retval        Interface status (MANDATORY: return 0 -> no Error).
  *
  */
int32_t lsm303agr_mag_offset_temp_comp_set(stmdev_ctx_t *ctx,
                                           uint8_t val)
{
  lsm303agr_cfg_reg_a_m_t cfg_reg_a_m;
  int32_t ret;

  ret = lsm303agr_read_reg(ctx, LSM303AGR_CFG_REG_A_M,
                           (uint8_t *)&cfg_reg_a_m, 1);

  if (ret == 0)
  {
    cfg_reg_a_m.comp_temp_en = (uint8_t)val;
    ret = lsm303agr_write_reg(ctx, LSM303AGR_CFG_REG_A_M,
                              (uint8_t *)&cfg_reg_a_m, 1);
  }

  return ret;
}

 

 

I cannot find what this register does other then activate or deactivate a temperature offset.
How does this register work and what does activating do?

 

With kind regards,


Egbert

1 ACCEPTED SOLUTION

Accepted Solutions
Federica Bossi
ST Employee

Hi @Egbert ,

Welcome to ST Community!

In register CFG_REG_A_M (60h) you find the COMP_TEMP_EN bit which enables the magnetometer temperature compensation when set to '1'. In this way is possible to remove the offset thermal drift.

This register is also used to set the ODR, power mode (high performance or low power) and System mode (continuous or single mode) you want and for soft reset and reboot.

If my reply answered your question, please click on Accept as Solution at the bottom of this post. This will help other users with the same issue to find the answer faster

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
Federica Bossi
ST Employee

Hi @Egbert ,

Welcome to ST Community!

In register CFG_REG_A_M (60h) you find the COMP_TEMP_EN bit which enables the magnetometer temperature compensation when set to '1'. In this way is possible to remove the offset thermal drift.

This register is also used to set the ODR, power mode (high performance or low power) and System mode (continuous or single mode) you want and for soft reset and reboot.

If my reply answered your question, please click on Accept as Solution at the bottom of this post. This will help other users with the same issue to find the answer faster

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Thank you for the information. So it is just a matter of on/off. No other configuration necessary.
Probably activate the internal temperature sensor.