On a generic Arduino (ATMEGA386P) -based application, I need Timer 0's overflow interrupt (normally goes to TIMER0_OVF_vect) to point to my own code, not the existing Arduino code. I realize this will cause the Arduino runtime functions dependent on the normally-functioning 1 kHz interval to be unusable. I am working within an existing Arduino-based application and cannot readily move out of the Arduino environment (example, to AVR-GCC) as there are some other Arduino dependencies I need to retain. I cannot harness the other timers (Timer 1 or Timer 2) as they are in use for other purposes.
My question is this - how do I (or can I) reconfigure Timer 0 so that it's Overflow interrupt vector points to my own code's ISR entry point?
Thank you.
ADDING INFORMATION 13 DEC 2021 per amike comment 10 Dec 2021
I created ISR(TIMER0_OVF_vect) (that I would use as a substitute for the one present in wiring.c)
ISR(TIMER0_OVF_vect)
{
// MY SUBSTITUTE CODE WILL GO HERE
}
While the code appears to get through the compiler, it fails during linking with the following error message (from the Arduino IDE
wiring.c.o (symbol from plugin): In function __vector_16': (.text+0x0): multiple definition of __vector_16'
sketch\MYTESTPROGRAM.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno
This problem is a show-stopper for a larger project I'm working on, so I'd be very grateful for any further advice on whether I can replace the interrupt service routine (without altering or recompiling the Arduino libraries.)
Thanks again
TIMER0_OVF_vect()routine? Like this:ISR(TIMER0_OVF_vect) { // your stuff... }It compiled without complaining about duplicate definitions, so it looks like we should be able to override the default implementation. Are you positive that the other required libraries do not needmillis()and the rest? Have fun!