Gast
#490883
Hallo,
ich probiere ein servo(Hitec 40Hz) anzuschteuern, ohne erfolg, mit
volgende code:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
uint16_t ImpulsZaehler1=0;
uint8_t a=64; //mitte 1,6ms
// Timer interrupt 4000Hz (4Mhz Quarz)
void Teimer0_ON(void){
TCCR0B |= (1<<CS00);
OCR0B = 156;
TIMSK |= (1<<TOIE0);
sei();
}
ISR(TIMER0_OVF_vect){
if (ImpulsZaehler1<1000){
ImpulsZaehler1++;
}
}
int main(void){
cli();
Teimer0_ON();
while(1){
if ( ImpulsZaehler1<a ) {
PORTB = PINB ^ ( 1 << PB1 );
}
else{
PORTB &= ~(PINB ^ ( 1 << PB1) );
}
if(ImpulsZaehler1==1000){
ImpulsZaehler1=0;
}
if ( PINA & (1<<PA1) ) {
a=42; 1,05ms min
}
}
}
Kann mir jemand sagen wieso das nicht hin haut?