# ATTiny 841 PWM at 450kHz

I have managed to output 500kHz PWM at 50% duty cycle on PA2 TOCC1 of ATTiny841.

DDRA = (1 << PA2);//PA2 pin as an output
TOCPMSA0 = (1 << TOCC1S0);//TOCC1 linkage
TOCPMCOE = (1 << TOCC1OE);//Enable PWM
TCCR1A = (1 << COM1A1) | (1 << WGM11);//Fast PWM 1110
TCCR1B = (1 << CS10) | (1 << WGM12) | (1 << WGM13);//Fast PWM 1110
ICR1 = 1;//Not sure how clock is calculated but this gives me 500kHz on scope


I would like now to generate a 450kHz PWM on that same pin. 444.44kHz = 8MHz/18 would be acceptable. How can I do that?

The datasheet of ATTiny 841 is available here: http://www.atmel.com/Images/Atmel-8495-8-bit-AVR-Microcontrollers-ATtiny441-ATtiny841_Datasheet.pdf

• A link to the datasheet and comments in the code what each line is supposed to do would help. Jul 12 '15 at 6:16
• Done with edits in the code and datasheet link Jul 12 '15 at 7:04