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

ticks = APP_TIMER_TICKS(MS);

In Nrf5 sdk V15 their is a micro 

ticks = APP_TIMER_TICKS(MS);

My question is what is the maximum value of ms which can be used as input.

the same question goes to the function 

app_timer_start()

Please assist

Parents
  • Hi, this ticket and this ticket both answer your question.

    The RTC features a 24 bit counter and a 12 bit prescaler, so the maximum value will be 

    (2*24) * (APP_TIMER_CONFIG_RTC_FREQUENCY + 1) * 1000 / APP_TIMER_CLOCK_FREQ

    depending on how you configure the RTC prescaler value (APP_TIMER_CONFIG_RTC_FREQUENCY).

    The clock frequency of the RTC timer (APP_TIMER_CLOCK_FREQ) is 32768 (32 kHz).

    So for example with a prescaler value of 15, the RTC will overflow after 8 192 000 ms, which will is in turn the maximum value of MS you can use as input to APP_TIMER_TICKS(MS). 

    (2^24) * (15 + 1) * 1000 / 32768 = 8 192 000ms = ~136,5 minutes.

    This will then give you a period (or counter resolution) of 

    8 192 000 / 16 777 216 = ~488 us

    The image below is taken from the product specification of the nRF52832 (and similar ones can be found for the other chips). So for example with a prescaler of 0 and counter resolution of 30.517 microseconds, the maximum value of MS is 512 000 milliseconds. 

     

    Best regards,

    Heidi

Reply
  • Hi, this ticket and this ticket both answer your question.

    The RTC features a 24 bit counter and a 12 bit prescaler, so the maximum value will be 

    (2*24) * (APP_TIMER_CONFIG_RTC_FREQUENCY + 1) * 1000 / APP_TIMER_CLOCK_FREQ

    depending on how you configure the RTC prescaler value (APP_TIMER_CONFIG_RTC_FREQUENCY).

    The clock frequency of the RTC timer (APP_TIMER_CLOCK_FREQ) is 32768 (32 kHz).

    So for example with a prescaler value of 15, the RTC will overflow after 8 192 000 ms, which will is in turn the maximum value of MS you can use as input to APP_TIMER_TICKS(MS). 

    (2^24) * (15 + 1) * 1000 / 32768 = 8 192 000ms = ~136,5 minutes.

    This will then give you a period (or counter resolution) of 

    8 192 000 / 16 777 216 = ~488 us

    The image below is taken from the product specification of the nRF52832 (and similar ones can be found for the other chips). So for example with a prescaler of 0 and counter resolution of 30.517 microseconds, the maximum value of MS is 512 000 milliseconds. 

     

    Best regards,

    Heidi

Children
No Data
Related