I'm using 3 capture channels (3 signals). I have linking each signal
to an capture pin and also linked to a generic input. The captures are
configured for rising edge and falling edge and I see which the state
in IOPIN. but i'm also with problems, read stupid values.
Someone can say that will be wrong.
Thanks
Domingos
void captura(void){
ISR_ENTRADA();
if(T1IR & TIR_CR0I){ //interrupt in channel0 (eixo dos xx)
T1IR |= TIR_CR0I;
acel_cap_eixo_x();
}
else if(T1IR & TIR_CR1I){ //interrupcao no canal1 (eixo dos yy)
T1IR |= TIR_CR1I;
//acel_cap_eixo_y();
}
else if(T1IR & TIR_CR2I){ //interrupcao no canal2 (eixo dos zz)
T1IR |= TIR_CR2I; //apaga a flag de interrupcao
// acel_cap_eixo_z();
}
VICSoftIntClr = (1<<VIC_TIMER1);
VICVectAddr = 0x00000000; // clear this interrupt from
the VIC
ISR_SAIDA(); // recover registers and return
}
void acel_cap_eixo_x(void){
u32 tpu;
if(IOPIN0 & ACEL_asc_x){ //verify if rising edge
tpu=T1CR0;
duty_x=(float)(ACEL_T2_x-ACEL_T1_x)/(float)(tpu-ACEL_T1_x));
ACEL_T1_x=tpu;
}else{ //falling edge
ACEL_T2_x = T1CR0;
}
return;
}
..........(identical function for other axes)
Citando onestone <onestone@...>:
>
> 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
>
>
>
>
>
>
>
>
_________________________________________________________
CEAC Cursos de forma\ufffd\ufffdo profissional - pe\ufffda informa\ufffd\ufffdes aqui.:
http://ceac.online.pt/Message
Re: [lpc2000] accurate pulse measurements
2005-01-23 by dasbento@aeiou.pt
Attachments
- No local attachments were found for this message.