Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Setting PWM period

2011-10-11 by Clark Martin

On Oct 10, 2011, at 8:34 PM, Philippe Habib wrote:

It would help if you listed the processor in use.  Without that we can't know what the settings mean.

> Thanks to all of the help I got a couple of weeks ago with timers, I have been able to get my PWM stuff (mostly) working.
> 
> I assume it is possible to tune the PWM period beyond the blunt instrument of the div by registers but I don't see how to do it.
> 
> Here are my settings, which give me a 500Hz frequency with an 8M clock. I would like to get that to between 200 and 300 Hz if I can. Am I missing a setting that lets me do that, or is it not possible.
> 
> DDRD |= (1 << PD6);	 // enable PWM (OC0A, PD6 ) output pin 
> OCR0A = 0;	 // set PWM % 0= off 255 = full
> TCCR0A = (1 << COM0A1) | (0 << COM0A0) | // OC0A in PWM mode
> (0 << COM0B1) | (0 << COM0B0) | // OC2B is not used
> (1 << WGM01) | (1 << WGM00); // PWM mode
> TCCR0B = (0 << CS00) | (1 << CS01) | (0 << CS02); // div 8 on clock
> TCCR0B |= (0 << WGM02); // more PWM mode

Clark Martin
Redwood City, CA, USA
Macintosh / Internet Consulting

"I'm a designated driver on the Information Super Highway"



[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.