Author |
Message |
BobTheDog
Joined: Feb 28, 2005 Posts: 4044 Location: England
Audio files: 32
G2 patch files: 15
|
Posted: Mon Jun 30, 2008 1:53 pm Post subject:
DMA buffer ready interrupt? |
|
|
Well here is the first technical question for the Chameleon masters:
Using DMA to fill a buffer from the ADC is it possible to have an interrupt fired when this buffer is full?
Cheers
Andy |
|
Back to top
|
|
|
DrJustice
Joined: Sep 13, 2004 Posts: 2114 Location: Morokulien
Audio files: 4
|
Posted: Mon Jun 30, 2008 2:32 pm Post subject:
|
|
|
Yes it is.
The DSP56303 User Manual (DSP56303UM.pdf), page 4-33 documents the use of the DIE bit in the DMA channel Control Registers (DCRn). Add your interrupt handler to the vector table, set DIE and you should be good to go.
BTW, the 'dspthru' example project shows the use of serial port interrupts to drive the audio IO - useful in this case to illustrate the use of interrupts.
DJ
-- |
|
Back to top
|
|
|
DrJustice
Joined: Sep 13, 2004 Posts: 2114 Location: Morokulien
Audio files: 4
|
Posted: Mon Jun 30, 2008 2:49 pm Post subject:
|
|
|
...so a few lines like the following, e.g. for DMA channel 0:
Code: |
; Set up the interrupt vector
org P:VecDMA0
JSR >my_DMA0_interrupt
; ... ... ...
; Set up DMA and enable the DMA interrupt
; ... ... ...
BSET #DCR_DIE,X:<<DCR0
; ... ... ...
my_DMA0_interrupt:
; Do stuff!
; ... ... ... ...
RTI
|
DJ
-- |
|
Back to top
|
|
|
BobTheDog
Joined: Feb 28, 2005 Posts: 4044 Location: England
Audio files: 32
G2 patch files: 15
|
Posted: Mon Jun 30, 2008 3:39 pm Post subject:
|
|
|
Hi Are,
Thanks for the info.
I will have a read of that section of the document tomorrow morning over coffee.
I have looked through the polling, interrupt and DMA code in the dspthru project, this is what made me think about triggering an interrupt from the DMA.
Is this usually how you do this or is there a "better" way?
Cheers
Andy |
|
Back to top
|
|
|
DrJustice
Joined: Sep 13, 2004 Posts: 2114 Location: Morokulien
Audio files: 4
|
Posted: Mon Jun 30, 2008 4:16 pm Post subject:
|
|
|
BobTheDog wrote: | Is this usually how you do this or is there a "better" way? |
Well... there are several ways, if nothing else.
The examples are using the the audio dma driver ('audio_ama.asm' file) run the DMA without interrupts, and the audio processing is done in a loop in the foreground. At the end of each iteration ChangeActiveBufferDMA is called and loops until the current DMA transfer is done, then it swaps the buffer pointers (...as you have made out, just filling in for other readers).
The host communication is interrupt driven in (most of?) the Soundart examples, but it could have been run in the foreground too.
Then there's the serial port interrupt. It's slightly less efficient and flexible (context changes, hard realtime), but can be used for the quickest response time. The audio processing could then run in that interrupt handler. Host communication could be run in the foreground.
And, you can use the DMA interrupt, as you are onto, to swap buffer pointers, emit signals and/or run your processing.
So, one can mix and match depending on priorities and convenience. Using DMA (with or without interrupts) is probably a good idea for most applications. Use a very short buffer for low latency or a longer buffer if you need to allow for spikes in DSP usage or efficient block processing. My best advice would be to try it all out and see what you're comfortable with and what suits your applications and your style.
DJ
-- |
|
Back to top
|
|
|
|