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

SPI + sd_app_evt_wait and nested interrupts?!

sdk15, SES, SD132

Hi
I am using an SPI slave with nrf52 (master)

I launch in the main() and I also initialize the SPI slave on main.
I also configured an app timer and when it fires I read the SPI slave using nrf_drv_spi_transfer (burst read) for 9 bytes.
and then I wait for the spi transfer like this:

while (!spi_xfer_done)
{

    uint32_t err_code = sd_app_evt_wait();
    printf("SPI status=> %d count %d\r\n", err_code,count);
}

The problem is that the loop never ends. It seems that it is an interrupt nesting issue.
Can anyone tell me if it could be an interrupt nesting problem and if so how can I solve the problem?

Thanks

Alex

Parents
  • Hi,

    Are your app_timer running at higher or equal priority to the SPI? If it does, the SPI IRQ handler will be blocked by the interrupt you are already in. You may also face issues if you do softdevice calls from high priority interrupt context.

    In general, it is not recommended to stay long in interrupts, like doing blocking calls. If you set a flag in the handler and start the transfer in the main context, that will normally be a much safer solution.

    Best regards,
    Jørgen

Reply
  • Hi,

    Are your app_timer running at higher or equal priority to the SPI? If it does, the SPI IRQ handler will be blocked by the interrupt you are already in. You may also face issues if you do softdevice calls from high priority interrupt context.

    In general, it is not recommended to stay long in interrupts, like doing blocking calls. If you set a flag in the handler and start the transfer in the main context, that will normally be a much safer solution.

    Best regards,
    Jørgen

Children
Related