2
\$\begingroup\$

Is there difference between Timer vs Counter in ATmega328P? Or is it the same thing?

\$\endgroup\$
  • \$\begingroup\$ You can use a timer as a counter. It all depends on how you use initialize it and use it. \$\endgroup\$ – DerStrom8 Sep 7 '14 at 0:20
  • \$\begingroup\$ Why do you believe that they are different? \$\endgroup\$ – Ignacio Vazquez-Abrams Sep 7 '14 at 0:25
  • \$\begingroup\$ @IgnacioVazquez-Abrams Because in datasheet it's written as "Timer/Counter" everywhere instead of just "Timer" or "Counter" \$\endgroup\$ – Daveel Sep 7 '14 at 0:33
  • \$\begingroup\$ @Daveel It's written like to to make explicit that they're the same thing (ie, a Timer OR a Counter). \$\endgroup\$ – sapi Sep 7 '14 at 5:28
1
\$\begingroup\$

A Timer and a Counter on an ATmega328 is the same piece of electronics.

There are three independent timers on the ATmega328.
Each timer has one counter register, and two comparison registers.

Each of the three timers has slightly different capabilities.
One has a 16bit counter, the other two 8bits.
With one it is much easier to count an external clock.
One has more flexibility on dividing down the main clock, so it is easier to adjust to count at a specific rate.

\$\endgroup\$
1
\$\begingroup\$

They are one and the same.

A "timer" is just a counter being fed a periodic pulse train; you can determine the elapsed time by multiplying the current count by the period of the pulses. Since possible sources for the pulses include both an oscillator (either directly or through a prescaler) or an external pulse (periodic or otherwise) via Tx (not to be confused with TX), it can act in both modes.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.