Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 871 → Rev 872

/trunk/timer0.c
85,7 → 85,7
}
}
 
//----------------------------
 
void Timer_Init(void)
{
tim_main = SetDelay(10);
97,11 → 97,10
//OCR1 = 0x00;
 
TCCR2A=(1<<COM2A1)|(1<<COM2A0)|3;
// TCCR2B=(0<<CS20)|(1<<CS21)|(1<<CS22); // clk/256
TCCR2B=(0<<CS20)|(0<<CS21)|(1<<CS22); // clk/64
TCCR2B=(0<<CS20)|(1<<CS21)|(1<<CS22);
TIMSK2 |= _BV(OCIE2A);
// TIMSK2 |= _BV(TOIE2);
TIMSK2 |= _BV(OCIE2A);
 
TIMSK0 |= _BV(TOIE0);
OCR2A = 10;
144,60 → 143,10
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Servo ansteuern
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SIGNAL(SIG_OVERFLOW2)
{
PORTD |= 0x80;
TCCR2A =3;
TIMSK2 &= ~_BV(TOIE2);
}
 
SIGNAL(SIG_OUTPUT_COMPARE2A)
{
#define MULTIPLIER 4
#define PPM_OFFSET 256 // 820us
static unsigned int timer = 10 * MULTIPLIER;
static unsigned char timer = 10;
if(timer == 3)
{
ServoValue = PPM_OFFSET;
ServoValue += (int) Parameter_ServoNickControl * 2;
if(EE_Parameter.ServoNickCompInvert & 0x01) ServoValue += ((long) (EE_Parameter.ServoNickComp * IntegralNick) / 128 )/ (512/MULTIPLIER);
else ServoValue -= ((long) (EE_Parameter.ServoNickComp * IntegralNick) / 128) / (512/MULTIPLIER);
if((ServoValue) < ((int)EE_Parameter.ServoNickMin*MULTIPLIER)) ServoValue = (int)EE_Parameter.ServoNickMin*MULTIPLIER;
else if((ServoValue) > ((int)EE_Parameter.ServoNickMax*MULTIPLIER)) ServoValue = (int)EE_Parameter.ServoNickMax*MULTIPLIER;
ServoValue = 500;
DebugOut.Analog[23] = ServoValue;
TCCR2A=(1<<COM2A1)|(0<<COM2A0)|3;
OCR2A = ServoValue % 256;
TIMSK2 |= _BV(TOIE2);
}
else if (timer < 3)
{
if (ServoValue > 255)
{ PORTD |= 0x80;
TCCR2A =3;
ServoValue -= 255;
}
else
{
TCCR2A =3;
PORTD&=~0x80;
OCR2A = 0xff;
}
if (timer == 0) timer = (int) EE_Parameter.ServoNickRefresh * MULTIPLIER;
}
 
timer--;
/* static unsigned char timer = 10;
if(!timer--)
{
TCCR2A=(1<<COM2A1)|(0<<COM2A0)|3;
215,6 → 164,5
{
TCCR2A =3;
PORTD&=~0x80;
} */
}
}