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

Slower SPI working on all GPIO pins?

I am interfacing nrf52840DK to a SPI module soldered by myself on a custom PCB adapter, connected by wires. This is the init code:

    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = SPI_SS_PIN;
    spi_config.miso_pin = SPI_MISO_PIN;
    spi_config.mosi_pin = SPI_MOSI_PIN;
    spi_config.sck_pin  = SPI_SCK_PIN;
    spi_config.mode = NRF_DRV_SPI_MODE_1;
    spi_config.frequency=NRF_DRV_SPI_FREQ_125K;

    // blocking mode
    APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, NULL, NULL));

I have two issues with the default spi driver from Nordic (the one working with function nrf_drv_spi_transfer):

1. I'm using FREQ_125K but it still seems too fast (responses from slave doesn't contain expected data) and I can't find a way to decrease frequency lower than 125Kbps, given that it can only be one of these:

typedef enum
{
NRF_DRV_SPI_FREQ_125K = NRF_SPI_FREQ_125K, ///< 125 kbps.
NRF_DRV_SPI_FREQ_250K = NRF_SPI_FREQ_250K, ///< 250 kbps.
NRF_DRV_SPI_FREQ_500K = NRF_SPI_FREQ_500K, ///< 500 kbps.
NRF_DRV_SPI_FREQ_1M = NRF_SPI_FREQ_1M, ///< 1 Mbps.
NRF_DRV_SPI_FREQ_2M = NRF_SPI_FREQ_2M, ///< 2 Mbps.
NRF_DRV_SPI_FREQ_4M = NRF_SPI_FREQ_4M, ///< 4 Mbps.
NRF_DRV_SPI_FREQ_8M = NRF_SPI_FREQ_8M ///< 8 Mbps.
} nrf_drv_spi_frequency_t;

2. I can't use other GPIO pins to work as CSN,SCK,MISO and MOSI

How can I decrease speed lower than 125kbps?

How can I use other GPIO pins?

Do I need a software spi implementation?

Can you suggest a one working with nrf52?

Thank you in advance!

Parents
  • What is the SPI slave?

    it still seems too fast (responses from slave doesn't contain expected data)

    There are plenty of other things - apart from speed - which could cause that.

    What do the slave specifications say about speed, and any other timing requirements?

    Are you sure that your expectations are correct?

    Have you looked at the wires with a scope to confirm that the signals are OK ?

    EDIT

    Also:

    SPI module soldered by myself

    Are you sure your soldering is all good and correct, and the connections are correct, and nothing has been damaged in the process?

    These kinds of things are where the scope test comes in ...

  • The slave accepts maximum speed of 10Mhz, but there is no minimum speed declared.

    The slave is a SPI mode 1 (CPOL=0, CPHA=0)

    I'm trying to read R/W registers after writing, even after some time, but there is not the value sent.

    The response for a same register is always the same, does not change, but it is isn't neither the default value, neither the written value. So I thought to a SPI problem.

    Checking with a scope on MOSI I can see correct bits are sent to the connector soldered on the custom PCB adapter where module is soldered. PCB adapter traces have 0.25mm width. Is it enough?

    Checking MISO with a scope at connector soldered on PCB adapter, bits are the same for the same registers, but they are neither the default value expected after module reset, neither the written value after spi_write register operation.

    So I was thinking to decrease speed.

    In any case I need spi on different gpio pins from Hardware SPI pins.. 

    EDIT: Yes, I checked with multimeter that all pins are connected and no short circuits are present.

    EDIT2: I tried with 3 modules of the same type soldered on different version of a same PCB adapter: same behaviour

Reply
  • The slave accepts maximum speed of 10Mhz, but there is no minimum speed declared.

    The slave is a SPI mode 1 (CPOL=0, CPHA=0)

    I'm trying to read R/W registers after writing, even after some time, but there is not the value sent.

    The response for a same register is always the same, does not change, but it is isn't neither the default value, neither the written value. So I thought to a SPI problem.

    Checking with a scope on MOSI I can see correct bits are sent to the connector soldered on the custom PCB adapter where module is soldered. PCB adapter traces have 0.25mm width. Is it enough?

    Checking MISO with a scope at connector soldered on PCB adapter, bits are the same for the same registers, but they are neither the default value expected after module reset, neither the written value after spi_write register operation.

    So I was thinking to decrease speed.

    In any case I need spi on different gpio pins from Hardware SPI pins.. 

    EDIT: Yes, I checked with multimeter that all pins are connected and no short circuits are present.

    EDIT2: I tried with 3 modules of the same type soldered on different version of a same PCB adapter: same behaviour

Children
Related