Hi,
someone can help me to notice because the following happens:
I have 3 PWM (of accelerometers ADXL202E)with periods of more or less
100Hz and I want to measure the duty cycle. If I only enable 2 of the
3 interruptions that pretend everything works well, but if I enables
the third interruption the results are not the expected (the duty
cycle have errors, for example I'm an duty cycle of 0.50 and once in a
while appear pick 1.5).
I'm using LPC2129 and the GCC 3.4.1 compiler for ARM.
T1CCR |= TCCR_CR0_I | TCCR_CR0_R | TCCR_CR0_F; // enable timer1
interrupt on rising edge of CR0 capture (eixo dos xx)
T1CCR |= TCCR_CR1_I | TCCR_CR1_R | TCCR_CR1_F;
T1CCR |= TCCR_CR2_I | TCCR_CR2_R | TCCR_CR2_F;
//interrupt function
void captura(void){
ISR_ENTRADA();
if(T1IR & TIR_CR0I){
T1IR |= TIR_CR0I;
acel_cap_eixo_x();
}
if(T1IR & TIR_CR1I){
T1IR |= TIR_CR1I;
acel_cap_eixo_y();
}
if(T1IR & TIR_CR2I){
T1IR |= TIR_CR2I;
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 rising edge
tpu=T1CR0;
INS_ACEL_ESCREVE(0,
((ACEL_T2_x-ACEL_T1_x)<<14)/(tpu-ACEL_T1_x));
ACEL_T1_x=tpu;
}else{ //falling edge
ACEL_T2_x = T1CR0;
}
return;
}
...
...
#define ACEL_BUFFER_TAM 8
#define ACEL_BUFFER_MASK 0x07
static u32 ACEL_BUFFER[3][ACEL_BUFFER_TAM+1];
static unsigned char ACEL_BUFFER_ESC[3];
char INS_ACEL_ESCREVE(char eixo, u32 valor){
if( (ACEL_BUFFER_ESC[eixo]+1)&ACEL_BUFFER_MASK ==
ACEL_BUFFER_LER[eixo] )
return -1;
ACEL_BUFFER[eixo][ACEL_BUFFER_ESC[eixo]]=valor;
ACEL_BUFFER_ESC[eixo]++;
if(ACEL_BUFFER_ESC[eixo]>ACEL_BUFFER_TAM){
ACEL_BUFFER_ESC[eixo]=0;
}
Thanks
Domingos
_________________________________________________________
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-24 by dasbento@aeiou.pt
Attachments
- No local attachments were found for this message.