Skip to content
RED SAGSkills
hard20 pts · first answer countstimersconcurrency

Timestamp jumps backwards

A 64-bit time is built from a software overflow count and a 32-bit hardware timer. Rarely, the time jumps by about 2^32 ticks. What is the fix?

volatile uint32_t overflows; /* incremented in timer overflow ISR */

uint64_t now(void) {
  return ((uint64_t)overflows << 32) | TIMER->CNT;
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions