FAST PWM (Pulse Width Modulation) Mode

In the Pulse Width Modulation (PWM) mode the duty cycle of a square wave can be varied. This will vary the avarage DC voltage of the waveform. When the waveforn is filtered by an RC circuit, this will create a Digital to Analog Convertor (DAC). For example a LED brightness or a DC motor can be controlled by the PWM waveform.

TIMER2 is a 8-bit Timer with PWM and output compare functions like TIMER1. The most interesting feature of TIMER2 it that it can use a external crystal separate from the system clock and the clock source.

Timers and counter are the most used peripherals in a microcontroller. They are being able to measure time periods, measure frequency, determine pulse width or provide output signals. Example applications might include producing tones to create music, create a time base for a real time clock or measure rpm of an engine. Timers and counter are simply binary up-counters. In timing mode the binary counter are counting the time periods and in counter mode, they are counting the events or pulses.

adc pic1

In this tutorial we introduce another pheriperal of the AVR, the ADC pheriperal. The ADC has a 10 bit convertor, that means that the input voltage will be converted into values from 0 to 1023.  We read the input of an ADC channel and output it to a IO port.

The Timer1 of the AVR ATMEGA328 microcontroller is a 16 bits timer/counter that is much more versatile and complex then the 8-bits TIMER0. Timer1 contains one 16-bit input capture register and two 16-bit output compare registers. The input capture register is used for measuring pulse widths or capturing times, while output compare registers are used for producing frequencies or pulses from the timer/counter to an output pin on the microcontroller. TIMER0 is usually started, stopped, and reset, while TIMER1 is usually left running.