This post describes the timers of MCU.
Count function
Timer count function of MCU divides the crystal oscillator clock by prescaler and supplies it to the timer for counting. Other than crystal oscillators, there are also timers that count signals from sensors.
Count type
Free-running type | Free- running type counts up to the maximum value of the timer bit length and then repeats back to zero. |
Count-up type | Count-up type counts up to the compare value and repeats back to zero after a match with the compare value. |
Count-down type | Count-down type starts down-counting after setting the set value in the timer, and repeats returning to the set value when it reaches zero. |
Input/Output
Here are some examples of timer inputs and outputs. As shown in the table below, timer inputs/outputs are external to the microcontroller and internal to the microcontroller, and various functions can be realized in conjunction with other microcontroller functions.
MCU | IO | Function | Description |
---|---|---|---|
External | Input | Signal time measurement(STM) | Rising or falling edge of input signal, time measurement of both edges. |
Signal pulse measurement(SPM) | Falling or falling edge of input signal, measuring the number of edges on both edges. | ||
Output | Pulse width modulation(PWM) | Output with fixed output signal cycle and variable Hi/Low time or duty (Hi time/cycle). PWM also includes 2-phase PWM for 2-phase modulation and 3-phase PWM for 3-phase modulation. | |
One-shot pulse output(OSP) | Pulse output with set Hi or Low time for output signal. One-shot pulse output also includes event-triggered output one-shot pulse output. | ||
Internal | Input | Trigger measurement(TRG) | Time measurement from program triggers such as Timeout and Wait. |
Output | Cycle output(CYC) | Cycle event output to Thread (Task), ADC, communication, etc. |
Measured and output waveforms of timers
Examples of timer measurement waveforms and output waveforms are shown below.