SPI timeout when calling from ISR

I currently have an application that buffers signals by recording with an ADC on an interrupt and then retransmits the data using an external DAC through SPI. When I call any SPI functions such as spi_write from anywhere outside of an ISR it works as expected and successfully transmits the data. When spi_write is called during the execution of an ISR it always results in an error code of 116 which implies the SPI writing is timing out. Is there something that I am missing about using SPI in interrupts? If this is not a simple fix and I need to provide code just let me know.

Parents
  • I've hit this same issue but this discussion doesn't offer any advice on what you should do instead.


    So for anyone else stumbling across this post, I've fixed it on my project by using an application work queue to get my SPI reads done as quickly as possible after exiting the ISR. My ISR just calls k_work_submit_to_queue to kick off my function that performs the SPI reads.

    Good video describing work queues here:

    www.youtube.com/watch

    Another devzone thread with a chunk of code you can copy and use to create your own work queue (currently it's the bottom post in the discussion) here:

    devzone.nordicsemi.com/.../388632

    You could also probably use the system work queue, but making an application queue lets me set the priority.

Reply
  • I've hit this same issue but this discussion doesn't offer any advice on what you should do instead.


    So for anyone else stumbling across this post, I've fixed it on my project by using an application work queue to get my SPI reads done as quickly as possible after exiting the ISR. My ISR just calls k_work_submit_to_queue to kick off my function that performs the SPI reads.

    Good video describing work queues here:

    www.youtube.com/watch

    Another devzone thread with a chunk of code you can copy and use to create your own work queue (currently it's the bottom post in the discussion) here:

    devzone.nordicsemi.com/.../388632

    You could also probably use the system work queue, but making an application queue lets me set the priority.

Children
No Data
Related