Übungen - AVR - 2024-11-03, Timer Interrupt

.include "m8def.inc"

.org 0x000
rjmp RESTART
.org
rjmp TimerIntervall

RESTART:

ldi r16, HIGH (RAMEND)
out SPH, r16
ldi r16, LOW (RAMEND)
out SPH, r16

ldi r16, 0xff
out DDRB, r16
ldi r16, 0x00
com r16
out PORTB, r16
com r16

ldi r17, 0x0f

sei
end: rjmp end

TimerIntervall:
and r17, 0b00001111
dec r17
brne goon
inc r16
com r16
out PORTB, r16
com r16
goon:
reti
So muss das ergänzt werden
.include "m8def.inc"

.org 0x000
rjmp RESTART
.org OVF0addr
rjmp TimerIntervall

RESTART:

ldi r16, HIGH (RAMEND)
out SPH, r16
ldi r16, LOW (RAMEND)
out SPH, r16

ldi r16, 0xff
out DDRB, r16
ldi r16, 0x00
com r16
out PORTB, r16
com r16

ldi r17, 0x0f

        ldi     r16, (1<<CS00) | (1<<CS02)
        out     TCCR0, r16

        ldi     r16, (1<<TOIE0)
        out     TIMSK, r16

sei
end: rjmp end

TimerIntervall:
andi r17, 0b00001111
dec r17
brne goon
inc r16
com r16
out PORTB, r16
com r16
goon:
reti
Schneller:
.include "m8def.inc"

.org 0x000
rjmp RESTART
.org OVF0addr
rjmp TimerIntervall

RESTART:

ldi r16, HIGH (RAMEND)
out SPH, r16
ldi r16, LOW (RAMEND)
out SPH, r16

ldi r16, 0xff
out DDRB, r16
ldi r16, 0x00
com r16
out PORTB, r16
com r16

ldi r17, 0x0f

        ldi     r16, (1<<CS00) | (1<<CS02)
        out     TCCR0, r16

        ldi     r16, (1<<TOIE0)
        out     TIMSK, r16

sei
end: rjmp end

TimerIntervall:
andi r17, 0b00000011
dec r17
brne goon
inc r16
com r16
out PORTB, r16
com r16
goon:
reti
Versuch auf das Timer Register zu zu greifen
.include "m8def.inc"

.org 0x000
rjmp RESTART
.org OVF0addr
rjmp TimerIntervall

RESTART:

ldi r16, HIGH (RAMEND)
out SPH, r16
ldi r16, LOW (RAMEND)
out SPH, r16

ldi r16, 0xff
out DDRB, r16
ldi r16, 0x00
com r16
out PORTB, r16
com r16

ldi r17, 0x0f
        ldi     r16, 0b00011111
        out     TCNT0, r16

        ldi     r16, (1<<CS00) | (1<<CS02)
        out     TCCR0, r16

        ldi     r16, (1<<TOIE0)
        out     TIMSK, r16

sei
end: rjmp end

TimerIntervall:
andi r17, 0b00000011
dec r17
brne goon
inc r16
com r16
out PORTB, r16
com r16
goon:
reti