#178 - Japster - Sat Jan 04, 2003 3:51 pm
Where can I find a good C/C++ example using DMA?
Jasper
#188 - imikeyi - Sun Jan 05, 2003 12:21 am
Here's some code I use for DMA:
#define REG_DMA3SAD *(volatile u32*) 0x40000D4
#define REG_DMA3DAD *(volatile u32*) 0x40000D8
#define REG_DMA3CNT_L *(volatile u16*) 0x40000DC
#define REG_DMA3CNT_H *(volatile u16*) 0x40000DE
void DMA3(u32 source, u32 dest, u16 ctrlLow, u16 ctrlHigh)
{
REG_DMA3SAD = source;
REG_DMA3DAD = dest;
REG_DMA3CNT_L = ctrlLow;
REG_DMA3CNT_H = ctrlHigh;
}
Eg.
DMA3((u32) &backgroundPalette, (u32) PALETTE_RAM, 256, 0x8000);
#246 - Japster - Sun Jan 05, 2003 2:52 pm
Thanks. BTW What does "volatile" mean? Could missing "volatiles" be the reason for that my programs don't work correctly?
Jasper
#252 - MHz - Sun Jan 05, 2003 4:18 pm
'Volatile' simply means the defined data may change from outside your code (certain memory locations such as counters, in/out ports etc). Because of this, the compiler will not make any assumptions about the data (in order to optimize it for instance).
I hope the explanation is clear enough... :)