Unexpected IRQ behaviour on a VIC-20

From: Ruud_at_Baltissen.org
Date: Fri, 28 Jul 2017 09:04:43 +0200
Message-ID: <597AE20B.8514.8E5CDEE5@Ruud.Baltissen.org>
Hallo allemaal,


I wanted to test the restore key of a VIC-20 so I connected pin PB7 
of UBA1 (VIA2 in the program) with the CA1 input of same IC. To have 
another mean to test things beside the monitor, I connected LEDs to 
the userport, VIA1.

The Program:


; Test negative edge on CA1
	lda	#$26
	sta	ControlCode
	sta	VIA1_DRB		; light LEDs according code

	lda	#0
	sta	VIA2_DRB		; negative edge on CA1

	nop
	nop

 lda #$77
 sta VIA1_DRB
Ly: jmp Ly


Original IRQ routine:

IRQroutine:  
	pla
	pla
	pla
NMIroutine:  
	lda	#$33
	sta	IrqNmiCheck

	sei				; disable interrupts

	rti


Routine with debug instructions and 'repair':

IRQroutine:  
	pla
	pla
	pla
NMIroutine:  
 lda #$AA
 sta VIA1_DRB
;	lda	VIA1_DRA
;	lda	VIA2_DRA		; dummy reads for clearing int. register

	lda	#$33
	sta	IrqNmiCheck

 nop
 nop
 nop
 nop
 nop
 nop
 lda #$55
 sta VIA1_DRB

	sei				; disable interrupts

	rti


The problem I encountered was that the computer just stopped. I 
first thought that it some where else in the program but I soon 
found out that it never reached the 'lda #$77' part because the LEDs 
kept on showing $26. So I added the 'lda #$AA' part to the IRQ 
routine. That proofed that the routine was executed.

To make a long story short:
- by adding the 'lda #$55' part I found out that the routine was 
looping because all LEDs lighted up.
- by adding 'lda	VIA2_DRA' I found out that the looping stopped and 
that I got $77 on my LEDs.

I understand that the looping is caused by not clearing the 
interrupt. But the idea was that 'sei' should have prevented that.

My question: why didn't 'sei' prevent the looping? 


PS: I realised that I have to change the code anyway because 'sei' 
won't work with NMI.


--
   
Kind regards / Met vriendelijke groet, Ruud Baltissen
www.Baltissen.org







       Message was sent through the cbm-hackers mailing list
Received on 2017-07-28 08:00:03

Archive generated by hypermail 2.2.0.