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

Hard fault when spi msg receive during ble scanning.

Hi,

I setup the nrf51 as in central mode and talking to an ARM Cortex mcu via spi bus with the NRF51 set to slave. The spi communication working fine, but when I star scanning and the ble event start coming in, I getting hardfault when I try to sent spi msg from the ARM over. It seem to be the spi interupt causing the hard fault when ble event coming in from softdevice. My handle for the spi interupt is very simple, very time I got SPI_SLAVE_XFER_DONE, I call the spi_slave_buffers_set to make it go to the next state as require to.

I wonder if I have missed something, do I need to do anything special for the spi interupt handle when ble events coming in?

I'm using SDK 9 and s130.

Thanks, Kevin.

Parents
  • Did you set any priority of your SPI interrupt? if not then it is set to default highest priority and that most probably will cause an assert in the softdevice because softdevice does not like anything else at the priority in which it will work.

    If you have SPI priority to APP_PRIORITY_HIGH, then it is OK to the softdevice but as soon as you make any SVC calls (calls to sd_xxxx functions) then it will hardfault. This seems to be more probable for me that your SPI interrupt priority is high and somewhere it makes sd_call (most probably enter critical section using softdevice API)

  • I use the api function spi_slave_init() to set up my spi bus. This function set IRQ priority to APP_IRQ_PRIORITY_LOW.

    My spi interupt handle is very simple, it just call spi_slave_buffers_set() when I got SPI_SLAVE_XFER_DONE.

    In my code, if scanning not running, then everything is ok. After scan start, and ble events start coming in from the sd, when I try to sent the spi msg from the Cortex, the hard fault occurs.

Reply
  • I use the api function spi_slave_init() to set up my spi bus. This function set IRQ priority to APP_IRQ_PRIORITY_LOW.

    My spi interupt handle is very simple, it just call spi_slave_buffers_set() when I got SPI_SLAVE_XFER_DONE.

    In my code, if scanning not running, then everything is ok. After scan start, and ble events start coming in from the sd, when I try to sent the spi msg from the Cortex, the hard fault occurs.

Children
No Data
Related