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

App timer problem in nRF 52832 bootloader

Hello,

I am working with the latest version of nRF52 SDK 13.0.0, when I was implementing my own bootloader application, I tried to start an app timer in my code to invert BSP_BOARD_LED_0. The initialization of lfclk and app timer was successful but I didn't observer that the LED_0 inverted. I upload my project below. I guess that the clock configuration is wrong? The hardware environment is nRF52 DK.

Thanks.

bootloader_user.zip

  • Hi Daniel,

    you have to set the APP_TIMER_CONFIG_USE_SCHEDULER in sdk_config.h to 0, i.e.

    #ifndef APP_TIMER_CONFIG_USE_SCHEDULER
    #define APP_TIMER_CONFIG_USE_SCHEDULER 0
    #endif
    

    If you want to use the scheduler, then you have to define

    #define SCHED_MAX_EVENT_DATA_SIZE       MAX(APP_TIMER_SCHED_EVENT_DATA_SIZE, 0)                
    #define SCHED_QUEUE_SIZE                20           
    

    and initialize the scheduler in main()

    APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
    

    and call app_sched_execute() in the infinite while loop, i.e.

    while(1)
    {   
        app_sched_execute();
    }
    

    Best regards

    Bjørn

  •  I am having the very same problem with my bootloader code not working with app_timer and was pulling my hair out trying to get it to work when I came across this older Post.

    I have some questions:

    1.Could you please explain WHY this fix is needed. I do not understand why events are a problem with the bootloader example.

    2. You seem to be suggesting to do contradictory things, first to disable scheduling in sdk_config, then enabling scheduling in the while loop? Which is it?

    3 I have an additional possibly related issue. I am trying to sense a pin state on entering bootloader and use app_timer to enter the bootloader after a few seconds if it remains pushed. When I call app_button_is_pushed the nrf52840 resets. If I call nrf_gpio_pin_read it works fine. What is happening?

    1.  The original poster was making a custom bootloader where the bootloader example from our SDK was modified. 
    2. As stated above, this was a custom bootloader, the unmodified bootloader example from our SDK does not require this fix. The answer I gave was that he should set APP_TIMER_CONFIG_USE_SCHEDULER 0 because he did not have the code listed below in his main.c file. 
    3. Its hard to say whats going on without seeing the actual code. 
Related