I have an Arduino MEGA 2560 (ATMEGA 2560) and need to use a timer to increment a variable each second (pretty much like millis() but without the millisecond resolution). As I am afraid to impact system functioning, is there any place (like lib documentation/tables or charts) to know which timers are being used by official libraries (rather than fully read the whole library code)? I think that, for example, timer0 is used for millis() and other time related routines. Am I wrong?
Thanks in advance.
Yes, timer0 is used for millis. On the Mega you have a reassuringly large number of timers - but remember each one controls 2 or 3 PWM outputs so you have to be aware of which PWM pins you want to use. Unfortunately there is no standardised way of marking libraries with the resources (such as timers and interrupts and pins) they use - read the documentation (and then the code itself to make sure!).
I'd avoid timer1 and timer2 simply because they are used by various Arduino libraries already that run on standard Arduinos, so start at timer3? I think timers 3,4,5 are all 16 bit ones like timer1 IIRC.
Thanks for your quick reply :) .