Re: LPC2138 timers



"Peter Dickerson" <first{dot}surname@xxxxxxxxx> wrote in message
news:8jWog.9$Xp3.2@xxxxxxxxxxxxxxxxxxxxxxx
"Frank van Eijkelenburg" <someone@xxxxxxxxxxxxxxxx> wrote in message
news:44A3FC9B.5010001@xxxxxxxxxxxxxxxxxxx
Peter Dickerson wrote:
[snip]

You shouldn't need to reset the timer at all. You want it to keep
going
so
that the results are entiely based on hardware timing without and
latency
issues (except to respond to the interrupt before the next capture is
expected).

Peter



Hi Peter,

thank you for the idea. If the timer was used only for measurement, it
would
work I guess. However, the timer is also used as timeout timer (if for a
long
period no edges are detected a timeout occures). I could manually detect
if the
timeout period is elapsed, but this should be done outside the interrupt
service
routine. Anyway, automatically reset the timer would be the best
solution,
but I
am afraid it isn't possible?!

So use two timers. Don't reset the input capture one but reset the timout
one. That way you'll get both the timeout and the timing to the nearest
clk.

Alternatively, if the timer supports capture and compare then update the
compare value to be capture_value+timeout (modulo timer size) in the capture
interrupt. You should only get a compare interrupt if no edge has occured
during the timeout interval.

Peter


.


Quantcast