Timer arduino

Dec 06, 2020 3 Replies

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 }


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:-)

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

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*

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required