This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

spi_master_send_recv in an ISR

I am calling the spi_master_send_recv in a ISR from a GPIO using app_gpiote.c It causes a hardfault on APP_ERROR_CHECK(sd_nvic_DisableIRQ(p_spi_instance->irq_type)); Otherswise spi_master_send_recv works well when using the function from e.g. main(). Any hint...

  • most probably because your SPI interrupt priority is more than SVC priority and it will create a hardfault. SVC in softdevice is set to priority 2.

  • I am setting the gpio interrupt priority to APP_IRQ_PRIORITY_HIGH and the SPI priority to APP_IRQ_PRIORITY_LOW, when this occurs. Setting the priority for both to APP_IRQ_PRIORITY_LOW results in not getting any SPI interrupt when the spi_master_send_recv() is called in the ISR.

  • i think i have seen this in older posts that SPI transaction does not get completed if it is called from ISR. Better not do it that way for now. Anyways if your GPIO interrupt priority is high than you cannot make any SVC calls from it, that explains your hardfault. You could set a flag in ISR and call spi_master_Send_recv from main context while polling on that flag. It wont be that difficult to achieve this.

Related