TI中文支持网
TI专业的中文技术问题搜集分享网站

cc2530 DMA+ADC 连续采样问题

static __xdata uint16 adc_data[4];

void dma_channel_init ( uint16 __xdata *dest_adr, uint8 lenl, uint8 trig )

 {   // Setup DMA confiuration    

halDMADesc_t *ch = HAL_NV_DMA_GET_DESC();//dma0  

HAL_DMA_SET_SOURCE(ch, &X_ADCL);  

HAL_DMA_SET_DEST( ch, dest_adr );  

HAL_DMA_SET_LEN(ch ,lenl);  

HAL_DMA_SET_VLEN(ch ,HAL_DMA_VLEN_USE_LEN);  

HAL_DMA_SET_WORD_SIZE(ch,HAL_DMA_WORDSIZE_WORD);

  HAL_DMA_SET_TRIG_SRC(ch,trig);

  HAL_DMA_SET_TRIG_MODE(ch,HAL_DMA_TMODE_BLOCK_REPEATED);

  HAL_DMA_SET_SRC_INC(ch,HAL_DMA_SRCINC_1);  

HAL_DMA_SET_DST_INC(ch,HAL_DMA_DSTINC_1);

  HAL_DMA_SET_IRQ(ch,HAL_DMA_IRQMASK_ENABLE);  

HAL_DMA_SET_M8(ch,HAL_DMA_M8_USE_8_BITS);    

DMA0CFGL = ((uint16)ch) & 0x00FF;  

 DMA0CFGH = ((uint16)ch) >> 8 & 0x00FF;    

DMAARM = 0x80; //aborts all channels     

DMAIRQ = 0x00;// set dma interrupt to zero  

DMAARM = 0x01;//starts channel 0

 }

void dma_adc_int(void)

{

  /* DMA configuration:    * Set up DMA channel 0 for tranfer from ADCL and ADCH to    * the ADC result table. The ADC will generate the DMA trigger    * on end of conversion.    */  

 // Configure DMA channel 0  

dma_channel_init(adc_data, 4 , HAL_DMA_TRIG_ADC_CHALL);

  // I/O-Port configuration  

 P0SEL|=0xF0; //1111 0000 通用IO  

 P0DIR&=0xF0; //1111 0000 0:输入  1:输出  

APCFG |= HAL_ADC_CHANNEL_3 | HAL_ADC_CHANNEL_2 | HAL_ADC_CHANNEL_1 | HAL_ADC_CHANNEL_0;//模拟IO使能    

  //   EA = 1; DMAIE = 1; DMAIF = 0;  

 ADCCON1 = 0x33;//full speed   bit1  bit0  

ADCCON2 = 0x30 | 0x80 | 0x04;//AVDD5 512 12ENOB P0_4   //启动ADC序列采集   

//AIRQ = 0x00;                 //清中断标志  

 EA = 0x01;   DMAIE = 0X01;//使能DMA  

 DMAIF = 0x00;  

ADCCON1 |= 0x40;//启动ADC序列采集  

DMAREQ = 0x01;//启动DMA传输  

 /* ADC conversion :   * The ADC will run in continous mode until disabled.   * Await all transfers being completed.   */  

 while( DMAIRQ != (0x01));  

 // Stop Continuous mode   //ADCCON1 |= ADCCON1_ST | BIT1 | BIT0; 

 }

 

dma和adc配置,程序运行只采样一次。

debug:

dma0  P0_0 1 2 3作为采样输入

VV:

你好,请问你的问题是什么,是没办法连续采样么?

谢谢! 

赞(0)
未经允许不得转载:TI中文支持网 » cc2530 DMA+ADC 连续采样问题
分享到: 更多 (0)