I downloaded AS5 and started new Tiny45 project with default settings. Now i have test following example external interrupt service routine code in AS5 simulator.
#include#include int main(void) { DDRB=0x01; // Port B init INPUTs, except pin0 PORTB=0xfe; // output low, pin0 MCUCR |= (1<<ISC01); //The falling edge of //INT0 generates an interrupt. GIMSK |= (1<<INT0); //Ext Int Enabled sei(); /* enable global interrupts */ while(1) { //TODO:: Please write your application code asm("nop"); } } ISR( INT0_vect ) { PORTB ^= (1<<PB0); //flip output pin0 }
When interrupt is triggered, service routine is executed twice. Interrupt flag in GIFR is not cleared and interrupt starts over again.
Also interrupt is triggered in rising edge???
If I try like this
ISR( INT0_vect ) { GIFR &= ~(1<<INTF0);// clear bit 6, Ext. Int. Flag PORTB ^= (1<<PB0); //flip output pin0 }
So what happens? -bit 5, Pin Change interrupt Flag (PCIF) is cleared.
Still, this code seems to work fine in AS4 simulator.