ServoTimer2 Library & Arduino Nano Every

Hi

I have used the ServoTimer2 Library sucessfully on an Arduino Nano V3.2. I'm trying to recompile it on the Arduino Nano Every and get the following error messages. Anyone have a fix for this?

ERRORS
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp: In function 'void TIMER2_OVF_vect()':
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:29:2: error: 'TCNT2' was not declared in this scope
TCNT2 = servos[Channel].remainder; // yes, set count for overflow after remainder ticks
^~~~~
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:29:2: note: suggested alternative: 'TCB2'
TCNT2 = servos[Channel].remainder; // yes, set count for overflow after remainder ticks
^~~~~
TCB2
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:39:2: error: 'TCNT2' was not declared in this scope
TCNT2 = 0; // reset the clock counter register
^~~~~
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:39:2: note: suggested alternative: 'TCB2'
TCNT2 = 0; // reset the clock counter register
^~~~~
TCB2
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp: In function 'void initISR()':
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:124:2: error: 'TIMSK2' was not declared in this scope
TIMSK2 = 0; // disable interrupts
^~~~~~
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:124:2: note: suggested alternative: 'TIMERB2'
TIMSK2 = 0; // disable interrupts
^~~~~~
TIMERB2
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:125:2: error: 'TCCR2A' was not declared in this scope
TCCR2A = 0; // normal counting mode
^~~~~~
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:125:2: note: suggested alternative: 'TCB2'
TCCR2A = 0; // normal counting mode
^~~~~~
TCB2
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:126:2: error: 'TCCR2B' was not declared in this scope
TCCR2B = BV(CS21); // set prescaler of 8
^~~~~~
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:126:2: note: suggested alternative: 'TCB2'
TCCR2B = BV(CS21); // set prescaler of 8
^~~~~~
TCB2
In file included from c:\users\mark
\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,
from c:\users\mark
\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\interrupt.h:38,
from \Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:4:
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:126:15: error: 'CS21' was not declared in this scope
TCCR2B = _BV(CS21); // set prescaler of 8
^
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:127:2: error: 'TCNT2' was not declared in this scope
TCNT2 = 0; // clear the timer2 count
^~~~~
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:127:2: note: suggested alternative: 'TCB2'
TCNT2 = 0; // clear the timer2 count
^~~~~
TCB2
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:128:2: error: 'TIFR2' was not declared in this scope
TIFR2 = BV(TOV2); // clear pending interrupts;
^~~~~
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:128:2: note: suggested alternative: 'TIMERB2'
TIFR2 = BV(TOV2); // clear pending interrupts;
^~~~~
TIMERB2
In file included from c:\users\mark
\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,
from c:\users\mark
\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\interrupt.h:38,
from \Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:4:
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:128:14: error: 'TOV2' was not declared in this scope
TIFR2 = _BV(TOV2); // clear pending interrupts;
^
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:128:14: note: suggested alternative: 'TCB2'
\Arduino\libraries\ServoTimer2-master\ServoTimer2.cpp:129:16: error: 'TOIE2' was not declared in this scope
TIMSK2 = _BV(TOIE2) ; // enable the overflow interrupt
^

exit status 1

Compilation error: exit status 1

@Delta_G is correct.

The Servo library supports many architectures including the Nano Every. In the library file you can select which timer you want to use in case of conflicts.

https://github.com/arduino-libraries/Servo/blob/master/src/megaavr/ServoTimers.h

//#define USE_TIMERB1        // interferes with PWM on pin 3
#define USE_TIMERB2        // interferes with PWM on pin 11
//#define USE_TIMERB0        // interferes with PWM on pin 6

Thanks will give that a try.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.