Hi!!
In my last project, i had the requirement to read a PPM channel coming from a RC receiver.
In the arduino i use the timer1 with this code:
----------------------------------------
void setup_timer1(){
//Desactivar todas las interrupciones | disable all interupts
TIMSK1 &= ~( _BV(TOIE1) | _BV(ICIE1) | _BV(OCIE1A) | _BV(OCIE1B));
//Fijar modo del timer | set timer mode
TCCR1A &= ~( _BV(WGM11) | _BV(WGM10) );
TCCR1B &= ~( _BV(WGM12) | _BV(WGM13) | _BV(ICNC1));
//Capturar flanco de subida | capture raising edge
TCCR1B |= _BV(ICES1); //capture raising edge
//Prescaler 1/8
TCCR1B |= _BV(CS11);
TCCR1B &= ~( _BV(CS12) | _BV(CS10) );
//Desactivar salidas | disable outputs
TCCR1A &= ~( _BV(COM1A0) | _BV(COM1A1) | _BV(COM1B0) | _BV(COM1B1));
//Activar interrupcion de captura | enable capture interrupt
TIMSK1 |= (1<<ICIE1);
}
ISR(TIMER1_CAPT_vect){
//static unsigned int lasticr; //icr at last caputre
static unsigned char cserinp; //Entrada actual de servo | current input servo
unsigned int licr;
//TCCR1B ^= _BV(ICES1);
//licr=ICR1-lasticr;
//lasticr=ICR1;
// TCNT1=0;
if(ICR1>10000){ //Pulso muy largo, comenzar con nuevo frame | pulse too long, means start of new frame
cserinp=0;
}else{ //Pulso correcto, guardar medicion, ir al siguiente canal | pulse good, take reading, go to next channel
serinp[cserinp]=((ICR1/2));
cserinp++;
}
TCNT1=0;
}
--------------------------------------
Im using interrupts to make it more efficient... the array "serinp" contains all the data from the 6 channels of my receiver.
My question is, how to do this in the marvelous Maple?? because im updating all my project to the maple....
Any ideas??
has anyone ported the pulseIn function??
thanks!!
cheers!!