This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

LIS2DH / INT1 interrupt for wake-up

Hello,

For our project I'm using a LIS2DH (accelerometer) that is supposed to trigger an interrupt on its pin INT1 when a movement is detected.

I use nRF52832. Before I implement with GPIOTE, I want to make it simple and just check if the accelerometer works but so far got no satisfaying result...

I first define the pin as input:

nrf_gpio_cfg_input(INT1,GPIO_PIN_CNF_PULL_Disabled);    //no pull-up,  no pull-down

Then I implement the sequence as described by ST:

1. Write 57h into CTRL_REG1 // Turn on the sensor and enable X, Y, and Z     ODR = 100 Hz
2. Write 00h into CTRL_REG2 // High-pass filter disabled
3. Write 40h into CTRL_REG3 // Interrupt activity 1 driven to INT1 pad
4. Write 00h into CTRL_REG4 // FS = ±2 g
5. Write 08h into CTRL_REG5 // Interrupt 1 pin latched
6. Write 10h into INT1_THS // Threshold = 250 mg
7. Write 00h into INT1_DURATION // Duration = 0
8. Write 0Ah into INT1_CFG // Enable XH and YH interrupt generation

Then I poll the pin INT1:

bool keep=1;
            
while (keep)
{
 state = nrf_gpio_pin_read(INT1);
 if (state) keep=0;     // if the PIN is High it means Interrupt received so stop polling
}

Does my code seems ok to you?

Thanks.

John.

Parents Reply Children
Related