DMACTL0 =DMA0TSEL_24+DMA1TSEL_24; DMACTL4 = DMARMWDIS; __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &ADC12MEM0); //DMA0 目的地址 __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &MPY); //DMA0源地址 DMA0SZ=1; // DMA0 size = 1
DMA0CTL = DMADT_4+DMAEN+DMADSTBYTE+DMASRCBYTE; // __data16_write_addr((unsigned short) &DMA1SA,(unsigned long) &ADC12MEM1); //DMA1 目的地址 __data16_write_addr((unsigned short) &DMA1DA,(unsigned long) &OP2); //DMA1源地址
DMA1SZ=1; // DMA1 size = 1
DMA1CTL = DMADT_4+DMAEN+DMADSTBYTE+DMASRCBYTE;
ADC12MEM0和ADC12MEM1中已经采集到了数据,但是DMA不能将数据传递到MPY和OP2中,MDA代码如上。
Maka Luo:
// 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
参见这个例程,希望对你有所帮忙。
qiang liu2:
回复 Maka Luo:
你好!你说的这个代码我已经看过,但是有个问题:当我把ADC12的转换模式改为ADC12CONSEQ_2(单通道序列转换)就可以将ADC12MEN0的值转移到MPY中区,但是当我将ADC12转换模式改为ADC12CONSEQ_3(序列通道序列转换)时,DMA就不能将ADC12MEM0传到MPY,也不能将ADC12MEM1传到OP2中。不知道是什么原因?希望您能够再详细的讲解哈!谢谢!