SPIM xfer delay

Hi,

I'm using nRFConnect 2.6.1 SDK on a nRF52833 with the speed build optimization.

I got two peripherals on the same SPI which is SPIM3. It is configured at 32MHz and the 2 CS are controlled through PPI.

The first peripheral sends a DataReady (DRDY) signal, CS1 is cleared with a PPI then the GPIOTE handler sends the first communication.

With the end_event, a second PPI sets CS1 and toggle CS2, then the SPIM handler sends the second communication.

The same end_event PPI sets CS1 with no effect and toggle CS2. Both CS return to a high state.

Due to the PPI control of both CS, the 2 handlers contain only the nrfx_spim_xfer() instructions and my main loop is empty : 

When observing CLK (yellow), CS2(green) and DRDY(blue) on a scope here is the result : 

There is a huge delay before every transmission, approximately 17us. Since the transfer only contains 28 bytes and the SPIM is supposed to use EasyDMA, why is there such a delay ? 

  • Hello,

    The delay likely results from the time required to reach the spim_handler ISR (including interrupt latency and the processing of the interrupt handling code), as well as the configuration of the next transfer within the ISR. The transfer itself is performed without CPU involvement.

    If this is really timing critical, you may be able to reduce the delay by starting setting up the subsequent transfer from the trigger_handler() ISR.

    void trigger_handler(..) 
    {
        nrfx_spim_tranfer(&spim_adc, &xfer_adc, NRFX_SPIM_FLAG_NO_XFER_EVT_HANDLER);
    
        while (!nrf_spim_event_check(&spim_adc, NRF_SPIM_EVENT_END))
        {}
    
        nrfx_spim_tranfer(&spim_adc, &xfer_ram, NRFX_SPIM_FLAG_NO_XFER_EVT_HANDLER);
    }

    Best regards,

    Vidar

  • Hello,

    I tried this solution before but it didn't knew about this event test so the two SPI were colliding.

    It works great, the delay between the two transmissions is reduced from 16 to 5us, thank you so much.

    In my first program the first transfer was triggered by PPI and i had the same problem of collision. I will try with this test, to see the maximum frequency of the system.

    Thank you so much,

    Quentin.

Related