high current consumption when we are using Accelerometer lis3dh with SPI with no transfer at all on SPI

we have high current consumption when we are using Accelerometer lis3dh with SPI with no transfer at all on SPI

  • We have 2 SPI’s in the circuit. The first SPI is connecting to serial Flash. It consumes almost nothing when there is no transfer.
  • When we connect the accelerometer to the CPU in I2C, it consume low power (110uA) – This current is consumed between transferred ( 30uA “leakage current” + 400hz acc sample rate)
  • When we connect SPI to the accelerometer, it consume 800uA without any transfer.

 

 

The following code show the problem. No transfer is done on the accelerometer at

init_acc_spi(spim_handler);
    uninit_acc_spix();

static void init_acc_spi(nrfx_spim_evt_handler_t handler)
{
    nrfx_err_t err_code;

    nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG;

    // spi_config.frequency = NRF_SPI_FREQ_4M; (default rate)
    spi_config.frequency = NRF_SPI_FREQ_8M;

    spi_config.sck_pin  = HAL_SPI2_CLK;
    spi_config.ss_pin   = HAL_SPI2_SS;
    spi_config.mosi_pin = HAL_SPI2_MOSI;
    spi_config.miso_pin = HAL_SPI2_MISO;
    spi_config.mode     = NRF_SPI_MODE_0;

    err_code = nrfx_spim_init(&m_spim2, &spi_config, handler, NULL);
    if (NRFX_SUCCESS != err_code)
        NRFX_LOG_ERROR("%s nrfx_spim_init failed: %s", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
    APP_ERROR_CHECK(err_code);
}

static void uninit_acc_spix(void)
{
    nrfx_spim_uninit(&m_spim2);

    nrf_gpio_cfg_default(HAL_SPI2_CLK);
    nrf_gpio_cfg_default(HAL_SPI2_SS);
    nrf_gpio_cfg_default(HAL_SPI2_MOSI);
    nrf_gpio_cfg_default(HAL_SPI2_MISO);
}

all.

    init_acc_spi(spim_handler);

    uninit_acc_spix();

 

static void init_acc_spi(nrfx_spim_evt_handler_t handler)

{

    nrfx_err_t err_code;

 

    nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG;

 

    // spi_config.frequency = NRF_SPI_FREQ_4M; (default rate)

    spi_config.frequency = NRF_SPI_FREQ_8M;

 

    spi_config.sck_pin  = HAL_SPI2_CLK;

    spi_config.ss_pin   = HAL_SPI2_SS;

    spi_config.mosi_pin = HAL_SPI2_MOSI;

    spi_config.miso_pin = HAL_SPI2_MISO;

    spi_config.mode     = NRF_SPI_MODE_0;

 

    err_code = nrfx_spim_init(&m_spim2, &spi_config, handler, NULL);

    if (NRFX_SUCCESS != err_code)

        NRFX_LOG_ERROR("%s nrfx_spim_init failed: %s", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));

    APP_ERROR_CHECK(err_code);

}

 

static void uninit_acc_spix(void)

{

    nrfx_spim_uninit(&m_spim2);

 

    nrf_gpio_cfg_default(HAL_SPI2_CLK);

    nrf_gpio_cfg_default(HAL_SPI2_SS);

    nrf_gpio_cfg_default(HAL_SPI2_MOSI);

    nrf_gpio_cfg_default(HAL_SPI2_MISO);

}

 

  • When init_acc_spi is remarked - 110uA
  • When init_acc_spi is called -  800uA
  • When init_acc_spi and uninit_acc_spix is called : 200uA
Related