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

Related