]> www.fi.muni.cz Git - bike-lights.git/blobdiff - pwm.c
pwm clock highspeed mode
[bike-lights.git] / pwm.c
diff --git a/pwm.c b/pwm.c
index af4e4fab2d55391f368d344b3a06f489bceb73a3..0c4f3d081a5b78ddbc9f2493255a17b0da6496bf 100644 (file)
--- 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;