This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

用DMA传输数据时,触发方式和传输方式出现问题。

Other Parts Discussed in Thread: MSP430F169

这几天看同学用虚拟示波器感觉不错,我也想用MSP430F169做一个。

程序写好了也能用但是还有一很多不完善的地方。请大家帮助解答。先上代码(代码参考TI例程修改)

用定时器触发ADC转化,定时器在触发DMA,DMA把数据传送到串口 串口波特率115200

1,初始化ADC  和 AD转化触发信号TA2

void ADC_Init(void)
{
  P1DIR = 0xff;                             // set port to outputs
  P1OUT = 0;                                // reset port outputs
  P6SEL |= 0x01;                            // select A0 input
  ADC12CTL0 = ADC12ON+SHT0_1+REF2_5V+REFON; // Setup ADC12
  ADC12CTL1 = SHP+CONSEQ_2+SHS_1;           // Timer triggers sampling
  ADC12MCTL0 = INCH_0 + SREF_1;
  ADC12IE = 0x0001;                         // Enable ADC12IFG.0

  
  TACCR0=50000;  
  TACCTL1=0X00E0;
  TACCR1=110;
  TACCTL2=0X00E0;
  TACCR1=110;
  TACTL= TASSEL_2 + ID_3 + MC_1 ;
  
}
2.DMA设置代码
  DMACTL0 = DMA0TSEL_1;                     // 0-CCR2IFG
  DMA0SA = (unsigned int)  & ADC12MEM0 ;           // Source block address
  DMA0DA = (unsigned int)&U0TXBUF;                        // Dest single address
  DMA0SZ = 2   ;                // Block size
  DMA0CTL = DMADT_4 + DMASRCINCR_3 + DMASBDB + DMAEN;// Rpt, inc src, enable
 
以上是配置代码是正常工作时的,这里面有两个问题
  1.ADC转化时的IFG来触发DMA传送,但是修改DMA配置第一行为 DMACTL0 = DMA0TSEL_6;   串口不会收到数据,只能用定时来触发,ADC的IFG信号应该产生了。
  2.DMA传送方式选择101 Repeated block transfer时候,串口得到的数据总是0X0A,是不是DMA传输速度太快,导致串口没有发送出去

 

 

  • 配置ADC的时候关闭终端时能,DMA的ADCIFG触发竟然触发了,开启的时候却没有,怪了。

    //ADC12IE = 0x0001; // Enable ADC12IFG.0

  • 是不是 因为ADCIFG会同时触发中断服务和DMA,中断服务级别高,就先执行执行完的时候清楚IFG标志,DMA就检测不到了,所有没有数据传输。请帮助

  • A transfer is triggered by an ADC12IFGx flag. When single-channel conversions are
    performed, the corresponding ADC12IFGx is the trigger. When sequences are used, the
    ADC12IFGx for the last conversion in the sequence is the trigger. A transfer is triggered when
    the conversion is completed and the ADC12IFGx is set. Setting the ADC12IFGx with software
    will not trigger a transfer. All ADC12IFGx flags are automatically reset when the associated
    ADC12MEMx register is accessed by the DMA controller.