#25605 - /*Articuno*/ - Wed Aug 25, 2004 10:28 pm
Hello World,
I'm having a strange problem when using DMA for copying...
This code:
wasn't working (on our first versions it was working... before we started using DevKitArm, Krawall, etc...)
Then we made this "slower" version:
But, when i was told that Krawall and DMA should be working together, i made this test:
to check how many blocks were being correctly copied...
And then the DMA Copy started working again! Note that the loops are only comparing values!
(and dprintf is just my debug function, that prints to VisualBoyAdvance's stdout...)
When i remove this "test code", the function doesn't work at all, as if things were messed during copy (the game shows arbitrary colors, a dark and broken version of our game... some pictures missing... etc...)
Someone can tell me what is wrong ? Could Krawall be affecting DMA ? Should I use interrupts for DMA ?
_________________
Close the world, txEn eht nepO.
I'm having a strange problem when using DMA for copying...
This code:
Code: |
void DMAFastCopy(void* source,void* dest,unsigned int count,unsigned int mode) { if (mode == DMA_16NOW || mode == DMA_32NOW) { REG_DMA3SAD = (unsigned int)source; REG_DMA3DAD = (unsigned int)dest; REG_DMA3CNT = count | mode; } } |
wasn't working (on our first versions it was working... before we started using DevKitArm, Krawall, etc...)
Then we made this "slower" version:
Code: |
void DMAFastCopy(void* source,void* dest,unsigned int count,unsigned int mode) { // DMASlowCopy ^_^; if (mode == DMA_16NOW) while(count--) *((u16*)dest + count) = *((u16*)source + count); else while(count--) *((u32*)dest + count) = *((u32*)source + count); } |
But, when i was told that Krawall and DMA should be working together, i made this test:
Code: |
void DMAFastCopy(void* source,void* dest,unsigned int count,unsigned int mode) { if (mode == DMA_16NOW || mode == DMA_32NOW) { REG_DMA3SAD = (unsigned int)source; REG_DMA3DAD = (unsigned int)dest; REG_DMA3CNT = count | mode; } dprintf("Trying to copy %d blocks...\n", count); if (mode == DMA_16NOW) { while(count--) if (*((u16*)dest + count) != *((u16*)source + count)) break; } else { while(count--) if (*((u32*)dest + count) != *((u32*)source + count)) break; } dprintf("%d\n", count); } |
to check how many blocks were being correctly copied...
And then the DMA Copy started working again! Note that the loops are only comparing values!
(and dprintf is just my debug function, that prints to VisualBoyAdvance's stdout...)
When i remove this "test code", the function doesn't work at all, as if things were messed during copy (the game shows arbitrary colors, a dark and broken version of our game... some pictures missing... etc...)
Someone can tell me what is wrong ? Could Krawall be affecting DMA ? Should I use interrupts for DMA ?
_________________
Close the world, txEn eht nepO.