Al Yes you can, if you want to implement two interrupts per cycle. The project this was for had a number of interrupts firing off much of the time. Because we had a conviemt capture pin, the decision was made to use it instead. -Bill On Sun, 23 Jan 2005 23:23:10 +1030, onestone wrote: Can't you just use a single timer and toggle the bits in the control register that set the trigger edge? I haven't studied LPC2000 in any great detail yet, but this is so basic every 4,8and 16 bitter I've worked with that had a capture channel could do this. Then just check the edge control bits to determine if you need a result. Al Bill Knight wrote: > We am doing something similar with two capture inputs to the > same timer. > - setup 1st capture input to capture the time of the rising edge > - setup 2nd capture input to capture the time of the falling edge > and to cause an interrupt. > - the interrupt routine saves the difference between the two as > the pulse duration. > - the interrupt routine could also save the raw values for period > and duty cycle calculations (we don't need that so don't do it). > > Regards > -Bill Knight > http://www.theARMPatch.com > > > On Fri, 21 Jan 2005 23:05:45 -0000, chazeltopman wrote: > > I'm trying to capture the width of a pulse using the capture > timers on the LPC2106 and getting an accurate reading every > time has proven difficult. The pulses are 200 to 700 > microseconds long. I thought that I could capture them in > the following way: > > Algorithm 1: > o set up capture timer channel 0 to interrupt on each edge > o on interrupt check level to see if high to indicate a > rising edge > o if high, remember captured time and wait for falling edge > o when falling edge occurs subtract rising edge time and > queue up the length of the pulse > > I implemented this algorithm and my numbers vary quite a bit. > If I scope the signals, they are clean so the variance is not > due to noise and is due to interrupt collision or a misunderstanding > of the timer capture. The above algorithm will fail if another > interrupt occurs preventing the captured count from being read > before another edge transition occurs. This is probably what is > happening in my case. So I've been thinking about how else to > capture the two edges without software getting in the way. The > only way I can think of is to use two capture inputs and a match > register. > > Algorthm 2: > o the first capture input captures the time on the rising edge > o the second capture input captures the time on the falling edge > o the match register provides a timed interrupt in which at > least two edges have been captured > > In my case I'd set it to be a millisecond since the pulse is > periodic with about a millisecond period (I'm really measuring the > duty cycle). Then comparing the rising and falling edge capture > times, I can deduce whether I've captured the low pulse (falling > edge before rising edge) or the high pulse (rising edge before > falling edge) and calculate the high pulse from the captured times. > Also by taking a group of measurements, I should get some of > the high pulse and some of the low pulse. Using this info, I > should be able to deduce the period as well instead of measuring > that independantly. > > While this algorithm seems like it should work, it uses two inputs > per pulse input. If someone else has a better idea please toss > it into the arena. > > Rob > > > > > > > Yahoo! Groups Links > > > > > > > > > > > > ------------------------------------------------------------------------ > Yahoo! Groups Links > > * To visit your group on the web, go to: > http://groups.yahoo.com/group/lpc2000/ > > * To unsubscribe from this group, send an email to: > lpc2000-unsubscribe@yahoogroups.com > <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe> > > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of > Service <http://docs.yahoo.com/info/terms/>. > > Yahoo! Groups Links
Message
Re: [lpc2000] accurate pulse measurements
2005-01-23 by Bill Knight
Attachments
- No local attachments were found for this message.