2023-02-10 03:59 AM
Hi,
I've tried to configure the DREADY to INT1 and read the output registers. I believe I'm making some mistake in the configuration as I observed that I'm able to read the OUT registers when I using the polling method. I've tried using the ST MEMS C driver and directly writing to the registers. Below is a code snippet of what I tried using to configure the LIS3DH
```
uint8_t lis3dh_on_boot(stmdev_ctx_t *ctx)
{
uint8_t config[6] = {0x07, 0x00, 0x10, 0xA8, 0x00, 0x01};
uint8_t config_read[6] = {0};
uint8_t ctrl_reg0 = 0x90;
uint8_t ctrl_reg1 = 0x07;
uint8_t ctrl_reg2 = 0x00;
uint8_t ctrl_reg3 = 0x80;
uint8_t ctrl_reg4 = 0xA8;
uint8_t ctrl_reg5 = 0x00;
uint8_t ctrl_reg6 = 0x02;
lis3dh_write_reg(ctx, LIS3DH_CTRL_REG0, &ctrl_reg0, 1);
lis3dh_write_reg(ctx, LIS3DH_CTRL_REG1, &ctrl_reg1, 1);
lis3dh_write_reg(ctx, LIS3DH_CTRL_REG2, &ctrl_reg2, 1);
lis3dh_write_reg(ctx, LIS3DH_CTRL_REG3, &ctrl_reg3, 1);
lis3dh_write_reg(ctx, LIS3DH_CTRL_REG4, &ctrl_reg4, 1);
lis3dh_write_reg(ctx, LIS3DH_CTRL_REG5, &ctrl_reg5, 1);
lis3dh_write_reg(ctx, LIS3DH_CTRL_REG6, &ctrl_reg6, 1);
nrf_delay_ms(50);
ctrl_reg1 = 0x17;
lis3dh_write_reg(ctx, LIS3DH_CTRL_REG1, &ctrl_reg1, 1);
nrf_delay_ms(50);
lis3dh_read_reg(ctx, LIS3DH_CTRL_REG1|0x80, config_read, 6);
lis3dh_read_reg(ctx, LIS3DH_CTRL_REG0, &ctrl_reg0, 1);
}
```
I believe the code to configure the interrupt pins is fine as the pin stayed high when I tried to read it.
Solved! Go to Solution.
2023-02-15 08:26 PM
Figured out the issue in the above code. The value I used for CTRL_REG3 is incorrect. I think the C driver didn't work initially as the interrupt was latched and I hadn't added in the code to read the output registers. So the interrupt stayed latch and it did not trigger the ISR.
2023-02-15 08:26 PM
Figured out the issue in the above code. The value I used for CTRL_REG3 is incorrect. I think the C driver didn't work initially as the interrupt was latched and I hadn't added in the code to read the output registers. So the interrupt stayed latch and it did not trigger the ISR.
2023-02-16 06:43 AM
Thank you @GTS.1 for sharing your solution!
-Eleon