Timer arduino

Bonsoir,

Afin de me familiariser avec la programmation PRU, je suis en train d'analyser la librairie Servo.h fournie de base dans les packages arduino

quelqu'un a une piste ?

static void initISR(timer16_Sequence_t timer) { #if defined (_useTimer1) if(timer == _timer1) { TCCR1A = 0; // normal counting mode TCCR1B = _BV(CS11); // set prescaler of 8 TCNT1 = 0; // clear the timer count #if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__) TIFR |= _BV(OCF1A); // clear any pending interrupts; TIMSK |= _BV(OCIE1A) ; // enable the output compare interrupt #else // here if not ATmega8 or ATmega128 TIFR1 |= _BV(OCF1A); // clear any pending interrupts; TIMSK1 |= _BV(OCIE1A) ; // enable the output compare interrupt #endif #if defined(WIRING) timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service); #endif } #endif }

Reply to
Julien Arlandis
Loading thread data ...

les #if defined sont des directives de compilation conditionnelles,

#if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__) devient if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__)

n'existe pas

mes connaissances Arduino n'en sont qu'au commencement:-)

Reply to
DuboisP

Bonjour,

static void initISR(timer16_Sequence_t timer) { if(timer == _timer1) { TCCR1A = 0; // normal counting mode TCCR1B = _BV(CS11); // set prescaler of 8 TCNT1 = 0; // clear the timer count TIFR |= _BV(OCF1A); // clear any pending interrupts; TIMSK |= _BV(OCIE1A) ; // enable the output compare interrupt TIFR1 |= _BV(OCF1A); // clear any pending interrupts; TIMSK1 |= _BV(OCIE1A) ; // enable the output compare interrupt timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service); } }

Donc si timer atteint la valeur de timer1, je dirais qu'on remet

Reply to
Raoul

de compilations conditionnelles.

l'erreur en compilation.

static void initISR(timer16_Sequence_t timer) { if(timer == _timer1) { TCCR1A = 0; // normal counting mode TCCR1B = _BV(CS11); // set prescaler of 8 TCNT1 = 0; // clear the timer count TIFR1 |= _BV(OCF1A); // clear any pending interrupts; TIMSK1 |= _BV(OCIE1A) ; // enable the output compare interrupt } }

static void initISR(timer16_Sequence_t timer) { if(timer == _timer1) { TCCR1A = 0; // normal counting mode TCCR1B = _BV(CS11); // set prescaler of 8 TCNT1 = 0; // clear the timer count TIFR1 |= _BV(OCF1A); // clear any pending interrupts; TIMSK1 |= _BV(OCIE1A) ; // enable the output compare interrupt timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service); } }

static void initISR(timer16_Sequence_t timer) { if(timer == _timer1) { TCCR1A = 0; // normal counting mode TCCR1B = _BV(CS11); // set prescaler of 8 TCNT1 = 0; // clear the timer count TIFR |= _BV(OCF1A); // clear any pending interrupts; TIMSK |= _BV(OCIE1A) ; // enable the output compare interrupt } }

le source est

static void initISR(timer16_Sequence_t timer) { if(timer == _timer1) { TCCR1A = 0; // normal counting mode TCCR1B = _BV(CS11); // set prescaler of 8 TCNT1 = 0; // clear the timer count TIFR |= _BV(OCF1A); // clear any pending interrupts; TIMSK |= _BV(OCIE1A) ; // enable the output compare interrupt timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service); } }

--
*e???to?r??????l???A*
Reply to
Alrote

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.