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

nrf52 not entering sleep mode when accelerometer kx022 is used with twi manager

On a NRF52832 based beacon I use to sensors, a SHT3 temperature and humidity sensor and a KX022 accelerometer.

I'm using the twi_manager library as it is used in the example.

With the SHT3 everything is fine, the overall power consumption is ok.

As soon as I initialize the KX022 sensor exactly the same way, the power consumption stays at ~3.7 mA and is not going to the expected average of 4 uA and it seems that there is a reason why it is not going to sleep mode. The accel device itself has a standby power consumption of 0.9 uA.

In Keil using the NVIC there are no pending interrupts.

The code segments I use:

static void twi_config()
{
    uint32_t err_code;

    nrf_drv_twi_config_t const config = {
       .scl                = ARDUINO_SCL_PIN,
       .sda                = ARDUINO_SDA_PIN,
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_LOWEST,
       .clear_bus_init     = false
    };

    err_code = nrf_twi_mngr_init(&m_nrf_twi_mngr, &config);
    APP_ERROR_CHECK(err_code);
}

static void sensor_init()
{	
    APP_ERROR_CHECK(nrf_twi_mngr_perform(&m_nrf_twi_mngr, NULL, kx022_init_transfers,
        KX022_INIT_TRANSFER_COUNT, NULL));
}

with

static uint8_t config_1[2] = {KX022_1020_REG_CNTL1, 				0x40 };	// KX022_1020_STANDBY | KX022_1020_HIGH_RESOLUTION
static uint8_t config_2[2] = {KX022_1020_REG_ODCNTL, 			 	0x02 };	// KX022_1020_OUTPUT_RATE_50_HZ

nrf_twi_mngr_transfer_t const kx022_init_transfers[KX022_INIT_TRANSFER_COUNT] =
{
    NRF_TWI_MNGR_WRITE(KX022_ADDR, config_1, 2, 0),
	NRF_TWI_MNGR_WRITE(KX022_ADDR, config_2, 2, 0)
}

In the current setup, I don't read any values, etc.

The initialization commands are taken from Kionix Getting Started, on page 2, first two steps from 1.

Any ideas on how to proceed or to further debug why it's not going to sleep mode?

Parents
  • Ok, but I didn't found on a packet timer concept in TWI transaction manager?

    For my application with the sensors mentioned I need the delay between to packets send to the device. It's not just one time when initializing the sensor, but every cycle it's necessary. So it would be good to have something like a "delay package" for a specific device handover to the TWI transaction manager to wait for that specific TWI address.

    In my current implementation I use RTC to do exactly this, but here I need to take care that the different device communications don't collide. So I need a combination of both, transaction manager and packet timer functionality.

    Is there something like this available? If not, the ticket can be closed because the problem is solved.

  • I would use either RTC or the app_timer. It seems that you have already solved this, so I would just use what you have. I do not believe there are any advantages of using the first option I discussed in my last comment.

Reply Children
No Data
Related