A simple question about timers & pin usage.

Is it possible to use a timer without affecting any pins?

Thanks for any replies,
DJ

Yes.

Is it possible to use a timer without affecting any pins?

No. Every timer has multiple purposes. If you divert it from its assigned purpose(s), that will have some impact.

To flesh this out a bit:

The three timers in the Uno (and similar) are used by analogWrite() to control the PWM outputs on pins 3,5,6,9,10,11.
timer0 is used to implement millis(),micros(),delay().

If you don't use analogWrite() on pins 3,9,10,11 then you can use timers 1 and 2 how you like.
If you don't use the time functions or analogWrite on pins 5,6 you can
user timer0 how you like (but you'll have to inhibit the interrupt handler perhaps).

Timers can be used to just count time (no need to connect to pins like analogWrite() does), or to count inputs (timer1 with pin 5),
or to generate waveforms via PWM, or to generate regular interrupts. Timers 0 and 2 are 8 bit only, timer1 is 16 bit (but can be
configured as 8,9 or 10 bits too).

I've got a mega2560 and, believe it or not, I'm using almost every pin. I want to use a timer for timing events between some of the hardware I have attached. The thing is, all of the timer compare match pins are used by hardware devices. Is there any way to use a timer and not have it output on it's related compare match pins?

Thanks for your time,
DJ

Now that I've thought about it, I suppose I could set up software timers using micros() or millis() and poll them.

DJ

Is there any way to use a timer and not have it output on it's related compare match pins?

Yes.

Yes.

Hey, dumbshit, that's not an acceptable answer!

DigitalJohnson:
The thing is, all of the timer compare match pins are used by hardware devices. Is there any way to use a timer and not have it output on it's related compare match pins?

Why all the bickering? It is completely optional whether the output of a timer is directed to a hardware pin. For example, for "TCCR0A – Timer/Counter Control Register A":

COM0A1 = 0, COM0A0 = 0: Normal port operation, OC0A disconnected.

"Normal" operation (whatever that means) is that the output pin is not connected.

(edit) I suppose "normal" means you get to use the port in its normal way, that is the way you choose to use it.

DigitalJohnson:
Now that I've thought about it, I suppose I could set up software timers using micros() or millis() and poll them.

Not necessary.

Thanks Nick. I guess it's time to learn all about timers. :fearful:
I'll do some research and see if I can get all the parts to play nice with each other. If so, I'll post some code for others' in need.

Thanx,
DJ

1 Like