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

APP_TIMER_TICKS in bsp_init

i am going through the bsp tutorial

what is the meaning of

how often we want the application timer to tick ?

Parents
  • Hi anilkunchalaece!

    The APP_TIMER is running with a frequency of 32768 Hz. This means that with prescaler 0, it generates 32768 ticks per second.

    Lets say you want a timer that does something every second; 1sec = 1000ms.

    APP_TIMER_TICKS(1000, APP_TIMER_PRESCALER)
    

    The macro below, given i app_timer.h, converts the milliseconds you provide in APP_TIMER_TICKS into number of ticks:

    #define APP_TIMER_TICKS(MS, PRESCALER)
        ((uint32_t)ROUNDED_DIV(MS) * (uint64_t)APP_TIMER_CLOCK_FREQ, ((PRESCALER) + 1) * 1000))
    

    From the macro the app_timer.h:

    Ticks = ((1000 * 32768) / (0+1)*1000) = 32768. The timer will put 32768 (0x8000) in the RTC compare register, and when the RTC has run for this many ticks, 1 second has passed.

    Best regards
    Joakim

  • HI, Thanks for Reply. i want to know the use of that function in bsp_init(). if i change the 100 to 1000 ticks how it will affect the program ?

Reply Children
No Data
Related