Das Programm soll PB1 bei Timer1-Capture oder INT1 toggeln.
Die Interrupts werden jedoch nicht angesprungen.
Im AVR Studio Debugger sehe ich, dass bei Interrupt lediglich ein Reset durchgeführt wird(die main-Funktion erneut durchlaufen wird).
Ich komme nicht dahinter, woran es liegt.
Weder das SIGNAL noch das ISR-Makro funktionieren.
Hier der Code:
Code:#include <avr/io.h> #include <avr/interrupt.h> #include <avr/delay.h> volatile uint16_t timer_save; int main() { DDRB = 0 | _BV(1); PORTB = 255; //Pullup&LED an // PORTB ^= _BV(1); //toggle PB1 // TCCR1B ^= _BV(ICES1); //Flankenrichtung toggeln TCCR1B |= _BV(ICNC1); //Input Capture Noise Canceler an TCCR1B |= _BV(CS11) |_BV(CS10); //CLCK-SRC = CLCK/64 TIMSK |= _BV(5); //Timer Interrupt Capture enable TCCR1B &= ~(_BV(ICES1)); //bei fallende Flanke GICR |= _BV(7); //INT1 an MCUCR |= _BV(ISC11); //falling edge SREG |= _BV(7); //global interrupt enable while(1); } ISR(TIMER1_CAPT_vect) { cli(); if(TCCR1B&_BV(ICES1)) { TCCR1B &= ~(_BV(ICES1)); //Timer1-Capture an fallender Flanke } else { TCCR1B |= _BV(ICES1); } PORTB ^= _BV(1); //toggle PB1 timer_save= ICR1L; //LoByte sichern _delay_ms(10); //debounce sei(); } SIGNAL(SIG_INTERRUPT1) { cli(); PORTB ^= _BV(1); //toggeln sei(); }
Lesezeichen