X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=bike-lights.git;a=blobdiff_plain;f=pwm.c;h=0c4f3d081a5b78ddbc9f2493255a17b0da6496bf;hp=af4e4fab2d55391f368d344b3a06f489bceb73a3;hb=2f02dcff5103d6466523678a8fafb385530406d2;hpb=2c9b86851ec5b510c0508557441ff83cc87ec263 diff --git a/pwm.c b/pwm.c index af4e4fa..0c4f3d0 100644 --- a/pwm.c +++ b/pwm.c @@ -7,7 +7,7 @@ void init_pwm() { /* Async clock */ - PLLCSR = _BV(LSM) | _BV(PLLE); + PLLCSR = _BV(PLLE); /* Synchronize to the phase lock */ _delay_ms(1); @@ -20,8 +20,10 @@ void init_pwm() TCCR1B = _BV(7) // PWM1X: PWM inversion mode | _BV(CS10) // no clock prescaling ; + TC1H = 0x01; OCR1C = 0xFF; // TOP value + TC1H = 0x00; OCR1D = OCR1B = OCR1A = 0; // initial stride is 0 DDRB &= ~(_BV( PB1 ) | _BV( PB3 ) | _BV( PB5 )); // tristate it @@ -48,6 +50,7 @@ void pwm_off(unsigned char n) void pwm_set(unsigned char n, unsigned char stride) { + TC1H = 0x00; switch (n) { case 0: OCR1A = stride; break; case 1: OCR1B = stride; break;