can i generate milliseconds using nrf calendar example?? that is only printing up to seconds I want milliseconds too??
I am using nrf52840 and SDK 17.02.
waiting for your precious replies. thanks
can i generate milliseconds using nrf calendar example?? that is only printing up to seconds I want milliseconds too??
I am using nrf52840 and SDK 17.02.
waiting for your precious replies. thanks
Thank you for your precious reply, i did a lot of changes to the char *nrf_cal_get_time_string(bool calibrated) function. Also i change the CAL_RTC->PRESCALER = 0 and the corresponding (CAL_RTC->COUNTER /32.768); but the problem is that struct tm does not has the tag for milliseconds like Hour, minutes etc. I use the below logic, this logic add another tag to YY:mm:HH:SS. But it does not calculate the milliseconds.
char *nrf_cal_get_time_string(bool calibrated)
{
uint64_t milli;
uint32_t sec;
char currentTime[84] = "";
time_t return_time;
static char cal_string[80];
return_time = m_time + (CAL_RTC->COUNTER) /32.768 ;
m_tm_return_time = *localtime(&return_time);
sec=m_tm_return_time.tm_sec;
milli=round(m_tm_return_time.tm_sec*1000);
strftime(cal_string, 80, "%Y%m%d %H:%M:%S%:",&m_tm_return_time);
sprintf(currentTime, "%s:%d", cal_string, milli);
printf("calibrated time: \t%s\r\n", currentTime);
return cal_string;
}
the above logic gives the following result
calibrated time: 19700101 00:01:22:536872881
calibrated time: 19700101 00:01:23:536872881
calibrated time: 19700101 00:01:24:536872881
calibrated time: 19700101 00:01:25:536872881
calibrated time: 19700101 00:01:26:536872881
calibrated time: 19700101 00:01:27:536872881
calibrated time: 19700101 00:01:28:536872881
calibrated time: 19700101 00:01:29:536872881
calibrated time: 19700101 00:01:30:536872881
calibrated time: 19700101 00:01:31:536872881
calibrated time: 19700101 00:01:32:536872881
calibrated time: 19700101 00:01:33:536872881
calibrated time: 19700101 00:01:34:536872881
calibrated time: 19700101 00:01:35:536872881
calibrated time: 19700101 00:01:36:536872881
calibrated time: 19700101 00:01:37:536872881
calibrated time: 19700101 00:01:38:536872881
calibrated time: 19700101 00:01:39:536872881
calibrated time: 19700101 00:01:40:536872881
calibrated time: 19700101 00:01:41:536872881
calibrated time: 19700101 00:01:42:536872881
calibrated time: 19700101 00:01:43:536872881
Time updates off
Thank you for your precious reply, i did a lot of changes to the char *nrf_cal_get_time_string(bool calibrated) function. Also i change the CAL_RTC->PRESCALER = 0 and the corresponding (CAL_RTC->COUNTER /32.768); but the problem is that struct tm does not has the tag for milliseconds like Hour, minutes etc. I use the below logic, this logic add another tag to YY:mm:HH:SS. But it does not calculate the milliseconds.
char *nrf_cal_get_time_string(bool calibrated)
{
uint64_t milli;
uint32_t sec;
char currentTime[84] = "";
time_t return_time;
static char cal_string[80];
return_time = m_time + (CAL_RTC->COUNTER) /32.768 ;
m_tm_return_time = *localtime(&return_time);
sec=m_tm_return_time.tm_sec;
milli=round(m_tm_return_time.tm_sec*1000);
strftime(cal_string, 80, "%Y%m%d %H:%M:%S%:",&m_tm_return_time);
sprintf(currentTime, "%s:%d", cal_string, milli);
printf("calibrated time: \t%s\r\n", currentTime);
return cal_string;
}
the above logic gives the following result
calibrated time: 19700101 00:01:22:536872881
calibrated time: 19700101 00:01:23:536872881
calibrated time: 19700101 00:01:24:536872881
calibrated time: 19700101 00:01:25:536872881
calibrated time: 19700101 00:01:26:536872881
calibrated time: 19700101 00:01:27:536872881
calibrated time: 19700101 00:01:28:536872881
calibrated time: 19700101 00:01:29:536872881
calibrated time: 19700101 00:01:30:536872881
calibrated time: 19700101 00:01:31:536872881
calibrated time: 19700101 00:01:32:536872881
calibrated time: 19700101 00:01:33:536872881
calibrated time: 19700101 00:01:34:536872881
calibrated time: 19700101 00:01:35:536872881
calibrated time: 19700101 00:01:36:536872881
calibrated time: 19700101 00:01:37:536872881
calibrated time: 19700101 00:01:38:536872881
calibrated time: 19700101 00:01:39:536872881
calibrated time: 19700101 00:01:40:536872881
calibrated time: 19700101 00:01:41:536872881
calibrated time: 19700101 00:01:42:536872881
calibrated time: 19700101 00:01:43:536872881
Time updates off