You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
346 B

void timer_init(void)
{
ICR1 = (1 << 11) - 1;/* 11 bit pwm */
OCR1A = 0;
TCCR1A = (1 << COM1A1) | (1 << CS10) | (1 << WGM11);/* fast pwm, non inverted, top in ICR1 */
TCCR1B = (1 << WGM13) | (1 << WGM12) | (1 << CS10);/* fast pwm, top in ICR1, */
DDRD |= (1 << PD5);/* set pwm pin as output */
TIMSK = 1 << TOIE1;/* interrupt at top */
}