[ Log In ]
Image of the Atmega324p

Atmega324P

$8.50
Qty:
USB AVR programmer

USB AVR Programmer

$9.95
Qty:
Breadboard adapter for the USBasp AVR Programmer

USBasp Breadboard Breakout Adapter

$4.90
Qty:
Serial to USB converter with Micro USB cable

USB to Serial Converter

$10.95
Qty:
Thumbnail: Crystal Oscillator 18.432 MHz for UART

18.432 MHz Crystal Oscillator 18pf 30ppm

$0.94
Qty:
Thumbnail: 22 pF Capacitor

22 pF Multilayer Ceramic Capacitor

$0.43
Qty:
Thumbnail: Quartz crystal oscillator - 16 MHz

16 MHz Crystal Oscillator 20 pF Through Hole

$0.75
Qty:
Thumbnail: 4x4 keypad top view.

4x4 Keypad with Adhesive Backing

$3.80
Qty:
Thumbnail: quad buffer line driver 74HC126E

Quad Buffer Line Driver (Through Hole)

$0.69
Qty:
3 pin slide switch

SPDT Slide Switch 3 pin 30V

$1.49
Qty:

Result: Outputting a PWM (Pulse Width Modulation) on any Pin of the AVR Microcontroller

In this program, interrupts are used to provide an interrupt every time the PWM counter reaches the top value in ICR1 (Input Capture Register 1).

Within the ISR (Interrupt Service Routine), all of the pins that will output the PWM signal will go high. This is to start all of the pins off as a pulse. When the timer reaches the desired width, that single pin will go low. This is using the TCNT1 register to determine the counts.

To enable the interrupt for the Timer, the TIMSK1 (Timer Mask) OCIE1A (Output Compare Interrupt Enable 1A) bit is set.

The oscilloscope is also used to show the PWM output on the pin of choice.

Comments and Additional Information

Have some code to share? Or additional information? Respond here:

You need to be logged in to save a response on this page. The response must be constructive, helpful, supplimentary or to correct the existing video, code or narrative content.

Description:

Code (optional):