Pages: [1]   Go Down
Author Topic: 10 bit pwm, How?  (Read 881 times)
0 Members and 1 Guest are viewing this topic.
SouthEast UK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. :-?
Logged

Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

SouthEast UK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: