On 9 Dec 2009 at 11:40, Keith M wrote:
When I think of sampling, I think of regularly
recording the value of
a pin every so many units of time. So it's possible to miss
pulses/edges/etc if they happen to fall in between the samples.
Many uCs have at least an "interrupt on edge" on some of their I/O
pins. Absent that, you need only hook up a flip-flop to toggle every
time a pulse is received ("T" FF). Then your polling loop would look
something like:
waitforpulse: if pin == lastvalue then waitforpulse
lastvalue = pin;
That way, as long as your loop executes in less time than the minimum
time between pulses, you won't miss any.
--Chuck