Unable to pull SPI MISO line down via device tree configuration

We have an nRF52833-based board, software is based on Zephyr and Nordic SDK 2.1.2.
One of the SPI interfaces connected to external flash (Winbond W25Q80DVSNIG)
Board is battery powered, so power draw is an issue.
While debugging board's excessive power consumption, we discovered that pulling down MISO pin (connected to FLASH DO pin) has effect of dramatically reducing sleep current.
For obvious reasons would like to avoid re-spinning the board, so trying to achieve the same effect (MISO being pulled down) in firmware
So, I added "miso-pull-down" to board's DTS file

&spi2 {
    compatible = "nordic,nrf-spi";
    status = "okay";
    pinctrl-0 = <&spi2_default>;
    pinctrl-1 = <&spi2_sleep>;
    pinctrl-names = "default", "sleep";
    miso-pull-down;
    cs-gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
    label = "CYCLONE_SPI";
    w25q80dv: w25q80dv@0 {
        compatible = "jedec,spi-nor";
        label = "W25Q80DV";
        reg = <0>;
        spi-max-frequency = <1000000>;
        size = <0x800000>;
        has-dpd;
        t-enter-dpd = <3000>;
        t-exit-dpd = <30000>;
        jedec-id = [ef 40 14];
    };
};

But instead of  being pulled down, the pin seems to float.
Tried "miso-pull-up" - same result.
I have

CONFIG_PM=y
CONFIG_PM_DEVICE=y

in prj.conf and low power mode enabled for this interface in boards DTSI file
    spi2_sleep: spi2_sleep {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
                    <NRF_PSEL(SPIM_MOSI, 1, 2)>,
                    <NRF_PSEL(SPIM_MISO, 0, 11)>;
                    low-power-enable;
        }          
    };


I also put the flash itslef to sleep when not in use by sending it command over SPI (0xB9)
but that seems to have only modest effect on sleep current (5-7 uA reduction), comparing to pulling down MISO (30 uA reduction).
Even probing PIN with the scope causes this large power reduction.

So, the question - how do I properly configure SPI controller to pull down MISO pin while in sleep mode (instead of floating it) ?

 

Parents
  • Hello,

    Since SDK v2.0.0, the pull configuration has to be applied to the pinctrl node. I'm not sure why the miso-pull-down property was still present in SDK v2.1.2, but it has since been removed. In any case, the additional current consumption may be caused by leakage due to the MISO input becomes floating when the SPI flash enters the power-down state.

    Here is an example on how you can enable pull-up on MISO with the 'bias-pull-up' property in your devicetree:

    	spi2_default: spi2_default {
    		group1 {
    			psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
    				<NRF_PSEL(SPIM_MISO, 1, 2)>;
    		};
    
    		group2 {
    			psels = <NRF_PSEL(SPIM_MOSI, 0, 11)>;
    			bias-pull-up;
    		};
    	};
    
    	spi2_sleep: spi2_sleep {
    		group1 {
    			psels = <NRF_PSEL(SPIM_SCK, 0, 19)>,
    				<NRF_PSEL(SPIM_MOSI, 0, 20)>,
    				<NRF_PSEL(SPIM_MISO, 0, 21)>;
    			low-power-enable;
    		};
    	};
     

    Note: the SPI nor driver does not implement PM device power states or change the pin configuration. This means that only the "spi2_default" configuration will be used. 

    Best regards,

    Vidar

  • Hi Vidar !
    Appreciate prompt response.
    So, given the fact that my flash is NOR and I need MISO pulled down, my pinctrl.dtsi should look like this ?

    spi2_default: spi2_default {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
            <NRF_PSEL(SPIM_MOSI, 1, 2)>;
            low-power-enable;
        };
        group2 {
            psels = <NRF_PSEL(SPIM_MISO, 0, 11)>;
            low-power-enable;
            bias-pull-down;
        };
    };

  • Hi, no problem. The 'low-power-enable' property is used when you want to configure the pins to their reset state (input, disconnect) after suspending the SPI peripheral. However, it cannot be used while the peripheral is enabled. Therefore, you should remove 'low-power-enable' for spi2_default. Everything looks correct apart from that.

  • Hi Vidar, 
    That did the trick, sleep current dropped to where we want it to be.
    Thank you so much,
    Alex

Reply Children
Related