Re: LPC2138 timers



Peter Dickerson wrote:
"Frank van Eijkelenburg" <someone@xxxxxxxxxxxxxxxx> wrote in message
news:482ef$44a3f118$3e3aa7a5$13428@xxxxxxxxxxxxxxxxxxxx

I am using a capture pin in combination with a timer of the LPC2138

controller.

Each time a rising/falling edge is detected the running timer value is

captured

and stored in a CAP register. I am using this method to measure timing

between

the edges and calculate the frequency of the signal (squarewave).

Each time I enter my interrupt service routine I reset the timer (to start

a new

measurement). Is there a way to do this automatically, because now I have

a

Surely that will introduce a error due to the interrupt latency. Shouldn't
you be subtracting the previous capture value leaving the time to free run?


small gap between the edge and the start point of measurement. I saw that

you

can automatically reset the timer if a match value is reached, but could

not

find this possibility for the capture pins.


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?!

Frank
.


Quantcast