Go Down

Topic: 10 bit pwm, How? (Read 1 time) previous topic - next topic


Can somebody give me a pointer to how to set the timer 1 pwm to 10 bit resolution.

I have been looking at the atmega168 datasheet but there is too much info to take in all at once. :-?

Triffid Hunter

see table 15-4 on page 133. You want to

TCCR1A |= (1<<WGM11) | (1<<WGM10);
TCCR1B |= (1<<WGM12);
TCCR1B &= ~(1<<WGM13);

which will set WGM1[3..0] to 0111 which according to table 15-4 is 10-bit fast pwm. If you want phase correct PWM, move WGM12 to the &= ~ line so it's set to zero instead of 1.


Thanks, I am just about getting a handle on what all the registers do now.

I found the following article helpful too. http://tinyurl.com/2jglra

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131