We are trying to read a flow sensor in our device. The device is in PSM mode most of the time.
The sensor outputs its state in digital mode HIGH or LOW. We are checking a falling edge interrupt to get sensor trigger.
Interrupts are working fine in non-psm mode. The problem is that sometimes we cannot catch pin interrupts in PSM mode after 15-20 minutes.
Some interrupts can be caught some of them not.
Is there a correct way of interrupt setting to wake the device with external pin interrupt in PSM mode.
Here is the code snippet we have used to configure the external pin interrupt.
#define FLOW_NODE DT_ALIAS(flow_in)
const struct device *dev_flow;
dev_flow = device_get_binding(DT_GPIO_LABEL(FLOW_NODE, gpios));
if (dev_flow == NULL)
{
return;
}
else
{
err = gpio_pin_configure(dev_flow, DT_GPIO_PIN(FLOW_NODE, gpios),
GPIO_INPUT | GPIO_INT_DEBOUNCE);
if (err < 0)
{
return;
}
gpio_init_callback(&button_callback, flow_int_callback, BIT(DT_GPIO_PIN(FLOW_NODE, gpios) ) );
gpio_add_callback(dev_flow, &button_callback);
gpio_pin_interrupt_configure(dev_flow, DT_GPIO_PIN(FLOW_NODE, gpios),
GPIO_INT_EDGE_FALLING);
}