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

In radio_signal_callback, after switching app_timer, it cannot generate app_timer interrupt

Hello,

I encountered a problem. When I turn off app_timer during timeslot interruption, it cannot generate app_timer interrupt
code show as below:

static nrf_radio_signal_callback_return_param_t *timeslot_cb(uint8_t signal)
{
    static nrf_radio_signal_callback_return_param_t ret = {
        .params.request.p_next = NULL,
        .callback_action       = NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE,
    };
    
    if(signal == NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO){
        if (NRF_RADIO->EVENTS_DISABLED == 1) {
            NRF_RADIO->EVENTS_DISABLED = 0;
            NRF_LOG_DEBUG("radio disable evt");
            APP_ERROR_CHECK(app_timer_start(m_rx_timer, APP_TIMER_TICKS(SLEEP_INTERVAL), NULL));
            APP_ERROR_CHECK(app_timer_stop(m_rx_timer));
            APP_ERROR_CHECK(app_timer_start(m_rx_timer, APP_TIMER_TICKS(SLEEP_INTERVAL), NULL));
            NRF_LOG_INFO("timer active : %d", m_rx_timer->active);
        }
    }

I am using app_timer2 :

ret_code_t app_timer_start(app_timer_t * p_timer, uint32_t timeout_ticks, void * p_context)
{
    ASSERT(p_timer);
    app_timer_t * p_t = (app_timer_t *) p_timer;

    if (p_t->active)
    {
        return NRF_SUCCESS;
    }

    p_t->p_context = p_context;
    p_t->end_val = get_now() + timeout_ticks;

    if (p_t->repeat_period)
    {
        p_t->repeat_period = timeout_ticks;
    }

    return timer_req_schedule(TIMER_REQ_START, p_t);
}

Regards, 

Gray.

Parents
  • Hi Gray, 

    Please be aware that the app_timer uses a buffer to queue/schedule the tasks. And it only execute tasks when there is an RTC interrupt. The interrupt can be either normal RTC interrupt, or it can be triggered by calling drv_rtc_irq_trigger() inside timer_req_schedule(). In your case if you are in the radio callback, it's most likely you are on the highest priority meaning the RTC_IRG can't be executed until the function is finished. 

    So it's normal that when you start the app timer inside the radio signal call back the active timer remains at 0. 

    But it should be executed after the radio callback is finished. Please check to see if the rtc_irq() is called after that or not. 


Reply
  • Hi Gray, 

    Please be aware that the app_timer uses a buffer to queue/schedule the tasks. And it only execute tasks when there is an RTC interrupt. The interrupt can be either normal RTC interrupt, or it can be triggered by calling drv_rtc_irq_trigger() inside timer_req_schedule(). In your case if you are in the radio callback, it's most likely you are on the highest priority meaning the RTC_IRG can't be executed until the function is finished. 

    So it's normal that when you start the app timer inside the radio signal call back the active timer remains at 0. 

    But it should be executed after the radio callback is finished. Please check to see if the rtc_irq() is called after that or not. 


Children
Related