Subversion Repositories FlightCtrl

Rev

Rev 749 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 749 Rev 753
Line 20... Line 20...
20
 
20
 
21
 
21
 
22
SIGNAL (SIG_OVERFLOW0)    // 9,8kHz
22
SIGNAL (SIG_OVERFLOW0)    // 9,8kHz
-
 
23
{
23
{
24
    static unsigned char cnt_1ms = 1,cnt = 0;
Line 24... Line 25...
24
    static unsigned char cnt_1ms = 1,cnt = 0;
25
        static uint8_t led_dim, led_duty;
25
    unsigned char pieper_ein = 0;
26
    unsigned char pieper_ein = 0;
26
 
27
 
27
   if(!cnt--)
28
   if(!cnt--)           // ca. 1 kHz
28
    {
29
    {
29
     cnt = 10;
30
     cnt = 10;
30
     cnt_1ms++;
31
     cnt_1ms++;
-
 
32
     cnt_1ms %= 2;
-
 
33
     if(!cnt_1ms) UpdateMotor = 1;
-
 
34
     CountMilliseconds++;
-
 
35
         
-
 
36
         // LED-Dimmung Duty-Cycle
-
 
37
         if (!led_duty--)
-
 
38
         {
-
 
39
                led_duty = 4;
31
     cnt_1ms %= 2;
40
                led_dim = Poti2 >> 2;
-
 
41
                PORTD &= ~(1<<PD4);     // J5 auf Low
-
 
42
         }       
-
 
43
     }
Line 32... Line 44...
32
     if(!cnt_1ms) UpdateMotor = 1;
44
       
33
     CountMilliseconds++;
45
        if (led_dim) led_dim--;
34
     }  
46
        else PORTD |= (1<<PD4);
35
 
47
 
Line 72... Line 84...
72
    OCR0B = 120;
84
    OCR0B = 120;
Line 73... Line 85...
73
 
85
 
74
    TCCR2A=(1<<COM2A1)|(1<<COM2A0)|3;
86
    TCCR2A=(1<<COM2A1)|(1<<COM2A0)|3;
Line 75... Line 87...
75
    TCCR2B=(0<<CS20)|(1<<CS21)|(1<<CS22);
87
    TCCR2B=(0<<CS20)|(1<<CS21)|(1<<CS22);
76
   
88
   
Line 77... Line 89...
77
//    TIMSK2 |= _BV(TOIE2);
89
        //    TIMSK2 |= _BV(TOIE2);
78
TIMSK2 |= _BV(OCIE2A);
90
        TIMSK2 |= _BV(OCIE2A);
79
 
91
 
80
    TIMSK0 |= _BV(TOIE0);
-
 
81
    OCR2A = 10;
92
    TIMSK0 |= _BV(TOIE0);
Line 82... Line 93...
82
    TCNT2 = 0;
93
    OCR2A = 10;
Line 83... Line 94...
83
   
94
    TCNT2 = 0;    
Line 150... Line 161...
150
    else
161
    else
151
    {
162
    {
152
                // disable PWM at PD7
163
                // disable PWM at PD7
153
                TCCR2A = 3;
164
                TCCR2A = 3;
154
                // set PD7 to low
165
                // set PD7 to low
155
                PORTD &= ~(1<<PORTD7);
166
                PORTD &= ~(1<<PD7);
156
    }
167
    }
157
}
168
}