#13137 - poslundc - Sat Dec 06, 2003 2:46 am
At DekuTree64's suggestion, I tried converting my sound player so that instead of using an interrupt every on a 16 KHz cycle I would use DMA1 instead.
The trouble is that DMA1 sits there glaring at me and does absolutely nothing. I have checked a dozen other demos and as far as I can tell I am doing exactly the same thing they are doing. I have checked the memory map and the DMA1 source, destination and control registers all have the correct values, and my EWRAM buffer has data in it. My timers and interrupts are working (this program works when I switch it back to a timer-based system).
This has me absolutely stumped. I don't know what I could possibly be doing wrong; the DMA just won't seem to activate.
Here's the code, with some pseudocode for brevity's sake:
It's so bloody straightforward I can't figure out what could possibly be wrong with it. Like I said, it works fine with the timers, the memory map displays the correct values for the DMA registers (although the source never increments), and there is data in the buffer.
Anyone feel up to fielding this one?
Thanks,
Dan.
The trouble is that DMA1 sits there glaring at me and does absolutely nothing. I have checked a dozen other demos and as far as I can tell I am doing exactly the same thing they are doing. I have checked the memory map and the DMA1 source, destination and control registers all have the correct values, and my EWRAM buffer has data in it. My timers and interrupts are working (this program works when I switch it back to a timer-based system).
This has me absolutely stumped. I don't know what I could possibly be doing wrong; the DMA just won't seem to activate.
Here's the code, with some pseudocode for brevity's sake:
Code: |
char *sndBuffA = (char *)EWRAM;
char *sndBuffB = (char *)(EWRAM + 256); char *buffActive; void IntTIMER1(void) { unsigned short i; char *buff; i = 256; buff = buffActive; buffActive = (buffActive == sndBuffA) ? sndBuffB : sndBuffA; REG_DMA1SAD = (unsigned int)buffActive; if (channels[0].sampleClock) // just dump in channel 0 for now while (i--) // dump values into buffer REG_IF = INT_TIMER1; } void AgbMain(void) { REG_SOUNDCNT_H = 0x0B0F; REG_SOUNDCNT_X = 0x0080; InitInterrupts(); PlaySample(0, (ModSample *)(&(testMod[4])), n); buffActive = sndBuffA; REG_DMA1SAD = (unsigned int)buffActive; // Source: sound buffer REG_DMA1DAD = 0x040000A0; // Dest: sound FIFO REG_DMA1CNT_H = 0xB600; REG_TM0CNT_L = 0xFBFF; // Activate sound chip 16384 times/second REG_TM1CNT_L = 0xFEFF; // Refill buffer every 256 bytes that go through REG_TM1CNT_H = 0x00C4; // Enable with IRQ and cascade from Timer 0 REG_TM0CNT_H = 0x0080; // Interrupt at 16384 Hz while(1); } |
It's so bloody straightforward I can't figure out what could possibly be wrong with it. Like I said, it works fine with the timers, the memory map displays the correct values for the DMA registers (although the source never increments), and there is data in the buffer.
Anyone feel up to fielding this one?
Thanks,
Dan.