diff --git a/Firmware/timer02.c b/Firmware/timer02.c index 113c7246..8309f940 100644 --- a/Firmware/timer02.c +++ b/Firmware/timer02.c @@ -11,11 +11,19 @@ uint8_t timer02_pwm0 = 0; - void timer02_set_pwm0(uint8_t pwm0) { - TCCR0A |= (2 << COM0B0); //switch OC0B to OCR mode - OCR0B = (uint16_t)OCR0A * pwm0 / 255; + if (timer02_pwm0 == pwm0) return; + if (pwm0) + { + TCCR0A |= (2 << COM0B0); + OCR0B = pwm0 - 1; + } + else + { + TCCR0A &= ~(2 << COM0B0); + OCR0B = 0; + } timer02_pwm0 = pwm0; } @@ -31,12 +39,13 @@ void timer02_init(void) TIMSK0 &= ~(1<