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

  • Hi

    I just know that I am launching app_timer and spi in the main(). How do I specify priorities?

    So I have to lower the app_timer priority and execute spi calls through app sched events.?

    App sched events must be launched/generated in the app_timer handler. Is that right?

    (This interrupt oriented approach os the sdk is very confusing and complex. Is there any document that describes all the different interrupt domains of the sdk? Is there any alternative programming approach (library?) where we can program using an kernel and multiple threads instead of interrupts)

    Thanks

Reply
  • Hi

    I just know that I am launching app_timer and spi in the main(). How do I specify priorities?

    So I have to lower the app_timer priority and execute spi calls through app sched events.?

    App sched events must be launched/generated in the app_timer handler. Is that right?

    (This interrupt oriented approach os the sdk is very confusing and complex. Is there any document that describes all the different interrupt domains of the sdk? Is there any alternative programming approach (library?) where we can program using an kernel and multiple threads instead of interrupts)

    Thanks

Children
No Data
Related