I know this is repeated question,I referred many post, but i didn't get an clear answer. My understanding is most of the micro-controller will have a 16/32 bit timer, which increments its ticks based on oscillator and clock provided(main/peripheral clock, divider, prescaler) to it.

When i started to work on simple 8051 micro-controller, I thought timer and counter are same. The reason of my thought after the simple below test i did in 8051.

"8051 has a bit C/T in TMOD Register. If timer is started after a reset i see TH/TL register are incremented irrespective of C/T bit (If bit set to 0 or 1 result is same)."

Later i worked on PIC microcontroller, I noticed that the timer and counter has different concept in this controller. If it is configured as Timer Mode, the register TMRnH/TMRnL(where n is 1 or 0) was incremented for every instruction cycle. But if it is configured as Counter, the register was not incremented for every instruction, Then i connected one switch in pin TnCkn. When i pressed that switch, the counter was incremented. With this i changed my perspective that the timer and counter are not same. Timer will increment for every instruction cycle(internal clock/signal) but counter will increment for every time either a raising edge or falling edge with external clock/signal.

Now i am working on Freescale MPC controller, Here i noticed the term GPT(General purpose timer). There are 5 timer units(GPT) in this controller, each timer unit has a register called "Counter Register(TCNTn)". When i started a timer, this register has incremented for every instruction cycle. So i thought this controller has only Timer not a counter. But i perturb with two terms below

  1. Counter Register - If it is timer, why it is called Counter register in user manual of MPC.
  2. In User manual, there is a section called Timer/Counter under this section, there is a subtopic called GPT and there is no subtopic for counters separately. which means timer and counter are same?

My question:

  1. Is really Timer and counter are same?
  2. If it is not same, why 8051 and MPC are working as same (act as timer and counter)?
  • 4
    \$\begingroup\$ What is your question? \$\endgroup\$ – Dave Tweed Mar 29 '17 at 12:58
  • 5
    \$\begingroup\$ Ok, you're wrong. Not every microcontroller has a 16/32 bit timer. \$\endgroup\$ – Finbarr Mar 29 '17 at 13:05
  • \$\begingroup\$ "I know this is repeated question, But i didn't get proper answer." Then don't ask again and wait for someone else to answer. \$\endgroup\$ – KingDuken Mar 29 '17 at 13:07
  • \$\begingroup\$ @KingDuken i mean, i have referred many post, which i didn't get proper answer. \$\endgroup\$ – user2732944 Mar 29 '17 at 13:17
  • \$\begingroup\$ @DaveTweed Is this question is clear? \$\endgroup\$ – user2732944 Apr 2 '17 at 11:35

For either a "counter" or a "timer", the basic hardware is the same — a binary counter, which might be 8, 16 or 32 bits wide.

The difference in functionality is in details such as what the clock source for the counter is and what conditions can trigger an interrupt.

A counter that is clocked by a fixed frequency (either internally or externally generated) is usually used to generate or measure time intervals, and so we call it a "timer". Sometimes it can only generate an interrupt when it overflows, and sometimes there's a separate register that contains a value against which the count is compared, and an interrupt is generated when they match. Sometimes a signal transition on an external pin can be used to start and​/or stop the counter — or capture its value in a register and generate an interrupt — allowing the direct measurement of intervals.

A counter that is clocked by an external signal that may or may not be periodic is generally being used to count those events, and so it is simply called a "counter".

Most microcontrollers have one or more such counters built in, and they usually have registers that allow things like the clock source and interrupt conditions to be configured by the firmware, hence the term "counter/timer" is usually used to describe them. However, you need to look at the details in any particular chip's data sheet in order to determine whether it meets the needs of your application.


Is really Timer and counter are same?

yes. they are both counters, and sometimes with different clock sources, external / internal, different prescalers, etc. but neither is fundamental to the operations.


A timer "counts" edges/cycles from some source, a counter "counts" edges/cycles from some source. You are getting way too concerned about terms that dont really matter. Some folks say one thing some folks say another some mix the terms up. Chip vendors may use one term, or another or both depending on whether that is just their convention or they are trying to attract folks that use either term.

What does matter is on a chip by chip or vendor by vendor basis you read the documentation for the peripherals in the chip, ignoring for the most part any other chip you have used and find out what this one chip in particular does or doesnt do for you, doesmt matter if they call it a DIO or GPIO or IO or UART, or USART. Whether they use the terms MOSI/MISO or SIMO/SOMI or neither (D0, D1, D2, ...).

What matters is what it does or doesnt do not what it is called or the vocabulary used.


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.