
Regarding toggle mode, I wonder if there is any practical application of it.1 AVR 8-bit Microcontrollers AVR135: Using Timer Capture to Measure PWM Duty Cycle APPLICATION NOTE Introduction This application note demonstrates the process to measure the pulse width of PWM waveform using Capture module of the Timer/Counter in Atmel AVR devices. This is because upon increasing the compare voltage, the duty cycle increases. Out of the three modes, inverted, non-inverted and toggle mode, non-inverted mode is the most reasonable. For general applications, phase correct PWM would do. But if you are using it for telecommunication purposes, or for signal sampling, fast PWM would be better. If you want to control the speed of DC motors or brightness of LEDs, go for any one of them. If you need quite high resolution in your application, go for 16bit timer. Obviously there isn’t much difference in speed between 123/256th and 124/256th of full speed in case of a motor! But if you use servo motors, you have to use 16bit timer. Even 8bit is too much, but there is no other choice. In this case, having 65536 steps is totally useless! Thus we can use an 8bit timer for this. Now suppose you want to control the speed of a DC motor. In 8bit accuracy, you have 256 individual steps, whereas in 16bit accuracy, you have 65536 steps. TIMER0 and TIMER2 provide 8bit accuracy whereas TIMER1 provides 16bit accuracy. In AVR, PWM Mode is available in all timers. Now that you are familiar with all the PWM concepts, it’s upto you to decide Since in most cases the value of TOP remains same, it doesn’t matter which one we are choosing – Phase Correct or Frequency and Phase Correct PWM. Thus, for this, we need Frequency and Phase Correct PWM.

In general, there are three modes of operation of PWM Timers:įrequency and Phase Correct PWM Description Now that you are aware of the terminologies of TOP, BOTTOM and MAX, we can proceed to the different modes of operation. Now, the CTC Mode can be extended to introduce variable TOP as shown in figure C (however there isn’t any practical utility of this).

The yellow line shows how the timer would have gone in normal mode. Due to this, the value of TOP can be reduced as shown in figure B. Now, I guess you all are familiar with timers in CTC Mode, in which you can clear the timer whenever a compare match occurs. The timer always counts from 0 to TOP, then overflows back to zero. In figure A shown above, TOP = MAX. Thus for a 8bit timer, MAX = 255 and for a 16bit timer, MAX = 65535. 16bit timers count from 0 to 65535, then back to zero.

8bit timers count from 0 to 255, then back to zero and so on.

We are very well aware that the AVR provides us with an option of 8 and 16 bit timers.
