i am going through the bsp tutorial
what is the meaning of
how often we want the application timer to tick ?
i am going through the bsp tutorial
what is the meaning of
how often we want the application timer to tick ?
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 ?
It will affect a lot of things. E.g app_button_init() in bsp.c uses the value calculated by APP_TIMER_TICKS to calculate the delay from a GPIOTE event until a button is reported as pushed (detection_delay). If you change it to 1000ms and run the code, you will notice that you have to push the button 10x longer for the button to be reported as pushed.