App Timer does not trigger his handle function

Hi,

I'm trying to implement a timer that will trigger each 10ms (for example) an handler function and do something inside it. So, I came with the idea to implement an App Timer as follow :

#define OSCILLATION_INTERVAL APP_TIMER_TICKS(10)
  
APP_TIMER_DEF(m_app_timer_id);

static void app_timer_handler(void *p_context)
{
  NRF_LOG_INFO("YES");
}

static void timer_init(void)
{
    ret_code_t err_code;

    err_code = app_timer_create(&m_app_timer_id, APP_TIMER_MODE_REPEATED, app_timer_handler);
    APP_ERROR_CHECK(err_code);
}

static void idle_state_handle(void)
{
    if (NRF_LOG_PROCESS() == false)
    {
        nrf_pwr_mgmt_run();
    }
}

int main(void)
{
    bool erase_bonds;
    ret_code_t err_code;
    
    // Initialize.
    log_init();
    app_timer_init();
    NRF_LOG_INFO("START");
    timer_init();
    // Enter main loop. 
    err_code = app_timer_start(m_app_timer_id, OSCILLATION_INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);
    for (;;)
    {   
        idle_state_handle();
    }
}

My issue is that I don't read the "Yes" charachter in the debug terminal, so I guees that my timer is not working correctly.
I tried to find the solution, but didn't find where my error is...

Thanks for helping !

Chris

Parents
  • Hello Chris,

    I do not immediately see anything wrong with your use of the application timer library so I suspect that the problem actually may be with the logging.
    Which logger backend are you using?
    The Segger Debug Terminal is an RTT terminal, so it will only show the loggings if the logger module is using the RTT backend. If you are using the UART backend you will need to use a serial terminal like Termite, PuTTy or similar to see the logs.
    Are you seeing any other unexpected behavior? Is the device resetting unexpectedly, for example?

    Best regards,
    Karl

Reply
  • Hello Chris,

    I do not immediately see anything wrong with your use of the application timer library so I suspect that the problem actually may be with the logging.
    Which logger backend are you using?
    The Segger Debug Terminal is an RTT terminal, so it will only show the loggings if the logger module is using the RTT backend. If you are using the UART backend you will need to use a serial terminal like Termite, PuTTy or similar to see the logs.
    Are you seeing any other unexpected behavior? Is the device resetting unexpectedly, for example?

    Best regards,
    Karl

Children
No Data
Related