Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI very high power consumption with SDK14.2.0 but low with SDK12.3.0

Hi,

SPI use with SDK14.2.0 leads to very high power consumption (around 400µA) on nRF52832 (QFAA). The same piece of code running with SDK12.3.0 has much lower power consumption (below 10µA).

#include "nrf_drv_spi.h"
#include "app_util_platform.h"
#include "nrf_gpio.h"
#include "nrf_delay.h"
#include "app_error.h"
#include <string.h>


#define LED_RED 	29
#define LED_GREEN	30
#define LED_BLUE	31

#define SPI_SS		6
#define SPI_MISO	5
#define SPI_MOSI	4
#define SPI_SCK		3

#define SPI_INSTANCE  0 /**< SPI instance index. */
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);  /**< SPI instance. */



int main(void)
{
	// Leds init
	nrf_gpio_cfg_output (LED_RED);
	nrf_gpio_pin_set(LED_RED);
	nrf_gpio_cfg_output (LED_GREEN);
	nrf_gpio_pin_set(LED_GREEN);
	nrf_gpio_cfg_output (LED_BLUE);
	nrf_gpio_pin_set(LED_BLUE);

	// Spi init
    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = SPI_SS;
    spi_config.miso_pin = SPI_MISO;
    spi_config.mosi_pin = SPI_MOSI;
    spi_config.sck_pin  = SPI_SCK;
#ifdef SDK_12_3
    nrf_drv_spi_init(&spi, &spi_config, NULL);
#else
    nrf_drv_spi_init(&spi, &spi_config, NULL, NULL);
#endif

    // Read Spi
    uint8_t address = 0x0f;	// WHO_AM_I code
    uint8_t read_buf[2];
    address |= 0x80;	// Read operation
    nrf_drv_spi_transfer(&spi, &address, 1, read_buf, 2);

    // Check answer
    if (read_buf[1] == 0x33)
    	nrf_gpio_pin_clear(LED_GREEN);
    else
    	nrf_gpio_pin_clear(LED_RED);
    nrf_delay_ms(1000);
	nrf_gpio_pin_set(LED_GREEN);
	nrf_gpio_pin_set(LED_RED);

	// Uninit Spi
	nrf_drv_spi_uninit(&spi);

    // Enter main loop
    for (;;)
    {
    	__WFE();
    }
}

Could you please investigate this issue ?

Thanks in advance for you help,

Joris

Parents
  • Hi all,

    The higher power consumption comes from the pullup on MISO pin. On SDK 12.3.0, the pin is always configured with no pullup. On SDK 14.2.0, the pullup is configurable (NRF_SPI_DRV_MISO_PULLUP_CFG, which was set to 1 in my sdk_config). I set it to 0, power consumption is now below 10µA.

    Why this pullup is drawing so much current ?

    Best regards,

    Joris

  • Seems you have identified the issue then, likely the MISO pin is pulled low by the slave spi in this case, thereby there is a leakage current through the internal pull-up resistor on-chip. The reason the internal pull-up have been introduced on newer SDK is to make sure that the pin doesn't float, but do have a defined level when not in use. Floating input pins can create a range of excessive current consumption issues over time, so having a pull up (or pull Down is likely better in this case) when not in use is a good idea in general.

Reply
  • Seems you have identified the issue then, likely the MISO pin is pulled low by the slave spi in this case, thereby there is a leakage current through the internal pull-up resistor on-chip. The reason the internal pull-up have been introduced on newer SDK is to make sure that the pin doesn't float, but do have a defined level when not in use. Floating input pins can create a range of excessive current consumption issues over time, so having a pull up (or pull Down is likely better in this case) when not in use is a good idea in general.

Children
Related