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

Delay time bewteen two transfer

Hi guys

I am using SPI example code in SDK11 (./nRF5_SDK_11.0.0_89a8197\examples\peripheral\spi) with nRF51 DK.

It works fine when send first data.

But it get in trouble when I send data(nrf_drv_spi_transfer) continuously.

I find it return ERROR_CODE(NRF_ERROR_BUSY).

So I add delay(1ms) between two nrf_drv_spi_transfer.

Then it works fine again.

Are there any information of datasheet or advising value to set delay time bewteen two transfer(not only SPI, but also I2C, UART...)

I set frequency as NRF_SPI_FREQ_125K in SPI example.

Thanks.

  • Hello pikachu

    The time it takes for a transfer depends on your transfer rate, in your case 125kb/s, and the amount of data you are transmitting. In the example it transmits the text "Nordic", where each letter is represented with 8 bits. This should give a minimum transfer time of approximately 6*8/125000=384us.

    In the spi example you refer to you have the

        while (!spi_xfer_done)
        {
            __WFE();
        }
    

    In the main loop. This flag is set in the spi_event_handler which is called upon an spi event, such as transfer complete. This way it waits until the previous transfer is complete before attempting a new one. I recommend reading the SPI section of the nRF51 reference manual, for specifics on timing you can see the electrical specifications of the nRF51xxx product specification (the development kit uses nRF514222.

    Best regards

    Jørn Frøysa

Related