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
Parents
  • Hi Alon,

    Do you use any pull up resistors in your SPI wire connections ? 

    Can you share the schematic on how you connect I2C and SPI to the chip ? 

    Also have you check if this errata is applied for you ? 

  • 1) SPI driver is implemented on version 1.6.4 and works with DMA

    2) SPI consume a lot of current, even if it not actually transfer data :

    - the other SPI to flash doesn't consume current if no data is transfered.

    - even if only initializing the SPI using nrfx_spim_init cause the current consumption to increase significantly

    - it seems the driver init function assert the CLK, MISO and MOSI to ground and this cause

    - changing the SPI mode clock to mode 3 - change the CLK default to high

    - changing NRFX_SPIM_MISO_PULL_CFG to 0 - changed the default MISO to high

    - MOSI is set to ground and I think this cause a problem.

    - calling nrfx_spim_uninit reduce the current but not all of the current before the SPI initialized

    - also setting all SPI to input with PULLUP reduce the current but not all of the current before the SPI initialized


  • Hi Alon, 

    The errata is applied only for some built code and the workaround is usually implemented already in the SDK. So most likely it's not the issue. 

    In your case it seems the pullups is causing the trouble ? 
    Is it possible to remove the pullups and use the internal pullup on the pin when you are communicate via I2C  ? 
    On SPI you don't need to use pullups. 

  • in I2C, we doesn't have any problems. when no transfer of data, there is no currrent consumptiomn.

    the problem is only in SPI.

Reply Children
Related