Rev 849 | Rev 872 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 849 | Rev 871 | ||
---|---|---|---|
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 100... | Line -... | ||
100 | TCCR2B=(0<<CS20)|(1<<CS21)|(1<<CS22); |
- | |
- | 101 | TCCR2B=(0<<CS20)|(0<<CS21)|(1<<CS22); // clk/64 |
|
101 | 102 | ||
Line 102... | Line 103... | ||
102 | // TIMSK2 |= _BV(TOIE2); |
103 | |
103 | TIMSK2 |= _BV(OCIE2A); |
104 | TIMSK2 |= _BV(OCIE2A); |
104 | 105 | ||
Line 141... | Line 142... | ||
141 | } |
142 | } |
Line 142... | Line 143... | ||
142 | 143 | ||
143 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
144 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
144 | // Servo ansteuern |
145 | // Servo ansteuern |
- | 146 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 147 | SIGNAL(SIG_OVERFLOW2) |
|
- | 148 | { |
|
- | 149 | PORTD |= 0x80; |
|
- | 150 | TCCR2A =3; |
|
- | 151 | TIMSK2 &= ~_BV(TOIE2); |
|
- | 152 | } |
|
145 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
153 | |
146 | SIGNAL(SIG_OUTPUT_COMPARE2A) |
154 | 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--; |
|
147 | { |
198 | |
Line 148... | Line 199... | ||
148 | static unsigned char timer = 10; |
199 | /* static unsigned char timer = 10; |
149 | 200 | |
|
150 | if(!timer--) |
201 | if(!timer--) |
151 | { |
202 | { |
Line 162... | Line 213... | ||
162 | } |
213 | } |
163 | else |
214 | else |
164 | { |
215 | { |
165 | TCCR2A =3; |
216 | TCCR2A =3; |
166 | PORTD&=~0x80; |
217 | PORTD&=~0x80; |
167 | } |
218 | } */ |
- | 219 | ||
168 | } |
220 | } |