18 July 2021, 17:15 | #1 |
Newbie Amiga programmer
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. |
18 July 2021, 17:50 | #2 |
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 |
18 July 2021, 18:24 | #3 |
Newbie Amiga programmer
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. |
18 July 2021, 19:07 | #4 |
Defendit numerus
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. Last edited by ross; 18 July 2021 at 19:19. |
18 July 2021, 19:14 | #5 |
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 |
18 July 2021, 19:25 | #6 |
Newbie Amiga programmer
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. |
19 July 2021, 12:08 | #7 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
|
19 July 2021, 15:04 | #8 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
And add to this that usually CIA registers are with separate functions for reading and writing..
|
20 July 2021, 15:48 | #9 |
Newbie Amiga programmer
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
INTREQRwith INTREQ, hence the swapping of move.w #$2000,$dff09cwith move.w #$2000,$dff01e. (I was aware of them being unidirectional.) Thanks for the correction guys. |
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 |
|
|