我用的是MSP430F5529,对于DMA模块,我想实现的是Fixed Address To Block Of Addresses,也就是如图所示:
在选择DMA Transfer Mode的时候选了100, Repeated Single Transfer。
问题来了:
我通过逐步运行观察DMA0DA地址的变化,发现他的值始终都是002400h(也就是RAM的起始地址),也就是说没有实现存放到block的功能,这是为什么呢?
Triton Zhang:
1. 你是如何观察的?
2. 代码如何?
3. 参见如下代码,是利用ADC转换触发DMA,并顺序把ADC采样的值用DMA放到数据BUF中。
unsigned int DMA_DST[10];
// Setup DMA0 DMACTL0 = DMA0TSEL_24; // ADC12IFGx triggered
DMACTL4 = DMARMWDIS; // Read-modify-write disable
DMA0CTL &= ~DMAIFG;
DMA0CTL = DMADT_4+DMAEN+DMADSTINCR_3; // Rpt single tranfer, inc dst, Int
DMA0SZ = 10; // DMA0 size = 1
__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &ADC12MEM0); // Source block address
__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) DMA_DST); // Destination single address
Haiqi Bian:
回复 Triton Zhang:
1.单步运行后通过registers窗口观察DMA0DA地址的变化,如图:始终都是002400h
2.DMA部分的代码如下:
unsigned int DMA_DST;
void main(){
……
// Setup DMA0 DMACTL0 = DMA0TSEL_24; // ADC12IFGx triggered DMACTL4 = DMARMWDIS; // Read-modify-write disable DMA0CTL &= ~DMAIFG; DMA0CTL = DMADT_4+DMAEN+DMADSTINCR_3+DMAIE; // Rpt single tranfer, inc dst, Int DMA0SZ = 1; // DMA0 size = 1
__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &ADC12MEM0); // Source block address __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &DMA_DST); // Destination single address __bis_SR_register(LPM3_bits + GIE); // LPM0 w/ interrupts __no_operation(); // used for debugging
}
3.对于你的这段程序,我想问:
1).变量DMA_DST[10]初始化和使用的时候都只是占用RAM空间吗?如果是这样,那其他不用DMA的程序变量也是只占用RAM空间?
2).DMA0SZ = 10;这个指的是总的数据大小而不是单个转换时的数据大小,是这样吗?