diff --git a/gg.c b/gg.c new file mode 100644 index 0000000..eeccc80 --- /dev/null +++ b/gg.c @@ -0,0 +1,10 @@ + +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 */ +}