Hello,
My end goal is to use the USART interrupt service routine to retrieve data and save it into the SRAM for processing in the main loop. However, using Serial.begin(9600) gives me this error.
HardwareSerial0.cpp.o (symbol from plugin): In function `Serial':
(.text+0x0): multiple definition of `__vector_25'
C:\Users\MARIAN~1.GUI\AppData\Local\Temp\arduino_build_31604\sketch\USART_Interrupt.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
So, I learned how to initialize the serial port in a different way.
//Serial Port 0 initialization
//Serial.begin(9600)
UBRR0H = 0x00; // Load upper bits into the high byte of UBRR
UBRR0L = 0x67; // Load lower bits into the low byte of UBRR
/*CALCULATIONS
MSTR_CLOCK = 16000000
BAUD_RATE = 9600
(MSTR_CLOCK/(16*BAUD_RATE))-1=103
0x67 = 103
Therefore, UBRR0H = 0 or 0x00
And UBRR0L = 103 or 0x67
*/
UCSR0B |= (1 << RXEN0) | (1 << RXCIE0); // Enable the reception and receive interrupt
UCSR0C |= (1 << UMSEL01) | (1 << UCSZ02) | (1 << UCSZ01); // Set frame: 8 data bits, 1 stop bit
interrupts();
This works with the ISR, but when I used other Serial.xxx() functions, the same error returns which leads me to believe that these two segments are not compatible.
This small routine is potentially going to be placed in a larger program that calls Serial.xxx() functions multiple times. I would ideally like not to low level code these functions and use the Arduino library.
There has to be some simple fix to this, right?