In my code I use only LiquidCrystal library and Servo library. When I try to compile the code following error appears
Servo/Servo.cpp.o: In function `Servo::attached()':
/usr/share/arduino/libraries/Servo/Servo.cpp:336: multiple definition of `__vector_42'
robot_v2.cpp.o:/usr/share/arduino/robot_v2.ino:662: first defined here
/usr/lib/gcc/avr/5.4.0/../../../avr/bin/ld: Disabling relaxation: it will not work with multiple definitions
Servo/Servo.cpp.o: In function `Servo::attached()':
/usr/share/arduino/libraries/Servo/Servo.cpp:336: multiple definition of `__vector_47'
robot_v2.cpp.o:/usr/share/arduino/robot_v2.ino:662: first defined here
collect2: error: ld returned 1 exit status
Apart from above mentioned libraries, I use a 16 bit timer as follows.
DDRC |= B01010101;
......
cli();
TCCR4A = 0;
TCCR4B = 0;
TCCR5A = 0;
TCCR5B = 0;
OCR4A = l_target;
OCR5A = l_target;
TCCR4B = _BV(WGM42) | _BV(CS41);
TCCR5B = _BV(WGM52) | _BV(CS51);
TIMSK4 |= (1 << OCIE4A);
TIMSK5 |= (1 << OCIE5A);
sei();
Let me know what I'm doing wrong and how to fix this issue? Are there any other libraries than the standard Servo library for arduino? I'm using Arduino Mega board.
Here are the ISRs.
ISR(TIMER4_COMPA_vect)
{
if (OCR4A != l_target) {
OCR4A = l_target;
}
PORTC ^= B00000001;
}
ISR(TIMER5_COMPA_vect)
{
if (OCR5A != r_target) {
OCR5A = r_target;
}
PORTC ^= B00010000;
}
I found the related code from Servo library. According to that it uses 1,3,4 and 5 timers. So, I cannot use them for any other purpose. I will have to use Timer 2 or any other solution. I'm answering my own question as a reference for any one else who faces similar situation.
// Say which 16 bit timers can be used and in what order
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define _useTimer5
#define _useTimer1
#define _useTimer3
#define _useTimer4