How to use the 64bit timer as a 32bit counter (overflow at 0xFFFFFFFF), but keep alarm function available
Posted: Fri Nov 22, 2019 3:22 pm
Hi,
For a time constrained application I need a freerunning 32bit microsecond time base timer to trigger alarm at given 32bit timestamp.
Currently I use the two 64bit timers of a timer group as follow :
The first timer is used to generate one shot alarm at a given absolute 32bit timestamp. The second timer is setup at the same speed with auto-reload and with an alarm at 0xFFFFFFFF (32bit max). When the second timer IRQ is triggered, I set the first timer counter back to 0 (simulate overflow). The second counter is automatically reset thanks to auto-reload, but I still re-enable the alarm for the next overflow.
Is there a better way to do this? I'm afraid this solution add overhead and that I might miss an alarm set for example at 0xFFFFFFFF on the first timer. I don't know how to ensure the 2 timers are in sync.
For a time constrained application I need a freerunning 32bit microsecond time base timer to trigger alarm at given 32bit timestamp.
Currently I use the two 64bit timers of a timer group as follow :
The first timer is used to generate one shot alarm at a given absolute 32bit timestamp. The second timer is setup at the same speed with auto-reload and with an alarm at 0xFFFFFFFF (32bit max). When the second timer IRQ is triggered, I set the first timer counter back to 0 (simulate overflow). The second counter is automatically reset thanks to auto-reload, but I still re-enable the alarm for the next overflow.
Is there a better way to do this? I'm afraid this solution add overhead and that I might miss an alarm set for example at 0xFFFFFFFF on the first timer. I don't know how to ensure the 2 timers are in sync.