2023-06-30 12:00 PM
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
Solved! Go to Solution.
2023-07-03 06:31 AM
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
2023-07-03 06:31 AM
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
2023-07-05 02:34 AM
Thank you for the information. So it is just a matter of on/off. No other configuration necessary.
Probably activate the internal temperature sensor.