I am trying to record the time on nRF52840 with s140 softdevice.
I used APP_TIMER to setup the TIMER and app_timer_cnt_get
to get the count. And then uint32_t app_timer_cnt_diff_compute(uint32_t ticks_to, uint32_t ticks_from);
to get the ticks for the time span.
However, I am confused about how to get the actual time. There is not defined ticks to time macro in app_timer.h
.
I read some discussion about this and the solution is like
APP_TIMER_TICKS = ( MS * APP_TIMER_CLOCK_FREQ ) / ( ( PRESCALAR + 1 ) * 1000 )
But in SDK 14.0 the macro for time to ticks is like
#ifndef FREERTOS
#define APP_TIMER_TICKS(MS) \
((uint32_t)ROUNDED_DIV( \
(MS) * (uint64_t)APP_TIMER_CLOCK_FREQ, \
1000 * (APP_TIMER_CONFIG_RTC_FREQUENCY + 1)))
#else
#include "FreeRTOSConfig.h"
#define APP_TIMER_TICKS(MS) (uint32_t)ROUNDED_DIV((MS)*configTICK_RATE_HZ,1000)
#endif
I don't know in SDK 14 the safe way to convert ticks to time anymore.