<sys/time.h>

06 Dec 2011

Hi:

Anyone has used millisecond time resolution? I do not mean wait_us() but getting the actual millisecond from the microcontroller after RTC is running. I believe the RTC only provide 1 second resolution. Perhaps someone is able to get millisecond from wait_us efficiently.

Regards YoongHM

06 Dec 2011

I'm not sure what your question is, the Timer class provides methods for measuring microseconds(us), for measuring time longer then 30mins (such as uptime) you would have to handle roll-over, but that's all?

07 Dec 2011

Hi Christ:

I would like to get RTC time in milliseconds resolution, not elapsed time.

#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>

void print_time ()
{
  struct timeval  tv;
  struct tm      *ptm;
  char            tmStr[40];

  gettimeofday(&tv, NULL);
  ptm = localtime(&tv.tv_sec);

  strftime(tmstr, sizeof(tmstr), "%d-%m-%Y %H:%M:%S", ptm);
  printf ("%s.%03ld\n", tStr, tv.tv_usec/1000);
}
07 Dec 2011

Pretty sure RTC is as you say just second resolution, Could you use the RTC Interrupt to reset a Timer?