cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Resetting LSM303AGR sensor

DoBaoLong
Associate

 

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;
}

 

1 ACCEPTED SOLUTION

Accepted Solutions
Federica Bossi
ST Employee

Hi @DoBaoLong ,

CFG_REG_A_M (register 0x60) bit 5 (SOFT_RST) triggers a soft reset: when this bit is set, the configuration registers and user registers are reset. Flash registers keep their values.

The only way to fully reset all registers to default values is to power cycle the sensor (i.e., disconnect and reconnect power).

Alternatively, you can manually re-initialize all registers in your firmware to desired default or startup values after a soft reset.

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 @DoBaoLong ,

CFG_REG_A_M (register 0x60) bit 5 (SOFT_RST) triggers a soft reset: when this bit is set, the configuration registers and user registers are reset. Flash registers keep their values.

The only way to fully reset all registers to default values is to power cycle the sensor (i.e., disconnect and reconnect power).

Alternatively, you can manually re-initialize all registers in your firmware to desired default or startup values after a soft reset.

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.

Hi @Federica Bossi 

Thank you very much!!!!