Electronic – Attiny10 not triggering timer overflow interrupt while simulation (Atmel Studio 6)

atmel-studioattinyavrinterruptssimulation

I have problems simulating the timer overflow in Atmel Studio 6. The code is for an Attiny10 and looks like below. As far as I know I set all the neccessary bits to enable the counter (which works in simulation) and the interrupt (which doesnt work in simulation).

I guess it's just a stupid mistake and I need a small hint so I would really appreciate if someone could tell me what I'm doing wrong.

;======================
;   device  attiny10
;======================
;.include   tn10def.inc
;            _____________
;           /1 °         6|
;       O--|PB0        PB3|--O RESET
;          |      t10     |
;       O--|GND        VCC|--O
;          |              |
;       O--|PB1        PB2|--O
;          |______________|

;======================
; defines
;======================
.def    temp    = r16

;======================
; reset / int. vecs
;======================
.org 0x0000
    rjmp    reset           ; Reset Handler
.org 0x0004
    rjmp    TIM0_OVF        ; Timer0 Overflow Handler
.org 0x000A

;======================
; reset / setup
;======================
reset:
    in      temp,   TCCR0B          ; turn timer on
    ori     temp,   (1<<CS00)
    out     TCCR0B, temp

    in      temp,   TIMSK0          ; turn overflow interrupt on
    ori     temp,   (1<<TOIE0)
    out     TIMSK0, temp

    ldi     0xff
    out     DDRB,   temp
    ldi     0x00
    out     PORTB,  temp

    ldi     temp,   0xff
    out     TCNT0H, temp
    ldi     temp,   250
    out     TCNT0L, temp

    ldi     temp,   0xff

    sei

;======================
; main loop
;======================
main:
    rjmp    main            ; while(1);

; overflow interrupt
;====================== 
TIM0_OVF:
    com     temp
    out     PORTB,  temp
    reti

EDIT: Solved: You cant step into/over an ISR. (Thx to Golaž)

Best Answer

If you havent got a compiler error when trying to compile the exact code you posted, you have a bigger problem.

Your code is working fine (ignoring the fact you missed out the register names in your 3rd block under reset label). However I would make some changes:

;======================
;   device  attiny10
;======================
;.include   tn10def.inc
;            _____________
;           /1 °         6|
;       O--|PB0        PB3|--O RESET
;          |      t10     |
;       O--|GND        VCC|--O
;          |              |
;       O--|PB1        PB2|--O
;          |______________|

;======================
; defines
;======================
.def    temp    = r16

;======================
; reset / int. vecs
;======================
.org 0x0000
    rjmp    reset           ; Reset Handler
; Replace : .org 0x0004 with:
.org OVF0addr
    rjmp    TIM0_OVF        ; Timer0 Overflow Handler
; Replace: .org 0x000A with:
.org INT_VECTORS_SIZE ; End of vector table.

;======================
; reset / setup
;======================
reset:
    ; Initialize stack:
    ldi r16, HIGH(RAMEND)
    out SPH, r16
    ldi r16, LOW(RAMEND)
    out SPL, r16        

    in      temp,   TCCR0B          ; turn timer on
    ori     temp,   (1<<CS00)
    out     TCCR0B, temp

    in      temp,   TIMSK0          ; turn overflow interrupt on
    ori     temp,   (1<<TOIE0)
    out     TIMSK0, temp

    ; You forgot to specify the regsiter here:
    ldi     temp,   0xff
    out     DDRB,   temp
    ldi     temp,   0x00
    out     PORTB,  temp

    ldi     temp,   0xff
    out     TCNT0H, temp
    ldi     temp,   250
    out     TCNT0L, temp

    ldi     temp,   0xff

    sei

;======================
; main loop
;======================
main:
    rjmp    main            ; while(1);

; overflow interrupt
;====================== 
TIM0_OVF:
    com     temp
    out     PORTB,  temp
    reti

You can find the include files for devices and all their specifics (such as OVF0addr, INT_VECTORS_SIZE, RAMEND, ...) in:

C:\Program Files (x86)\Atmel\Atmel Toolchain\AVRAssembler\Native\2.1.1117\avrassembler\include

I am not sure what your exact goal was here, when you've setted TCNT0 registers you've only set its value for one (current) cycle, when the timer would reach its maximum value it will restart from 0.

What was your goal with TIM0_OVF ISR I am not sure.

Stack is needed for the MCU to know which address to return to after the call to subfunction or ISR have been executed.