Hello,
I would like to display the Time independently of what the rest of my program is doing. As I am fairly new to arduino and coding, my research led me to the magical world of Interrupts. After some tutorials and articles I now have a basic understanding of the subject.
I found this library : GitHub - PaulStoffregen/TimerOne: TimerOne Library with optimization and expanded hardware support, which should allow me do use a Timer (ex :Timer1) and come up with something like that :
void Setup(){
Timer1.initialize(1000000);
Timer1.attachInterrupt(UpdateTime);
}
void UpdateTime(){
Serial.println(Time blablabla...);
}
I tried to compile the library : #include <TimerOne.h>, but I am getting this error : [This is an extract of the entire error message]
Arduino: 1.8.12 (Windows 7), Board: "Arduino Nano Every, None (ATMEGA4809)"
WARNING: library TimerOne-master claims to run on avr architecture(s) and may be incompatible with your current board which runs on megaavr architecture(s).
In file included from C:\Users\HOMEST~1\AppData\Local\Temp\arduino_modified_sketch_464418\sketch_apr12a.ino:1:0:
C:\Users\HomeStudio\Documents\Arduino\libraries\TimerOne-master/TimerOne.h: In member function 'void TimerOne::initialize(long unsigned int)':
C:\Users\HomeStudio\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:184:2: error: 'TCCR1B' was not declared in this scope
TCCR1B = _BV(WGM13); // set mode as phase and frequency correct pwm, stop the timer
^~~~~~
C:\Users\HomeStudio\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:184:2: note: suggested alternative: 'TCB1'
TCCR1B = _BV(WGM13); // set mode as phase and frequency correct pwm, stop the timer
^~~~~~
TCB1
In file included from c:\users\homestudio\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\homestudio\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,
from C:\Users\HomeStudio\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/api/String.h:30,
from C:\Users\HomeStudio\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/api/Print.h:24,
from C:\Users\HomeStudio\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/api/Stream.h:25,
from C:\Users\HomeStudio\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/api/Client.h:22,
from C:\Users\HomeStudio\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/api/ArduinoAPI.h:29,
from C:\Users\HomeStudio\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:23,
from sketch\sketch_apr12a.ino.cpp:1:
C:\Users\HomeStudio\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:184:15: error: 'WGM13' was not declared in this scope
TCCR1B = _BV(WGM13); // set mode as phase and frequency correct pwm, stop the timer
^
In file included from C:\Users\HOMEST~1\AppData\Local\Temp\arduino_modified_sketch_464418\sketch_apr12a.ino:1:0:
C:\Users\HomeStudio\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:185:2: error: 'TCCR1A' was not declared in this scope
TCCR1A = 0; // clear control register A
^~~~~~
C:\Users\HomeStudio\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:185:2: note: suggested alternative: 'TCB1'
TCCR1A = 0; // clear control register A
^~~~~~
[PART OF THE ERROR MESSAGE REMOVED HERE]
exit status 1
Error compiling for board Arduino Nano Every.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
2 questions :
-What does the error mean and can I fix it ?
-I have seen that using a Serial request during an interrupt is not recommanded, so does anyone has a better approach to have the time displayed every second in an independent way ?
I checked the "Show verbose output during compilation" box but the error message is too long to be paste here and I don't know which part is relevant.
Thanks for your help !