nrf5340 spi power consumption

I am using the nrf5340 on a nrf7002fk dev kit. I am interested in low power operation so I am measuring the power consumed.

I am running a simple app:

int main(void)
{
while(1) { k_msleep(1000); }

return 0;
}

when I compile with this simple prj.conf file I measure 3uA current consumption

CONFIG_SERIAL=n
CONFIG_PM=y
CONFIG_PM_DEVICE=y

however when add "CONFIG_SPI=y" to the prj.conf file the current consumption jumps to 130 uA.

Is it possible to reduce this power consumption by suspending the SPI logic when it is not being used ?

  • Hello,

    Yes, this could be because the peripheral remains active. I recommend suspending the SPI device when it's not needed. See the Device Power Management section from the Academy.

    Kind Regards,

    Abhijith

  • Hi Menon

    Thankyou for your response.

    The academy link you provided uses driver level code. If possible, I would like to resolve the problem using my simple application level example before I move into drivers.

    I updated my code to create a pointer to the SPI device and then called pm_device_action_run() with PM_DEVICE_ACTION_SUSPEND. I expected this to suspend the SPI device. 

    I confirmed that the spim_suspend function was getting called inside the spi_nrfx_spim.c driver. However the current remained at 130 uA.

    I am not sure why the current is at 130 uA if the spi is suspended. Is there a step I am missing ?

    Here is the updated code and prj.conf files:

    static const struct device* const SpiDev = DEVICE_DT_GET(DT_NODELABEL(spi4));
    int main(void)
    {
    pm_device_action_run(SpiDev, PM_DEVICE_ACTION_SUSPEND);
    while(1) { k_msleep(1000); }

    return 0;
    }

    CONFIG_SERIAL=n
    CONFIG_SPI=y

    CONFIG_PM=y
    CONFIG_PM_DEVICE=y
    CONFIG_PM_DEVICE_RUNTIME=y

  • Hello,

    Can you check if its associated with GPIO pins  (SCK, MOSI, MISO, CS) remaining in an active state though you have suspended the SPI. Try reconfiguring these GPIOs to low-power states to confirm if they are the sources of the excess current you are seeing.

    Kind Regards,

    Abhijith

  • can you provide an example of configuring a GPIO pin to low-power state

  • Thanks Abhijith that was a useful suggestion.

    configuring the gpio0 pin11 (chip select for mx25r64) as an input reduced the current down to 3 uA.

    this was achieved with this overlay:

    /{
    inputs {
    compatible = "gpio-keys";
    mx_cs: mx_cs {
    gpios = <&gpio0 11 (GPIO_ACTIVE_LOW)>;
    label = "mx cs";
    };

    };
    };

    and this code:

    static const struct gpio_dt_spec mx_cs = GPIO_DT_SPEC_GET(DT_NODELABEL(mx_cs), gpios);

    gpio_pin_configure_dt(&mx_cs, GPIO_INPUT);

    changing the sck, mosi or miso pins did not make any difference to the current

Related