Phil,
excuse my quibble, but I still cannot see much advantage over my three instruction loop
In both cases we have an inaccuracy of 4 ticks worst case. My aditional insruction can easily be compensated for after reading cnt (if you are interested in the phase). Mirror's example has opened my eyes for the extremely specific and limited usefulness of being able to re-act within 150 ns rather than 200 ns to a rising slope of a much longer signal...
Yup, yours is also an eight-clock loop. One (not terribly significant) difference between our approaches is the extra instruction yours requires to react to the pin change. OTOH, mine requires more instructions to "rearm" the tests after a change and uses up a local counter.
Had I taken more time to examine your routine in detail, I probably wouldn't have gone to the trouble to develop mine!
But it wasn't in vain! I love to see applications for these timers/counters of the Propeller. They are definitely underused and to little understood. Just think of the fast shift-out exploit!
Which is a pity as they can be used even from SPIN in many situations. When I wrote the sequence of my PWM examples, I was astonished how precise the timing was...
Comments
excuse my quibble, but I still cannot see much advantage over my three instruction loop
In both cases we have an inaccuracy of 4 ticks worst case. My aditional insruction can easily be compensated for after reading cnt (if you are interested in the phase). Mirror's example has opened my eyes for the extremely specific and limited usefulness of being able to re-act within 150 ns rather than 200 ns to a rising slope of a much longer signal...
Yup, yours is also an eight-clock loop. One (not terribly significant) difference between our approaches is the extra instruction yours requires to react to the pin change. OTOH, mine requires more instructions to "rearm" the tests after a change and uses up a local counter.
Had I taken more time to examine your routine in detail, I probably wouldn't have gone to the trouble to develop mine!
-Phil
Which is a pity as they can be used even from SPIN in many situations. When I wrote the sequence of my PWM examples, I was astonished how precise the timing was...