I want to count clocks in order to implement a watch. I use the RTC0 as my time-base and count mainly with this device. As it has just 24 bits it would not last for long, which is why I use an extra counting variable that counts seconds (unix epoch time). My idea was to add the value of RTC0 to my counter in case of:
- I need to calculate the time now
- the RTC0 has an overflow
After transfering the RTC0 value to my counter I want to clear the RTC as the value got transfered. But to make sure this works the clear must be synchronised to the RTC0 count increment. Otherwise I would loose the subdivision of my time hold in the prescaler. The other solution would be not to have the prescaler clear it's value but just the RTC counter.