cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Resetting LSM303AGR sensor

DoBaoLong
Visitor

 

Hello everyone,

I am using I2C to communicate between an STM32F411 Discovery Board and the on-board LSM303AGR sensor. I have already configured it for a 400Hz ODR, normal power mode, and am reading temperature values (around 25°C to 27°C).

However, I am stuck on how to soft-reset the entire sensor. I tried to SET bit 5 in CFG_REG_A_MAG and adding a small delay, but this does not reset the values I configured in other registers. Those settings remain the same, no matter how many times I try to SET the reset bit.

The registers only reset when I unplug and plug the power back in.

Please help me.

Thank you very much.

bool LSM303AGR_softReset(const LSM303AGR_t* lsm303agrStruct){
	uint8_t regVal = 0;
	if(!readMag(lsm303agrStruct, LSM303AGR_CFG_REG_A_MAG, &regVal)) return false; //Extract the current status bit-field and assign it to regVal

	/* Start to assign and write regVal to CFG_REG_A to start FULL CHIP RESET */
	regVal |= (SET << REG_A_SOFT_RST_Pos);
	if(!writeMag(lsm303agrStruct, LSM303AGR_CFG_REG_A_MAG, regVal)) return false;
	HAL_Delay(50);
	return true;
}

 

0 REPLIES 0