Hello everybody,
I have a problem with my sensor lis3lv02dq.
I want to do a function that when you press a button, set to 0 the values of the 3-axis sensor to start from a point of reference.
I'm playing with several values in CTRL_REG2, but I can not reset using the boot.
I leave part of the code of my accelerometer
void Sensor_Init(void)
{
unsigned int xx = 0;
unsigned int yy = 0;
unsigned int zz = 0;
xx= Sensor_RX(WHO_AM_I);
yy= Sensor_RX(CTRL_REG1);
zz= Sensor_RX(CTRL_REG3);
printf(" W: %x 1: %x 2: %x \n", xx, yy, zz);
// war: Sensor_TX(CTRL_REG1, 0x87); // Power on device, enable all axis, and turn off self test
// war: Sensor_TX(CTRL_REG2, 0x45);
//Axel: REG2: 0x65, REG1: 0x47
//Sensor_TX(CTRL_REG2, 0x14);
Sensor_TX(CTRL_REG2, 0x44);
Sensor_TX(CTRL_REG1, 0x87);
if ((B1) == 0 && b1_flag == 0) //if B1 pressed
{
draw_array32_to_lcd("Calibrate ");
b1_flag = 1;
}
if ((B1) != 0 && b1_flag != 0) //if B1 released
{
Sensor_TX(CTRL_REG2, 0x14);
b1_flag = 0;
}
}