Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Atmega8a PWM with TCNT1 issue

Status
Not open for further replies.

White Heart

New Member
Hello Friends

I've a question about using Atmega8a for fast mode PWM using TCNT1 (16 bit) and hope to answer me with my thanks in advance

I want to set Fast PWM to use TCNT1, OCR1A to hold the comparing value of the counter and use OC1A as an output, I know how to setup the configuration that i want ,


TCCR1A |= (1 <<WGM11 | 1 <<WGM10 ); // Set PWM type (Fast PWM) e

TCCR1B |= (1 <<WGM13 | 1 << WGM12);

but my confusion is

if i used OCR1A to store the comparing value, where can i store the TOP value (period time),which register i can use for storing ?

if i want to make OC1B as output, where can i store the TOP value ?

if i want to use both OC1A and OC1B at the same time, which registers used to store the comparing values (dutty cycle), and which one is used for storing the top values (period)

is it possible to use a TOP value more than 1024 since TCNT1 is 16 bit ?
 
Take a look at the Datasheet. Page 89.

When I'm interpreting right, You can use the 4 Fixed Values 0x00FF, 0x01FF,0x03FF and 0xFFFF.
Or setting the ICR1 for the top value and set OCR1A OCR1B for set the PWM Value in the Range of ICR1.

Be aware in Fast PWM Mode an AVR Controller always built a little spike at TCNT1=0 for 1 Timer Cycle.
But when no PWM output is needed You can deactivate the OC1x outputs, until a PWM Output has to been built.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top