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
- Heavy work in an interruptEmbedded Systems Engineer
- printf in an interruptEmbedded Systems Engineer
- 16-bit timer overflow timeEmbedded Systems Engineer
- PWM frequency from timer settingsEmbedded Systems Engineer
- What SysTick is used forEmbedded Systems Engineer
- Where a FreeRTOS timer callback runsEmbedded Systems Engineer