Go Down

Topic: A simple question about timers & pin usage. (Read 675 times) previous topic - next topic

DigitalJohnson

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

Thanks for any replies,
DJ
DigitalJohnson


PaulS

Quote
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.

MarkT

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 won't respond to messages, use the forum please ]

DigitalJohnson

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
DigitalJohnson

DigitalJohnson

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

DJ
DigitalJohnson

dhenry

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


Yes.


PaulS

Quote
Yes.

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

Nick Gammon

#8
Nov 21, 2012, 11:21 pm Last Edit: Nov 21, 2012, 11:23 pm by Nick Gammon Reason: 1

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":

Code: [Select]

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.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon


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


Not necessary.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

DigitalJohnson

Thanks Nick. I guess it's time to learn all about timers.  :smiley-eek-blue:
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
DigitalJohnson

Go Up