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

SPI Master from interrupt

I'm using the SPI Master driver code on the nrf52 using EasyDMA to talk to a SPI slave (Adesto Flash chip)

I can successfully initialize, read, write and read-back from the flash chip from MAIN.

However, if I try to instead read from a timer interrupt the firmware hangs after a successful call to nrf_drv_spi_transfer. It never gets to the callback, it instead resets without hitting the assert handler.

Is there a trick? Do I need to de-init and re-init? Is there something that could be throwing off my callback? I am also using the SAADC and timeslots and a second SPI instance.

  • I assume you use spi driver in non-blocking mode as you talk about a callback function.

    When you say that you don't hit the assert handler do you mean the app_error_fault_handler? This should be hit if there is an error condition, and it will reset the chip if DEBUG is defined. If DEBUG is not defined the code will stop inside app_error_save_and_stop.

    You should be able to call nrf_drv_spi_transfer function inside an interrupt. Could you update the question with code showing the interrupt where you call this function?

  • Thanks Ole -

    I figured it out. I was working from the example code and while it used the callback, it was also still using the the WFE loops. I've made it all non-blocking now and things are working. Thanks.

Related