unsigned long results_MPY16X16[128]={0};
DMACTL1=DMA2TSEL__MPY; //乘法器触发
__data16_write_addr((unsigned short) &DMA2SA,(unsigned long)&RESLO); //源地址
__data16_write_addr((unsigned short) &DMA2DA,(unsigned long)&results_MPY16X16[0]); //目的地址
DMA1SZ=2; //2个字
DMA2CTL=DMADT_4+DMASWDW+DMADSTINCR_3+DMASRCINCR_3+DMAEN+DMAIE; // 目的地址增,源地址增,重复单次转化,
#pragma vector=DMA_VECTOR //DMA2中断函数
__interrupt void DMA_ISR(void)
{
switch(__even_in_range(DMAIV,16))
{
case 0: break;
case 2: break; // DMA0IFG = DMA Channel 0 case 4: break; // DMA1IFG = DMA Channel 1
case 6:
{
_NOP();
} break; // DMA2IFG = DMA Channel 2
case 8: break; // DMA3IFG = DMA Channel 3
case 10: break; // DMA4IFG = DMA Channel 4
case 12: break; // DMA5IFG = DMA Channel 5
case 14: break; // DMA6IFG = DMA Channel 6
case 16: break; // DMA7IFG = DMA Channel 7
default: break;
}
}
问题是:为什么从results_MPY16X16[0]到results_MPY16X16[28] 每个数组元素都有数值(不是0),后面数组元素的没有值(为0).
应该是只在results_MPY16X16[0]和results_MPY16X16[1],中有数值。为什么会出现上面的问题?谢谢
qiang liu2:
回复 Triton Zhang:
乘法器没有单独的代码,所以就不能贴了。
但是我将这部分代码单独运行还是有问题。
代码如下:
void main()
{
WDTCTL = WDTPW + WDTHOLD; check_clk();
unsigned int DMA_DST[10]={0};
unsigned int test_start[10]={121,5436,456,1215,326,9548,63,6554,554,12};
TA0CTL = TASSEL_2+MC_1+TACLR; //CLK=MCLK,增计数模式 ,清TAR TA0CCTL0|= OUTMOD_7; // TA0CCTL2|= OUTMOD_3; TA0CCR0 = 100; TA0CCR2=70; DMACTL4=DMARMWDIS; DMACTL1=DMA0TSEL__TA0CCR2; //TA0CCR2触发 __data16_write_addr((unsigned short) &DMA2SA,(unsigned long)&test_start); __data16_write_addr((unsigned short) &DMA2DA,(unsigned long)&DMA_DST); DMA1SZ=2; DMA2CTL=DMADT_4+DMASWDW+DMADSTINCR_3+DMASRCINCR_3+DMAEN; }
DMA_DST结果:121, 5436 ,456 ,1215, 326, 9548, 63, 6554, 554, 12
问题还是一样,应该只有DMA_DST[0]和DMA_DST[1]中有结果,而其他是没有结果,但是现在问题DMA将所有的值都传送过来?这是为什么呢?
qiang liu2:
回复 Triton Zhang:
谢谢您的回答!我找到问题,是我太疏忽!