This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Wrong behavior of SPI slave on Zephyr RTOS when last bit of miso signal is set to 1 (NRF52840, NRF52832)

Hello everyone,

I have found the following issue in the behavior of the SPI driver:

having connected an NRF52840 as an SPI master which is set to receive 22 bytes from an SPI slave on NR52832

if the last bit received by the master is set to one the MISO signal looks distorted as shown in the pictures

Although the received data are correct. but the MISO signal should go back to Idle once the clock of the master has stopped

Thank you

  • Hi,

     

    Although the received data are correct. but the MISO signal should go back to Idle once the clock of the master has stopped

    MISO = Master input - Slave Output

    So it is the slaves job to drive this pin, but; the slave is also only active during the "CSN active" period. What you are seeing here is a floating GPIO and how that looks when discharged through a probe.

    While I agree that a GPIO should always have a defined level, I would not categorize this as wrong behavior.

     

    In general, floating GPIOs should be avoided, as they can cause excessive current leakage in sleep modes. I'd recommend that you either enable a pull-resistor in the pad (usually on the master side), or add one externally to pull it to the inactive level.

    You can set this in your dts:

    https://github.com/NordicPlayground/fw-nrfconnect-zephyr/blob/master/dts/bindings/spi/nordic,nrf-spim.yaml#L11

    example $(board).overlay file:

    &spi3 {
        compatible = "nordic,nrf-spim";
    	status = "ok";
    	sck-pin = <10>;
    	mosi-pin = <11>;
    	miso-pin = <12>;
        miso-pull-down;
    };

    Since "miso-pull-down" is a boolean property in dts, you shall set it by calling it without assigning a value. 

    Kind regards,

    Håkon

  • Thank you very much for your answer.

    I guess I need an external resistor because the miso-pull-down option is already set for me on the master side  

Related