Login
Back to forumReply to this topicGo to last reply

Posted By

Spektro
on 2022-10-12
03:19:16
 How to use timer 2 and timer 3 interrupts with raster interrupts?

Hello,

I'm trying to use timer 2 and timer 3 interrupts with raster interrupts but I can't get it to work. Are there any example programs on how to do it?

Posted By

mono
on 2022-10-12
04:20:15
 Re: How to use timer 2 and timer 3 interrupts with raster interrupts?

Timer 2 and 3 need to be reloaded after countdown.

Initialization:

sei
ldx CINV
ldy CINV+1
stx oldcinv
sty oldcinv+1
ldx #<userirqint
ldy #>userirqint
stx CINV
sty CINV+1

ldx #<period
ldy #>period
stx T3LO
sty T3HI
lda #<rasterline
sta RASTER
lda #[T3 | RAS | >rasterline]
sta IRQMSK
cli

Interrupt service routine:

userirqint:
lda #T3
and IRQCR
; and IRQMSK
beq ?skipt3
; ora #RAS
sta IRQCR

ldx #<period
ldy #>period
stx T3LO
sty T3HI

nop ;do something

pla
tay
pla
tax
pla
rti
?skipt3

lda #RAS
and IRQCR
; and IRQMSK
beq ?skipraster
; ora #T3
sta IRQCR

lda #<rasterline
sta RASTER
lda #[T3 | RAS | >rasterline]
sta IRQMSK

nop ;do something

?exit
pla
tay
pla
tax
pla
rti
?skipraster

jmp (oldcinv)

If T3 IRQ shouldn't disturb in RASTER routine then I'm enabling IRQ earlier and moving RASTER service prior to T3:

userirqint:
lda #T3
and IRQCR
; and IRQMSK
beq ?skipt3
; ora #RAS
sta IRQCR

ldx #<period
ldy #>period
stx T3LO
sty T3HI

cli
nop ;do something

pla
tay
pla
tax
pla
rti
?skipt3

Equates:

CINV = $314

T3LO = $FF04
T3HI = $FF05
T3 = 1 << 6
T2 = 1 << 4
T1 = 1 << 3
LP = 1 << 2
RAS = 1 << 1
IRQCR = $FF09
IRQMSK = $FF0A
RASTER = $FF0B


Posted By

Spektro
on 2022-10-12
20:53:42
 Re: How to use timer 2 and timer 3 interrupts with raster interrupts?

Thanks mono! Got it working happy



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon