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

timeslot extension never succeed

Hi,

I have a working scanner and manage to require timeslots with the below timings.

Interval 300ms, scan window 50ms, Timeslot length 10ms.

image description

But when i try to request timeslot extensions as low as 1ms it never works.

nrf_radio_signal_callback_return_param_t * ts_radio_callback(uint8_t signal_type)
{
	//NRF_LOG_DEBUG("TS_RADIO_CB:%d\r\n", signal_type);
	switch(signal_type)
	{
	case NRF_RADIO_CALLBACK_SIGNAL_TYPE_START: {
		//Start of the timeslot - set up timer interrupt
		// Set up rescheduling
		NRF_TIMER0->INTENSET = (1UL << TIMER_INTENSET_COMPARE0_Pos);
		NRF_TIMER0->CC[0]    = m_slot_length_us - SLOT_SANITY_END_US;
		NVIC_EnableIRQ(TIMER0_IRQn);
		on_ts_start();
		signal_callback_return_param.params.request.p_next = NULL;
		signal_callback_return_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE;
	}
	break;

	case NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO:
	{
		signal_callback_return_param.params.request.p_next = NULL;
		signal_callback_return_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE;
		on_radio_cb();
	}
	break;

	case NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0:{
		//Timer interrupt - attempt to increase timeslot length
		if (NRF_TIMER0->EVENTS_COMPARE[0] == 1)
		{
			NRF_TIMER0->EVENTS_COMPARE[0] = 0;

			signal_callback_return_param.params.extend.length_us = SLOT_EXTEND_US;
			signal_callback_return_param.callback_action         = NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND;
		}
	}
	break;

	case NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED:
	{
		//Extension succeeded, reset timer(configurations still valid since slot length is the same)
		NRF_TIMER0->CC[0]    += SLOT_EXTEND_US;
	}
	break;

	case NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED:
	{
		//Extension failed, schedule new timeslot at earliest time
		on_ts_stop();
		configure_next_event_earliest();
		signal_callback_return_param.params.request.p_next = &m_timeslot_request;
		signal_callback_return_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END;
	}
	break;

	default:
		//No implementation needed
		break;
	}
	return (&signal_callback_return_param);
}

complete code here

Many thanks for your clue.

Seb

  • Hi Seb,

    Seems that the issue was at NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED event, that you didn't set the callback_action to NONE.

    I attached here an example in SDK v14 I made (nRF52832, S132 v5.0), it should be similar on SDK v13.

    I use the timer start_timeslot_timeout_handler() to trigger a request for timeslot every second. The timeslot length is 35ms. Timer 0 CC[0] triggered after 30ms.

    The code request more 3 extensions (extension_count). When the last compare event triggered with CLOSE action, I will end the timeslot immediately, result in 120ms length timeslot (instead of 35x4 = 140ms)

    You can monitor pin 18-20 to verify the operation (description of the pins in the main loop)

    ble_app_hrs SDK14- Timeslot.zip

Related