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

s110-sd-v8 sd_flash_page_erase hardfault

my chip is nrf51822,I used s110-sd-v7, it's work. I switched the software to s110-sd-v8, GPIO interrupt is high priority (APP_IRQ_PRIORITY_HIGH). I erase the flash (pstorage_raw_clear) when GPIO irq is coming. it occured hard fault irq at sd_flash_page_erase . And the softdevice is enable. Afterwards, I set the priority of GPIO interrupt to low, it's work. Otherway BLE occured IRQ, it alse need erase the flash, and occoured hard fault irq at sd_flash_page_erase. what can i do? would you help me? thank you very much! image description

  • You can't call softdevice functions from APP_IRQ_PRIORITY_HIGH handlers because the underlying SVC call us at priority 2 (which is lower than APP_IRQ_PRIORITY_HIGH) and the cortex m0 hardfaults if you try to do a SVC call with from a context which has higher interrupt priority. This is because SVC calls execute immediately and the chip can't switch from higher priority to lower priority, so it has no choice but to hardfault.

    Only call sd functions from APP_IRQ_PRIORITY_LOW or from the main thread context.

Related