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.

Parents
  • Are you able to reproduce this on a DK, or are you only seeing this on a custom board? If this is specific to a custom board, please check your soldering, as the SCK pin may be connected somewhere it shouldn't be, or the other way around. All the pins you're using should be okay, and if that's the only thing that has changed in your project code, everything points toward this being a HW issue.

    Best regards,

    Simon

Reply
  • Are you able to reproduce this on a DK, or are you only seeing this on a custom board? If this is specific to a custom board, please check your soldering, as the SCK pin may be connected somewhere it shouldn't be, or the other way around. All the pins you're using should be okay, and if that's the only thing that has changed in your project code, everything points toward this being a HW issue.

    Best regards,

    Simon

Children
  • I am testing it like this, without any external device attached to it.

    Please tell me its a hardware issue

  • 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. 

Related