I’m trying to make use of the built-in timers. I’m using Arduino Mega, which means I have 6 timers, where Timer0 is used by Arduino Timer functions (like delay). Thus, I have 5 timers for myself
I have found two libraries, which can make use of Timer1 and Timer3. Both these timers are 16 bit.
Questions.
How come no one made an official library to control Timer2, 4 and 5 ??
I’m using Timer1, and I’m trying to understand which influence it has on my hardware usage. The timer is in fact a counter, but is the counter connected to a pin?
But what if I do not want to route the counter PWM to those pins?
I’m using the timer to turn on and off some LEDs, and I cannot use pin 13 for some reason – I have even tried to use the Timer1 function called Timer1.disablePwm(13) but that doesn’t really make any difference. Now, the easy solution is to just move my LEDs to other pins, but I want to understand what’s really happening here
How come no one made an official library to control Timer2, 4 and 5 ??
Why haven't you?
I'm using Timer1, and I'm trying to understand which influence it has on my hardware usage. The timer is in fact a counter, but is the counter connected to a pin?
Define what you mean by "connected to". How can you logically expect to read a pin to know anything about the timer?
Some timers are used to generate PWM on specific pins, so using a timer for another purpose will disable PWM on some pins.
but I want to understand what's really happening here
We can't see your code or your LEDs, so, you are on your own.
All the information you need about the timers is in the Atmega2560 datasheet. That is the place to go when you want to extend beyond the Arduino system.
I suspect the reason the Arduino system does not have a library for those extra timers is because very few people use them. As @PaulS has said, feel free to publish your own solution for the benefit of others.
When the timer is in one of the PWM modes, it controls the relevant pins IF the relevant
registers are set up to do this. Look at the code for analogWrite() to see how this happens
(you have the code, its in the release. The file is 'wiring_analog.c').
The mapping from the relevant timer output compare register (OCR1A, OCR3C etc) to pins
is fixed in the hardware, the enabling of PWM is configurable. On the Mega some pins are
shared by two timers - obviously you only drive them from one at a time.
read the timer chapter in the datasheet like 100x (not in one sitting :)) and write your own code.
A good oscilloscope or logic analyzer will be very helpful if you are generating waveform (pwm).