SpenceKonde / ATTinyCore

Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8
Other
1.53k stars 301 forks source link

Compilation failed with Timer0 Interrupt handler #827

Closed DoubleCouponDay closed 7 months ago

DoubleCouponDay commented 7 months ago

I am using the following sketch with the ATTinyCore Board Manager targeting an ATTiny84A. When I try to compile the sketch I get the following error. If I use the TIM1_OVF_vect to interrupt on timer 1 instead, it compiles.

In the tiny core in this repository, I found a second definition of TIM0_OVF_vect which conflicts with mine, preventing compilation. The tinymodern core does not seem to have this issue.

My question is how can I use the tinymodern core to compile so that I can use timer 0 with an interrupt routine?

#include <Arduino.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <avr/interrupt.h>

void setup() {}
void loop() {}
ISR(TIM0_OVF_vect) {}
Linking everything together...
"/usr/bin/avr-gcc" -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=attiny84  -o "/tmp/arduino_build_300293/apd.ino.elf" "/tmp/arduino_build_300293/sketch/apd.ino.cpp.o" "/tmp/arduino_build_300293/core/core.a" "-L/tmp/arduino_build_300293" -lm
wiring.c.o (symbol from plugin): In function `__vector_11':
(.text+0x0): multiple definition of `__vector_11'
/tmp/arduino_build_300293/sketch/apd.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board ATtiny24/44/84(a) (No bootloader).
hmeijdam commented 7 months ago

Try with Millis()/micros() disabled.

DoubleCouponDay commented 7 months ago

Thank you @hmeijdam , I can confirm that is working. Is there a dependency on timer 0 when using the millis() function?

hmeijdam commented 7 months ago

You can read that here

SpenceKonde commented 6 months ago

Worth noting that

So had my crystal ball been working, obviously I wouldn't have named the second subcore in this core tinymodern because the next part families released would instead herald the coming of what I now call modern AVRs, (Microchip who as you know bought Atmel in the mid 2010's, has not provided any such official term, nor a converse term to call non-modern AVRs; I call them Classic AVRs). And if I'd had more of a clue I'd have not needed a second core at all, but I didn't know what I was doing way back then, other than that I wanted to make an ATtiny841 work on arduino because I wanted 2 serial ports and Software Serial Sucks.

The big push in addition to consistency between parts (in the form of all pins_arduino.h files being completely overhauled) with 2.0.0 is eliminating the "tinymodern" core which was nothing but trouble - the two had to be kept in sync, that never happened, and problems resulted.

DoubleCouponDay commented 6 months ago

Thanks @SpenceKonde for the in-depth answer.