Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PWM in ATMEGA

The atmega has a few different PWM modes, the frequency and duty ratio depend on the mode and values used, this is a description of the way to calculate them.

In fast PWM top=ICR1, the output PWM frequency=timer clock/(ICR1+1) and the duty=OCR1A(B)/ICR1
In fast PWM top=0h00ff, the output PWM frequency=timer clock/256 and the duty=OCR1A(B)/256
In fast PWM top=0h01ff, the output PWM frequency=timer clock/512 and the duty=OCR1A(B)/512
In fast PWM top=0h03ff, the output PWM frequency=timer clock/1024 and the duty=OCR1A(B)/1024

In phase correct or phase & freq correct top=ICR1, the output PWM frequency=timer clock/(ICR1*2) and the duty=OCR1A(B)/ICR1
In phase correct or phase & freq correct top=0h00ff, the output PWM frequency=timer clock/(255*2) and the duty=OCR1A(B)/256
In phase correct or phase & freq correct top=0h01ff, the output PWM frequency=timer clock/(511*2) and the duty=OCR1A(B)/512
In phase correct or phase & freq correct top=0h03ff, the output PWM frequency=timer clock/(1023*2) and the duty=OCR1A(B)/1024

OCR1A(B) means OCR1A or OCR1B because there are two registers you can use to generate two PMW duty cycles of the same frequency.

Alex

Comments

There are no comments to display.

Part and Inventory Search

Blog entry information

Author
alexan_e
Read time
1 min read
Views
1,241
Last update

More entries in AVR

More entries from alexan_e

Share this entry

Back
Top