Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Restart after system off if the sensor driver is not suspended (Zephyr OS)

Hello, 

I'm working with LIS3DH sensor and I want to wakeup nRF52832 from system off by an interrupt from the sensor (not added the interrupt configuration yet). I'm using Zephyr OS v3.1.99 on a nRF52 DK, and I've merged two examples : nRF5x System Off demo and LIS2DH: Motion Sensor Monitor. The problem is, whenever I put the chip in system off mode, It will reset immediately, but if I suspend the sensor driver using pm_device_action_run(), it won't reset anymore. I don't know what's going on, can someone explain the reason?

This is the main.c :

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Copyright (c) 2019 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <zephyr/zephyr.h>
#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/pm/pm.h>
#include <zephyr/pm/device.h>
#include <zephyr/pm/policy.h>
#include <hal/nrf_gpio.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/init.h>
static void fetch_and_display(const struct device *sensor)
{
static unsigned int count;
struct sensor_value accel[3];
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

prj.conf :

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
CONFIG_STDOUT_CONSOLE=y
CONFIG_I2C=y
CONFIG_SENSOR=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_LIS2DH=y
CONFIG_LIS2DH_ACCEL_RANGE_2G=y
CONFIG_LIS2DH_OPER_MODE_LOW_POWER=y
CONFIG_LIS2DH_ODR_1=y
# CONFIG_LIS2DH_TRIGGER_GLOBAL_THREAD=y
CONFIG_PM=y
CONFIG_PM_DEVICE=y
CONFIG_GPIO=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

dts.overlay :

Fullscreen
1
2
3
4
5
6
7
&i2c0 {
lis3dh: lis3dh@19 {
status = "okay";
compatible = "st,lis2dh";
reg = <0x19 >;
};
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX