English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 18 July 2021, 17:15   #1
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
Timer instantly causes interrupt

I have this code:
Code:
		move.b		#$0c,$BFDE00		; Stop Timer A.
		move.b		#$7f,$BFDD00		; Disable all CIA interrupts.
		move.w		#$2000,$DFF09A		; Disable L6 interrupts.
		move.l		#$7ff00,$78		; L6 interrupt now points to the copied code.
		move.w		#$a000,$DFF09A		; Enable L6 interrupts.
		move.b		#$81,$BFDD00		; Enable Timer A interrupt.
		move.b		#$00,$BFD400
		move.b		#$60,$BFD500		; Load $6000 into Timer A and start.
It does not wait until underflow, it causes an interrupt instantly. What i am doing wrong?
TCH is offline  
Old 18 July 2021, 17:50   #2
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
1. set $dff09a to $2000 first (what if L6 int occurs between $bfdd00/e00 and $dff09a? doesn't necessarily have to timer a), this way you also don't have to stop the timer
2. clear L6 bit in INTREQ ($dff09c) before you re-enable interrupts in case it's been set already
3. you start the timer a by writing $11 (continuous) or $19 (one-shot) to $bfde00, not by setting the initial count, at the end
a/b is offline  
Old 18 July 2021, 18:24   #3
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
1., 2.: Okay, i did so and this way it never fires.
3. Manual says otherwise, but okay, i did so and this way it instantly fires again.
Code:
		move.w		#$2000,$DFF09A		; Disable L6 interrupts.
		move.b		#$7f,$BFDD00		; Disable all CIA interrupts.
		move.l		#$7ff00,$78		; L6 interrupt now points to the copied code.
		move.w		#$2000,$dff01e		; Clear L6 interrupt request.
		move.w		#$a000,$DFF09A		; Enable L6 interrupts.
		move.b		#$81,$BFDD00		; Enable Timer A interrupt.
		move.b		#$00,$BFD400
		move.b		#$60,$BFD500		; Load $6000 into Timer A.
		move.b		#$19,$BFDE00		; Start Timer A.
TCH is offline  
Old 18 July 2021, 19:07   #4
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
This is the proper way:
Code:
		move.w		#$2000,$DFF09A		; Disable L6 interrupts.
		move.b		#$7f,$BFDD00		; Disable all CIA interrupts.
		move.b		#8,$BFDE00		; Stop timer, One-Shot mode
		tst.b		$BFDD00			; Clear pending
		move.w		#$2000,$dff09C		; Clear L6 interrupt request.
		move.l		#$7ff00,$78		; L6 interrupt now points to the copied code.
		move.b		#$81,$BFDD00		; Enable Timer A interrupt.
		move.b		#$00,$BFD400
		move.b		#$60,$BFD500		; Start Timer A.
		move.w		#$a000,$DFF09A		; Enable L6 interrupts.
EDIT: stop timer in the right position

Last edited by ross; 18 July 2021 at 19:19.
ross is offline  
Old 18 July 2021, 19:14   #5
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
$dff01e is INTREQR (read only), to write a value you have to use $dff09c.

This works for me (assumes VBR=0):
Code:
	lea	($bfd000),a0
	lea	($dff000),a6
	move.l	($78).w,d0

	move.w	#$2000,($09a,a6)	; int6 off
	move.b	#$7f,($d00,a0)		; all ints off
	move.b	#$10,($e00,a0)		; stop timer a
	move.l	#int6,($78).w
	move.w	#$2000,($09c,a6)	; clear int6 req
	move.w	#$e000,($09a,a6)	; master+int6 on
	move.b	#$81,($d00,a0)		; timer a int on
	move.b	#$00,($400,a0)		; timer a low
	move.b	#$60,($500,a0)		; timer a high
	move.b	#$11,($e00,a0)		; timer a: force, continuous, start

Wait	btst	#6,($e001-$d000,a0)	; wait lmb
	bne.b	Wait

	move.b	#$10,($e00,a0)		; stop timer a
	move.l	d0,($78).w
	rts

int6	tst.b	($bfdd00)		; ack timer a int
	move.w	#$2000,($dff09c)	; clear int6 req
	move.w	#$fff,($dff180)
	move.w	#$000,($dff180)
	rte
a/b is offline  
Old 18 July 2021, 19:25   #6
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
@ross: Thank you, that worked.

@a/b: Thanks, but in the meantime it has been solved.
TCH is offline  
Old 19 July 2021, 12:08   #7
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Quote:
Originally Posted by TCH View Post
@a/b: Thanks, but in the meantime it has been solved.
Maybe, but it's still important that you understand what a/b tried to tell you.
All the custom chip registers are read- or write-only, and you need to distinguish between them
hooverphonique is offline  
Old 19 July 2021, 15:04   #8
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by hooverphonique View Post
Maybe, but it's still important that you understand what a/b tried to tell you.
All the custom chip registers are read- or write-only, and you need to distinguish between them
And add to this that usually CIA registers are with separate functions for reading and writing..
ross is offline  
Old 20 July 2021, 15:48   #9
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
Ah, i see now, sorry. The code was partly copied and i must have confused
INTREQR
with
INTREQ
, hence the swapping of
move.w #$2000,$dff09c
with
move.w #$2000,$dff01e
. (I was aware of them being unidirectional.) Thanks for the correction guys.
TCH is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitter interrupt during VERTB interrupt phx Coders. Asm / Hardware 38 01 October 2021 19:54
FS-UAE (OSX) dies instantly when listing mapped directory idrougge support.FS-UAE 5 08 January 2017 03:03
example of a CIA timer interrupt in assembler using cia.resource Apollo Coders. Asm / Hardware 3 05 July 2013 08:40
Aladdin AGA crashes instantly on clean ADFs MethodGit support.Games 13 31 October 2010 12:41
CIA timer interrupt handler called twice during mod playback absence Coders. General 5 16 March 2009 18:55

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 22:24.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10908 seconds with 13 queries