When simulating my ATTiny13 application in AVR Studio7 (latest version 7.0.2594, no stimuli file), XINT0 does not respond as I would expect:
In MCUCR I set ISC01|ISC00 to 0x02 because I want to trigger on the falling edge of XINT0.
When manipulating PINB1 manually, after ending up at a breakpoint, the simulator ALWAYS jumps into the ISR,regardless the change: rising as well as falling edge. Funny enough, the flag in GIFR is never set.
Clarification: in Tools / Options / Tools / Tool settings 'Mask interrupts while stepping' is set to false.
To reduce complexity, I stripped my code to the absolute minimum:
;------------------------------------------------------
;register definitions
;------------------------------------------------------
.def TmpReg = r16
.def Flags_Reg = r21 ;
;------------------------------------------------------
;constants
;------------------------------------------------------
.equ FLAG_KeyPressed = 1
;------------------------------------------------------
;interrupt vectors
;------------------------------------------------------
.org 0x0000 rjmp RESET ;Reset
.org 0x0001 rjmp ExtInt0 ;ISR for ext int0
;------------------------------------------------------
;Init
;------------------------------------------------------
RESET: ldi TmpReg, RAMEND ;Stack
out SPL, TmpReg
;----------------------------------------------
;----------------------------------------------
;prepare port B
;----------------------------------------------
ldi TmpReg, (1<<PB2)|(1<<PB3)|(1<<PB4)|(1<<PB5)
out ddrb, TmpReg ;set PortB bit 0 and 1 as input, PortB bit 2 to 5 as output
ldi TmpReg, 0x1f ; enable internal pullup for inputs and set 'Enable' for outputs
out PortB,TmpReg ;and transfer to the output
;----------------------------------------------
;ExtInt0 init
;----------------------------------------------
ldi TmpReg,0x02
out MCUCR,TmpReg ; enable falling edge int at ExtInt0
ldi TmpReg,0x40
out GIMSK,TmpReg
sei ; enable interrupts
; Initialise register values
ldi Flags_Reg, 0 ; reset
;------------------------------------------------------
; Main
;------------------------------------------------------
NoPush: sbrs Flags_Reg, FLAG_KeyPressed ; idle here as long as key not pressed / flag not set,
; FLAG_KeyPressed in FlagsReg is set by ISR KeyPressed (Ext Int0)
rjmp NoPush ; otherwise, key has been pressed
cbr Flags_Reg, 0x02 ; reset FLAG_KeyPressed
rjmp NoPush ; keep running in idle loop
;------------------------------------------------------
;end main loop
;------------------------------------------------------
;------------------------------------------------------
;ExtInt0 Interrupt: key is pressed
;------------------------------------------------------
ExtInt0:
ori Flags_Reg, 0x20 ; set flag for key pressed
reti
As with my previous, similar request, I tried the same in the simulator of the antique AVR studio version 4 - everything works fine here ;-)
Thanks for your help! And - btw - happy new year!