app_timer is not working properly

Hi team,

I am using nRF52833 DK with PCA10100 on it.

I am developing  app_timer application for blinking led for a fixed time interval. But it is not working properly. I am using  nRF5_SDK_17.1.0_ddde560\examples\ble_peripheral\ble_app_uart  example program.

While debugging it ends with " <error> app: SOFTDEVICE: ASSERTION FAILED ".

Please provide me solution..

  • Hi,

    While debugging it ends with " <error> app: SOFTDEVICE: ASSERTION FAILED ".

    Do you only get this when debugging, and another error in other cases? I ask because the SoftDevice will assert if it looses timing, for instance if you hit a breakpoint or halt and then continue. So if this is the case, the assert is expected. To debug with a SoftDevice you can use a breakpoint or halt, but then you need to for instance move the breakpoint and reset instead of continuing to avoid this assert.

    If the assert is caused by something else, then perhaps you can elaborate a bit more on what you are doing when/before this happens, and also check the PC value of the assert (check the debug handler function with a debugger, or enable debug logging which should print the PC value on the terminal) and let me know which exact SoftDevice version you are using.

  • Hi,

    " <error> app: SOFTDEVICE: ASSERTION FAILED ". .It is due to break point.

    But my issue is app_timer handler unable to hit for every one second in consistency, I observed the timing issue with led toggling in handler for every one second (some times it is toggling for two seconds).

    Please let me know anything if anything I missed regarding App_timer configuration.

    Regards,

    Hareesh Gorle

  • Hi Hareesh,

    I see. There is not much to go on, can you enable debug logging and see if you get any runtime errors printed? Do you get any warnings when you build? If not, can you share your code (either complete or just app_timer related) so that I can have a look?

  • Hi Einar Thorsrud,

    Here I am attaching my app_timer code.

    please check it..

    Regards,

    Hareesh Gorle

    ================================================================

    static void app_timer_handler1(void * p_context)
    {
    nrf_gpio_pin_toggle(LED_Pin1);
    }


    /**@brief Function for initializing the timer module.
    */
    static void timers_init(void)
    {
    ret_code_t err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);

    // Create an application timer with the handle, mode and interrupt event handle function
    err_code = app_timer_create(&m_app_timer_id1, APP_TIMER_MODE_REPEATED, app_timer_handler1);
    APP_ERROR_CHECK(err_code);

    }

    static void lfclk_config(void)
    {
    // initialize the low power low frequency clock
    ret_code_t err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);

    // request the lf clock to not to generate any events on ticks
    // One tick = 1 value increment in the counter register
    nrf_drv_clock_lfclk_request(NULL);

    }

  • Hi,

    I do not see anything sticking out here, but there could be issues in other parts of your code that I do not see here. You write that the observed behavior is that the LED blinks inconsistently. Could it be that you also toggle the same GPIO pin from somewhere else in some other conditions? It could be interesting to for instance log a line in app_timer_handler1() to see if that runs every second(?) as expected or not. Also, I do not see the code where you start (and perhaps also stop/restart) the timer - could there be an issue there?

Related