SPIM start task not functioning normally when migrating from 2.5.0 to 2.6.0

My SPIM seems to stopped working when migrating from NCS 2.5.0 to 2.7.0, so I decided to downgrade to 2.6.0, and it seems the issue is still there. When migrating to 2.6.0, all the changes I have made during the migration that might impact the driver is for GPIOTE due to the API changes, so I don't understand what could be causing the change in behavior of the hardware.... I checked the change log, and I couldn't really find anything that impacts the behavior of these modules. If anyone is also going through the migration and can provide any insights or help it would be greatly appreciated. Thanks! 

  • I have found the issue however I am unsure why it is only happening in 2.6.0/2.7.0. Apparently, the TXD.MAXCNT register for some reason did not take in the tx_length value in nrfx_spim_xfer_desc_t after calling nrfx_spim_xfer, so I had to manually add that in. (shown below)

    nrfx_spim_xfer_desc_t spim_xfer_desc = {
        .p_tx_buffer = NULL, 
        .tx_length = tx_len,
        .p_rx_buffer = NULL,
        .rx_length = 0
    };
    
    err = nrfx_spim_xfer(
            spim,
            &spim_xfer_desc,
            NRFX_SPIM_FLAG_TX_POSTINC | NRFX_SPIM_FLAG_HOLD_XFER | NRFX_SPIM_FLAG_NO_XFER_EVT_HANDLER | NRFX_SPIM_FLAG_REPEATED_XFER);
    if (err != NRFX_SUCCESS) {
        return false;
    }
    
    NRF_SPIM_Type *spim1_reg = (NRF_SPIM_Type *)NRF_SPIM1_BASE;
    spim1_reg->TXD.MAXCNT = tx_len;
    

  • If you are seeing this only after migrating to later versions of SDK, it might be a possible bug in the API. 

    I would recommend you to put a breakpoint in nrfx_spim_xfer and step in the code since I can see in modules\hal\nordic\nrfx\drivers\src\nrfx_spim.c->nrfy_spim_buffers_set the the MAXCNT register is set for TXD if you are using the easyDma version of the SPI. Find out by stepping line by line as to why that configuration did not get set. I am guessing there might be some configuration that we might have missed? Just trying to avoid future surprises and bugs with the workaround you had to make this work. Or maybe this is a bug at our end. In any case it would be good to know for sure why this happened.

  • The issue seems to coming from NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED which is resetting the xfer_dest.tx_length and rx_length to 0 in nrfx_spim.c:802. On 2.5.0 this option seems to be turned off by default. On 2.7.0, not having this option gives me the error described in one of my other post ( Multiple IRQ registration build error when migrating from NCS 2.5.0 to 2.7.0), so I can only set NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED = n to fix this issue.

Related