What is Timer actually ?? (Beginner in circuit)

Discussion in 'Embedded Systems and Microcontrollers' started by Rizu, Sep 8, 2014.

  1. Rizu

    Thread Starter New Member

    Nov 1, 2012
    Hi, I am really a beginner in electronics. I wanna know what timer is actually. Like the one that is used in microcontrollers. I have googled it and it returns many complex definitions of timer in terms of oscillator, comparator etc. of which I am not aware of really. Can someone please explain to me what timer is in layman's terms. I am really interested in the topic but I just don't know about it...............
    Thanks in advance :)
  2. sirch2

    Well-Known Member

    Jan 21, 2013
    In a microcontroller a timer is a circuit that can be programmed to do something based on a number of clock cycles. All microcontrollers have a "clock" which is a regular signal provided by an oscillator. The clock signal causes the MCU to do something, normally execute a program instruction, but the same clock can drive the timer circuitry. Depending on the MCU the timer can either be connected to an output pin, so you could generate an ouput signal at a different frequency to the MCU clock, or it can trigger an interrupt after a certain time has elapsed.

    What is the point? Well, your program may take varying time to execute depending on what path through your program is taken but you may need something to happen at a specific time, such as sampling an input every second, regardless of what your program is doing.

    A special case is the Watchdog Timer. This timer is hooked up to the MCU reset and counts down from some value, if it does not get restarted before it counts down to zero, it resets the MCU. Suppose your code got stuck in a loop, it would not reset the watchdog and the MCU would reset, usually after a few seconds.

    Hope that helps
    Rizu likes this.
  3. MrChips


    Oct 2, 2009
    In a microcontroller, a timer module is simply a binary counter circuit.

    Basic timers come in 8-bit, 16-bit, 32-bit lengths, etc. On a simple 8-bit processor, an 8-bit counter register is commonly used.
    In its simplest form, a counter can be made to count upwards. The clock frequency may be selectable under program control.
    Basic timer operations may be any number of functions such as:

    Reset count to zero.
    Set count to a particular starting value.
    Start/Stop counting.
    Stop counter when value overflows.
    Stop counter when value reaches a certain value.

    Beside these basic functions there may be other functions such as pulse-width modulation output, input capture (record when an input trigger is received), output compare (generate a signal when a certain value is reached).
    Rizu likes this.