avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] pwm


From: Galen Seitz
Subject: Re: [avr-gcc-list] pwm
Date: Mon, 05 Jul 2004 08:20:19 -0700

IMC <address@hidden> wrote:

> Hi all.
> 
> I have been playing with the PWM functionality of the mega8. I am a little
> confused with it though.
> 
> Using the 16 bit timer, TCNT1 I thought I would be able to vary the pulse
> whilst keeping the period constant. I have managed this with TCNT2 - 8 bit
> version. This all seemed to work fine. Is it me or is the PWM just period
> modulation for PWM based on TCNT1?
> 
> If it is possible, does anyone know the registers to affect to implement
> this. I had currently been working with TCCR1A and TCCR1B and changing the
> OCCR1A register thinking this would change the pulse width but it just
> changed the period.
> 

It sounds like you have the timer set up to use OCCR1A as the TOP value.
You probably want to use one of the "Fast PWM" modes, with a fixed value
for TOP.  See "Table 39. Waveform Generation Mode Bit Description" in the
mega8 datasheet dated 08/03.  I would suggest starting with "Fast PWM,
10 bit".  In this mode TCNT1 continuously count up from 0 to 0x3ff, and
you can use OCR1A to control the pulse width.

galen



reply via email to

[Prev in Thread] Current Thread [Next in Thread]