I am counting 1 microsecond periods using both general timers:
timer t;
int time;
t :> time;
t when timerafter (time + 100) :> time;
and port timers:
out port p = XS1_PORT_1F;
int time;
p <: 1 @ time;
p @ (time + 100) <: 0;
However, when I count longer periods (several milliseconds), port timers give the wrong result. What are the overflow periods for both types of timer, and when should I use one over the other?
What are the overflow periods for timers on XS1? Topic is solved
-
Verified
- XCore Legend
- Posts: 1156
- Joined: Thu May 27, 2010 10:08 am
-
- XCore Addict
- Posts: 230
- Joined: Wed Mar 10, 2010 12:46 pm
Port timers are 16-bit and by default they are clocking at 100MHz along with the reference clock. Therefore they cover a range of 655us (655360ns). If you are working with a period longer than that then you will have to use a combination of a timer and the port time.
The timer counters are reset at the point the clock they are attached to is started. Therefore they will not correspond to the least significant 16 bits of the timers. However, assuming that they are still running on the 100MHz reference clock then it is possible to get the offset between the timer's least significant 16 bits and the port timer value.
The timer counters are reset at the point the clock they are attached to is started. Therefore they will not correspond to the least significant 16 bits of the timers. However, assuming that they are still running on the 100MHz reference clock then it is possible to get the offset between the timer's least significant 16 bits and the port timer value.