What are the overflow periods for timers on XS1?


What are the overflow periods for timers on XS1?

Timers overflow every 2^32 reference clock cycles; but the timer after function assumes that all negative times are in the past, so you should not use timers beyond 2^31 reference clock cycles, which is a 21.47 second period. If you want to time longer periods than that, it is best to chop them up in shorter periods, eg:

   void sleep(int seconds) {
       timer tmr;
       int time;
       tmr :> time;
       while(seconds > 0) {
           time += 100000000;
           tmr when timerafter(time) :> void;
           seconds--;
       }
   }

Port counters overflow every 2^16 clock cycles on the port. Note that strictly speaking not timers, as they do not count time; they just count edges on the clock associated with the port; which may or may not reflect time.

Port counters have no notion of the past, so 65535 values refer to the future, and one value refers to now. If you need to activate something more than 65535 clocks in the future, you should chop it into smaller parts.