how to close spi in low power state? (52840)

Dear, I'm developing on nordic 52840 with ncs2.6.1. 

I found that the Current will reach to 600+uA in k_sleep state by enable SPI in device_tree and if i disable the spi, the current will increase to 100uA.

I have try to enable CONFIG_PM_DEVICE(As far as i know that CONFIG_PM is not support by nrf52840 in ncs2.6.1) and call the function 

pm_device_action_run(spi1_dev, PM_DEVICE_ACTION_SUSPEND)
before k_sleep, but there is no difference in the results。
here is my dts config:(i have removed spi0 which was used by twi0)
&spi1 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	pinctrl-0 = <&spi1_default>;
	pinctrl-1 = <&spi1_sleep>;
	pinctrl-names = "default", "sleep";
	cs-gpios = <&gpio0 14 GPIO_ACTIVE_LOW>, <&gpio0 17 GPIO_ACTIVE_LOW>;
	imu: imu@0 {
		compatible = "imu";
		lable = "imu";
		reg = <0>;
	};
	sdcard: sdcard@1 {
		compatible = "sdcard";
		reg = <1>;
		lable = "sdcard";
	};

	status = "okay";
};
and the main() function is just call a k_sleep without doing anything else.
Parents
  • In your application, before calling k_sleep(), explicitly disable the SPI interface using the spi_release() function.
    This will ensure that the SPI interface is not active and consuming power during the low-power state.
    Here's an example of how you can do this:

    #include <device.h>
    #include <drivers/spi.h>

    void main(void)
    {
    const struct device *spi_dev = DEVICE_DT_GET(DT_NODELABEL(spi0));

    while (1) {
    /* Disable the SPI interface */
    spi_release(spi_dev);

    /* Enter low-power state */
    k_sleep(K_SECONDS(5));

    /* Re-enable the SPI interface when needed */
    // spi_configure(spi_dev, ...);
    // spi_transceive(spi_dev, ...);
    }
    }

    Edited by slope 1 day ago

Reply
  • In your application, before calling k_sleep(), explicitly disable the SPI interface using the spi_release() function.
    This will ensure that the SPI interface is not active and consuming power during the low-power state.
    Here's an example of how you can do this:

    #include <device.h>
    #include <drivers/spi.h>

    void main(void)
    {
    const struct device *spi_dev = DEVICE_DT_GET(DT_NODELABEL(spi0));

    while (1) {
    /* Disable the SPI interface */
    spi_release(spi_dev);

    /* Enter low-power state */
    k_sleep(K_SECONDS(5));

    /* Re-enable the SPI interface when needed */
    // spi_configure(spi_dev, ...);
    // spi_transceive(spi_dev, ...);
    }
    }

    Edited by slope 1 day ago

Children
No Data
Related