Hello, i have an issue with softdevice API combined with timeslot API. I use timeslot API to scan for packets one time (one time interval) with 30000us. Then before timeslot ends i call NRF_RADIO_SIGNAL_CALLBACK_ACTION_END and handle end of timeslot in my function:
void TSS_SocEventHandler(uint32_t evt_id, void * p_context)
{
switch (evt_id)
{
//The session has no remaining scheduled timeslots. If this event is triggered the application ends the session.
//Note that it is also possible to request new timeslots here(more on that later).
case NRF_EVT_RADIO_SESSION_IDLE:
{
if (m_timeslot_scanner.is_running)
{
m_timeslot_scanner.is_running = false;
m_timeslot_scanner.err_code = sd_radio_session_close();
if ((m_timeslot_scanner.err_code != NRF_SUCCESS) && (m_timeslot_scanner.error_handler != NULL))
{
m_timeslot_scanner.error_handler(m_timeslot_scanner.err_code);
}
}
m_timeslot_scanner.event.evt_type = TSS_IDLE;
m_timeslot_scanner.evt_handler(&m_timeslot_scanner.event);
} break;
//The session is closed and all acquired resources are released.
case NRF_EVT_RADIO_SESSION_CLOSED:
{
m_timeslot_scanner.session_open = false;
m_timeslot_scanner.event.evt_type = TSS_STOPPED;
m_timeslot_scanner.evt_handler(&m_timeslot_scanner.event);
} break;
//The requested timeslot could not be scheduled due to a collision with other activities.
//The application should request a new timeslot either at the earliest possible, or at the next normal position.
case NRF_EVT_RADIO_BLOCKED:
//The scheduled timeslot was cancelled by higher priority activity. The application should request a new timeslot.
case NRF_EVT_RADIO_CANCELED: // Fall through
{
if (m_timeslot_scanner.keep_running)
{
m_timeslot_scanner.err_code = sd_radio_request(tss_configure_earliest(NRF_RADIO_PRIORITY_NORMAL));
if ((m_timeslot_scanner.err_code != NRF_SUCCESS) && (m_timeslot_scanner.error_handler != NULL))
{
m_timeslot_scanner.error_handler(m_timeslot_scanner.err_code);
}
}
} break;
default:
{
} break;
}
}
I debug code and see, that after timeslot ends NRF_EVT_RADIO_SESSION_IDLE called and right after NRF_EVT_RADIO_SESSION_IDLE. But after that my HardFault handler called.
uint32_t* hf_sp;
uint32_t hf_ia;
void HardFault_Handler(void)
{
setLed(APP_LED_R, true);
hf_sp = (uint32_t *) __get_MSP(); // Get stack pointer
hf_ia = hf_sp[12]; // Get instruction address from stack
//hf_ia = *(hf_sp + 0x18);
while(1)
{}
}
hf_ia points on random address, so i cant see the last instruction. Without sd_radio_session_close() function all works perfect, but i feel that isn't right to do with radio session. I've read that " If you do not manage to do graceful shutdown by the end of the timeslot your application will hardfault.", but i use modified code from 11sdk example.
I use chip nRF52811, Softdevice 112 v7.0.1, SDK v16.0 and MDK v8.35.0
What reason for HardFault it could be?