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;
}Discussion 0
Join free to post in the discussion.
Related questions
- PWM duty cycleEmbedded Systems Engineer
- Timer prescaler mathsEmbedded Systems Engineer
- Priority inversionEmbedded Systems Engineer
- Counter shared with an ISREmbedded Systems Engineer
- Measuring a signal frequencyEmbedded Systems Engineer
- Atomic GPIO writesEmbedded Systems Engineer
- A lock-free ISR ring bufferEmbedded Systems Engineer
- Garbled log text from two tasksEmbedded Systems Engineer