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

HardFault softdevice_handler_init

Using SD_110 v6 I get a hardfault on the final call to sd_nvic_EnableIRQ(SWI2_IRQn); sd_softdevice_enable before that returns success. Any idea why enabling interrupt could cause hardfault?

int main(void)
{
	
	NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
	NRF_CLOCK->TASKS_HFCLKSTART = 1;
	while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {};
	NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
	
	 //uint32_t err_code;

    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM, false);
}
Parents
  • what is the priority of the interrupt? Make sure it is APP_LOW or APP_HIGH, anything else will cause unpredictable behavior. use SD_EVT_IRQn define for compatibility.

    err_code = sd_nvic_SetPriority(SD_EVT_IRQn, NRF_APP_PRIORITY_LOW);
    APP_ERROR_CHECK(err_code);
    err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn);
    APP_ERROR_CHECK(err_code);
    
Reply
  • what is the priority of the interrupt? Make sure it is APP_LOW or APP_HIGH, anything else will cause unpredictable behavior. use SD_EVT_IRQn define for compatibility.

    err_code = sd_nvic_SetPriority(SD_EVT_IRQn, NRF_APP_PRIORITY_LOW);
    APP_ERROR_CHECK(err_code);
    err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn);
    APP_ERROR_CHECK(err_code);
    
Children