Hey Guys,
I am trying to figure the best way to measure the time between transitions on a one bit port.
The problem is some transitions are longer than the 32 bit counter period.
Secondly I need to log the times of up to 100 sequential transitions.
I have experimented with the
inp when pinsneq(pinstate) :> pinstate @ ttime;
and then do the math on sequential reads but this gives me numbers that are not useful
I am guessing that I could use a case statement that uses a variable to track if the counter rolls over but I am also guessing that someone has already figured the best way and wouldnt mind letting me know.
Cheers
Matt
Best way to measure pulse width greater than timer size.
-
- Active Member
- Posts: 50
- Joined: Sat Feb 13, 2010 12:04 pm
-
- XCore Addict
- Posts: 169
- Joined: Fri Jan 08, 2010 12:13 am
A good way (depending on the resolution you need) is to attach a clock block to the port and then divide down the clock rate - you can use the function listed below which is documented in the xs1.h section of the documentation in <xmos tool root>/doc/libs/html/index.html
This should allow you with a standard ref clock get down to ref / (2*255).
By the way- port timers (using the @ syntax) are only 16 bit and by default run at the reference clock speed, which is usually 100MHz unless you have explicitly set it to another value.
Code: Select all
configure_clock_rate ( clock clk,
unsigned a,
unsigned b
)
By the way- port timers (using the @ syntax) are only 16 bit and by default run at the reference clock speed, which is usually 100MHz unless you have explicitly set it to another value.
Paul
On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.