Gast
#528692
Hallo Spezialisten Habe da ein Problem mit der ISR. Wenn ich das Programm simuliere im AVR Studio 4.12 und WIN-AVR, wird immer beim Timeroverflow zum Programmbeginn bei Main gesprungen. Die ISR wird also nicht ausgeführt. Beim Test auf dem STK500 tut sich auch nichts, außer daß die LED's leuchten. µC -> ATtiny2313 Was ist, mache ich falsch? Weiß jemand etwas? Schonmal vielen Dank #include <avr/io.h> #include <avr/interrupt.h> volatile int8_t enc_delta=0; // -128 ... 127 int main( void ) { // rotary switch connection DDRD &= ~(_BV(PD0) | _BV(PD1)); // set to input PORTD |=(_BV(PD0) | _BV(PD1)); // enable pull up TCCR0B = 0x01;//1<<CS01; //divide by 8 * 256 TIMSK = 1<<TOIE0; //enable timer interrupt DDRB = 0xFF; sei(); for(;;) // main loop PORTB = enc_delta; } ISR(TIMER0_OVF_vect) { static uint8_t last_state = 0,last_cnt = 0; uint8_t new_state; new_state=PIND & (_BV(PIND1) | _BV(PIND0)); if ((new_state^last_cnt)==(_BV(PIND1) | _BV(PIND0)) ) { if ((new_state ^ last_state)==_BV(PIND1)) enc_delta+=1; else enc_delta-=1; last_cnt=new_state; } last_state=new_state; }