Hello
I am trying to implement radio receiver using the time slot API and I am facing some problems to make it work. I am using nrf51822 with SD130 (sdk8) and the device is configured in central mode. I want to receive some data sent from another nrf device which runs nrf radio transmitter example.In order to run the RF radio i am using time slot api which is tested and working fine.However, when i try to run the radio receiver code in the time slot the radio is unable to receive any data and from debugging i can see that it gets stuck in the following line even though the transmitter is continuously sending the data.
// Start listening and wait for address received event
NRF_RADIO->TASKS_START = 1U;
// Wait for end of packet or buttons state changed
while ((NRF_RADIO->EVENTS_END == 0U)&&(error!=0))
{
// wait
}
Please have look at the below code snippet.
timeslot code.
nrf_radio_signal_callback_return_param_t * radio_callback(uint8_t signal_type)
{
switch(signal_type)
{
case NRF_RADIO_CALLBACK_SIGNAL_TYPE_START:
//Start of the timeslot - set up timer interrupt
signal_callback_return_param.params.request.p_next = NULL;
signal_callback_return_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE;
NRF_TIMER0->MODE = TIMER_MODE_MODE_Timer;
NRF_TIMER0->BITMODE = TIMER_BITMODE_BITMODE_32Bit;
NRF_TIMER0->PRESCALER = 4;
NRF_TIMER0->INTENSET = TIMER_INTENSET_COMPARE0_Msk;
NRF_TIMER0->CC[0] = m_slot_length - 1000;
NVIC_EnableIRQ(TIMER0_IRQn);
Timeslot=true;
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;
break;
case NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0:
//Timer interrupt - do graceful shutdown - schedule next timeslot
signal_callback_return_param.params.extend.length_us = m_slot_length;
signal_callback_return_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND;
break;
case NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED:
//No implementation needed
NRF_TIMER0->TASKS_CLEAR = 1;
break;
case NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED:
//Try scheduling a new timeslot
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);
}
And i am reading the radio as shown below.
/**@brief Function for reading packet.
*/
uint32_t read_packet()
{
uint32_t result = 0;
uint32_t error=0;
NRF_RADIO->EVENTS_READY = 0U;
// Enable radio and wait for ready
NRF_RADIO->TASKS_RXEN = 1U;
error=10000;
while ((NRF_RADIO->EVENTS_READY == 0U)&&(error!=0))
{
// wait
error--;
}
NRF_RADIO->EVENTS_END = 0U;
// Start listening and wait for address received event
NRF_RADIO->TASKS_START = 1U;
error=10000;
// Wait for end of packet or buttons state changed
while ((NRF_RADIO->EVENTS_END == 0U)&&(error!=0))
{
// wait
error--;
}
if (NRF_RADIO->CRCSTATUS == 1U)
{
//result = packet;
}
NRF_RADIO->EVENTS_DISABLED = 0U;
// Disable radio
NRF_RADIO->TASKS_DISABLE = 1U;
error=10000;
while ((NRF_RADIO->EVENTS_DISABLED == 0U)&&(error!=0))
{
// wait
error--;
}
return result;
}
if(Timeslot)
{
//clock_initialization();
radio_configure();
read_packet();
Timeslot=false;
//printf("ok");
printf("%c",packet[0]);
printf("%c",packet[9]);
configure_next_event_normal();
}
Could you please help me to understand the issue with this implementation or suggest me the best method to realize this.