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

SPI not operating correctly at high speeds

Hello,

I'm having issues getting my SPI to work at high transfer speeds.
I have my pins configured to have high drive.

SPI is set to MSB first, Mode 0. 

Colors:

Brown = SCK

Red = MOSI

Orange = MISO

Yellow = CS

This is a transaction on 125kbps, working  fine.

This is at 500kbps, not getting all clock pulses.

This is at 8Mbps and yeah... nothing here but the chip select.

Can anyone help me getting this work at higher speeds?

Kind regards.

  • Clock speed is only one consideration; the other is capacitive load on the outputs. Long leads such as these inevitably slow the clock edges and so therefore High Drive is required.

    Try this:

    #define SPI_MOSI 19
    #define SPI_CLK   7
    #define SPI_CS   25
    
    // Init first then set High Drive 0 and 1 (something like this):
    APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));
    // Boost drive to MOSI and CLK and CS to sharpen clock edges and timing
    nrf_gpio_cfg(SPI_MOSI, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_CONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_H0H1, NRF_GPIO_PIN_NOSENSE);
    nrf_gpio_cfg(SPI_CLK,  NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_CONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_H0H1, NRF_GPIO_PIN_NOSENSE);
    nrf_gpio_cfg(SPI_CS,   NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_CONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_H0H1, NRF_GPIO_PIN_NOSENSE);
    

  • I have my pins configured to have high drive.

    I've done that already.

    Tested it with standard drive as well.

    It might be due to the wires and everything but in my opinion this shouldn't make that much of a difference.

    If my SPI device is located at the other side of my circuit board do I get the same behavior as having it like I have now with the long wires? 

    I've tried it with a simple Arduino pushing out at 8 MHz to compare to see if the analyzer is the problem but it isn't. The Arduino has proper clocks instead of a sine that the NRF is producing. 

  • Hi Tom

    Seeing as the SCK signal seems to be the source of the problem here, have you tried switching this to be any other GPIO, to make sure that it isn't specific to that one pin (just in case there is any issues with the soldering or connection on that GPIO.

    Best regards,

    Simon

  • On 52832 DK, pin 7 is a CTS signal of debug UART - this may cause an issue.

  • This is clock on Pin 8, still the same.

    On 52832 DK, pin 7 is a CTS signal of debug UART - this may cause an issue.

    I have turned off the UART debug output in the CMSIS config wizzard. I always use the RTT option.

    Pin 11 also looks the same.

Related