Subversion Repositories FlightCtrl

Rev

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

Rev 871 Rev 872
Line 83... Line 83...
83
    cntKompass = 0;
83
    cntKompass = 0;
84
   }
84
   }
85
 }
85
 }
86
}
86
}
Line 87... Line -...
87
 
-
 
-
 
87
 
88
//----------------------------
88
 
89
void Timer_Init(void)
89
void Timer_Init(void)
90
{
90
{
91
    tim_main = SetDelay(10);
91
    tim_main = SetDelay(10);
92
    TCCR0B = CK8;
92
    TCCR0B = CK8;
Line 95... Line 95...
95
    OCR0B = 120;
95
    OCR0B = 120;
96
    TCNT0 = (unsigned char)-TIMER_RELOAD_VALUE;  // reload
96
    TCNT0 = (unsigned char)-TIMER_RELOAD_VALUE;  // reload
97
    //OCR1  = 0x00;
97
    //OCR1  = 0x00;
Line 98... Line 98...
98
 
98
 
99
    TCCR2A=(1<<COM2A1)|(1<<COM2A0)|3;
99
    TCCR2A=(1<<COM2A1)|(1<<COM2A0)|3;
100
//    TCCR2B=(0<<CS20)|(1<<CS21)|(1<<CS22);    // clk/256
-
 
Line 101... Line -...
101
    TCCR2B=(0<<CS20)|(0<<CS21)|(1<<CS22);      // clk/64
-
 
-
 
100
    TCCR2B=(0<<CS20)|(1<<CS21)|(1<<CS22);
102
   
101
   
Line 103... Line 102...
103
 
102
//    TIMSK2 |= _BV(TOIE2);
104
  TIMSK2 |= _BV(OCIE2A);
103
TIMSK2 |= _BV(OCIE2A);
105
 
104
 
Line 142... Line 141...
142
}
141
}
Line 143... Line 142...
143
 
142
 
144
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
143
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
145
//  Servo ansteuern
144
//  Servo ansteuern
146
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
-
 
147
SIGNAL(SIG_OVERFLOW2)
-
 
148
{
-
 
149
  PORTD |= 0x80;
-
 
150
  TCCR2A =3;
-
 
151
  TIMSK2 &= ~_BV(TOIE2);
-
 
152
}
-
 
153
 
145
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
154
SIGNAL(SIG_OUTPUT_COMPARE2A)
146
SIGNAL(SIG_OUTPUT_COMPARE2A)
155
{
-
 
156
  #define MULTIPLIER 4
-
 
157
  #define PPM_OFFSET  256  //  820us
-
 
158
  static unsigned int timer = 10 * MULTIPLIER;
-
 
159
 
-
 
160
  if(timer == 3)  
-
 
161
    {
-
 
162
     ServoValue = PPM_OFFSET;
-
 
163
         ServoValue +=  (int) Parameter_ServoNickControl * 2;
-
 
164
         
-
 
165
     if(EE_Parameter.ServoNickCompInvert & 0x01) ServoValue += ((long) (EE_Parameter.ServoNickComp * IntegralNick) / 128 )/ (512/MULTIPLIER);
-
 
166
     else ServoValue -= ((long) (EE_Parameter.ServoNickComp * IntegralNick) / 128) / (512/MULTIPLIER);
-
 
167
     
-
 
168
     if((ServoValue) < ((int)EE_Parameter.ServoNickMin*MULTIPLIER)) ServoValue = (int)EE_Parameter.ServoNickMin*MULTIPLIER;
-
 
169
     else if((ServoValue) > ((int)EE_Parameter.ServoNickMax*MULTIPLIER)) ServoValue = (int)EE_Parameter.ServoNickMax*MULTIPLIER;
-
 
170
     
-
 
171
ServoValue = 500;
-
 
172
         DebugOut.Analog[23] = ServoValue;
-
 
173
         
-
 
174
         TCCR2A=(1<<COM2A1)|(0<<COM2A0)|3;  
-
 
175
         OCR2A = ServoValue % 256;
-
 
176
         TIMSK2 |= _BV(TOIE2);
-
 
177
    }
-
 
178
  else if (timer < 3)
-
 
179
    {
-
 
180
         
-
 
181
          if (ServoValue > 255)
-
 
182
          { PORTD |= 0x80;
-
 
183
                TCCR2A =3;
-
 
184
                ServoValue -= 255;
-
 
185
          }
-
 
186
          else
-
 
187
      {
-
 
188
            TCCR2A =3;
-
 
189
        PORTD&=~0x80;
-
 
190
                OCR2A = 0xff;
-
 
191
      }
-
 
192
         
-
 
193
          if (timer == 0) timer = (int) EE_Parameter.ServoNickRefresh * MULTIPLIER;
-
 
194
    }
-
 
195
 
-
 
196
 
-
 
197
  timer--;
-
 
198
       
147
{
Line 199... Line 148...
199
/*  static unsigned char timer = 10;
148
  static unsigned char timer = 10;
200
 
149
 
201
  if(!timer--)  
150
  if(!timer--)  
202
    {
151
    {
Line 213... Line 162...
213
    }
162
    }
214
    else
163
    else
215
    {
164
    {
216
     TCCR2A =3;
165
     TCCR2A =3;
217
     PORTD&=~0x80;
166
     PORTD&=~0x80;
218
    } */
167
    }
219
       
-
 
220
}
168
}