Author |
Message |
rload
Member |
I've been having mysterious problems with audio interrupts since my first 4k with sound.. It seems to trigger twice or do other weird stuff. It comes and goes. What is the correct way to write an interrupt handler? What is the correct way to initialize the sound hardware so that I only get one interrupt?
Currently I save regs, clear the INTREQ bits on entering the interrupt and then do stuff and end with rte. The problematic thing is that this double interrupt bug happens only once every lightyear on my own machine. It pops up on other machines though and esp. on UAE..
Anyone have a clue?
|
dalton
Member |
Maybe you could use the amigaos interrupt-handler? I read in the masterpiece "how to code 7" that this is no significant speed loss. You might have to skip forbid/permit then though.
Btw your 4k's work alot better than your demos on my config =)
|
TheDarkCoder
Member |
@rload
we seem to have some kind of telepathic connection!! :-)
As you may remember, months ago I said I was studying carefully the problem of clearing interrupt request. I am about to finish a tutorial on the issue. In few days I'll post it.
Some detail is not yet clear, because of lack of experiments, I really need more tests on 040 CPU boards!!
|
rload
Member |
@Dalton
I've tried to use OS audio interrupts through AddIntServer, but it just crashes all the time. Only thing that seems to work is SetIntVector which is a tad more hardcore, but atleast it doesn't crash.
Looking forward to the "the Dark Coder's interrupt" tutorials :)
|
TheDarkCoder
Member |
@rload
actually the tutorial is on "clearing interrupt request", which is a tricky issue, as you'll see.
Also, you seem to have problems with audio, which is another beast by itself.
Anyway hope it'll help. It is a rather long tutorial, maybe too much :-(
|
noname
Member |
not sure if it helps, but have you tried writing INTREQ twice?
that was the whole fix for p61 to make it work on a4040 and a4060.
|
rload
Member |
yes I've tried that :)
|
TheDarkCoder
Member |
@rload
so I think my tutorial won't help. I think it's an audio related issue
|
rload
Member |
I found some AHI sources that handle audio stuff. I can look through those
|
TheDarkCoder
Member |
@rload post an example on how you use interrupt, maybe I can give a look
|
rload
Member |
lets see..
; Setup audio interrupt for channel 0
move.l 4.w, a6
moveq #AUD0,d0
lea audio_server(pc),a1
jsr _LVOSetIntVector(a6)
; Do some sound channel setup here $dff0a0 and so on
move.w $dff002,d0
bset #15,d0
move.w d0,-(sp) ; save old dmacon
move.w #$7fff, $dff096
move.w #%0000011110000000, $dff09a ; disable audio ints
move.w #%0000011110000000, $dff09c ; clear pending ints
move.w #%1100000010000000, $dff09a ; enable audio int0
move.w #%1000011110001111, $dff096 ; enable audio dma
mainloop
bra mainloop
rts
; The interrupt struct
audio_server
dc.l 0,0
dc.b NT_INTERRUPT, 0
dc.l 0
dc.l 0
dc.l interrupt_routine
; the routine
interrupt_routine
movem.l d0-a6,-(sp)
move.w #%0000000001000000, $dff09c
move.w #%0000000001000000, $dff09c ; double clear thingy
;
; some rewriting of audio channel registers here
;
movem.l (sp)+,d0-a6
rts
|
rload
Member |
do I really have to clear pending ints? anything that can be removed is good :)
|
TheDarkCoder
Member |
If the code you posted was related to any other interrupt, it would be correct.
Audio is a different beast.
One should write a tutorial about using audio on Amiga. I would like to do it, but it is not possible before July!! :-(
So, very quickly, here is an explanation in DMA-mode (non-DMA-mode is different):
1- in the init of your program, before disabeling the audio DMA do the following: kill multitasking (all interrupts), wait for 3 PAL vblank, and only then disable audio DMA
2- now, audio interrupt occurs when the DMA is ready to load a new set of data into audio state machine, NOT when the sound is finished!
so to play just once a sample:
load audio register
turn on DMA
wait for interrupt
load data for next sample (if any)
wait for interrupt
turn off DMA
Strange, isn't it? If you would like to know why it works this way, study carefully the Audio State Machine diagram in the HRM.
If anybody is interested, in a distant future I may write a tutorial... :-)
hope that helps!
|
Anonymous
Member |
|
Pezac
Member |
Hello loady! I was googling around for some info about interrupts and look what I found: a forum discussion about it that was active to date!
I had a different question but I was thinking I could just tell you how I do interrupts as it is now.. Could as well start a new thread about my original question :p
Currently I save regs, clear the INTREQ bits on entering the interrupt and then do stuff and end with rte. The problematic thing is that this double interrupt bug happens only once every lightyear on my own machine. It pops up on other machines though and esp. on UAE..
It's how I do it too, but I write to intreq at the end of the code snippet. So it's:
* save registers
* code
* write to intreq twice
* restore registers
* rte
Does this make any difference at all? Hardware ref doesn't really explain exactly how you should use interrupts.
|
Anonymous
Member |
|
noname
Member |
@rload: i have never done any audio-programming on this level so pardon me if i talk rubbish but shouldn't you quit your interrupt code with "nop" and "rte" rather than "rts" to return from the exception?
|
rload
Member |
I think there is something about exec _LVOSetIntVector system function that makes it right to write rts instead of rte.. It's executed from some system function that does the real rte I think.
|