X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=tinyboard.git;a=blobdiff_plain;f=projects%2Fstep-up%2Fpwm.c;h=b93a4fab8502039d73d811c69b96592725c5bad5;hp=42ed777357eba68b6d8853e28c92891bd5298e06;hb=ccfee4572d781e2007f36ac30f1c80a7ef43e9ef;hpb=e6421ff2a4cecb87d997afff76dddc3eb1ba936a diff --git a/projects/step-up/pwm.c b/projects/step-up/pwm.c index 42ed777..b93a4fa 100644 --- a/projects/step-up/pwm.c +++ b/projects/step-up/pwm.c @@ -11,7 +11,7 @@ * Counts from 0 to 0xFF, without OCR1C compare. */ -static unsigned char pwm_enabled; +volatile unsigned char pwm_enabled; static void inline enable_pll() { @@ -57,6 +57,7 @@ void pwm_off() DDRB &= ~_BV(PB4); PLLCSR &= ~(_BV(PLLE) | _BV(PCKE)); + power_timer1_disable(); pwm_enabled = 0; } @@ -65,6 +66,7 @@ void pwm_set(uint8_t stride) OCR1B = stride; if (!pwm_enabled) { + power_timer1_enable(); enable_pll(); DDRB |= _BV(PB4); pwm_enabled = 1;