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.

CC2640 ADC trigger DMA

Other Parts Discussed in Thread: CC2640R2F

想请问下Ti的大神们几个问题:

1.按照数据手册17.4.8.11的DMA usag里面说的 ADC触发DMA主要依赖两个事件:ADC_ FIFO_NOT_EMPTY和ADC_FIFO_ALMOST_FULL

但是我并没有在ADC里找到设置触发源的相应API只找到一个AUXADCEnableSync()函数,但是这个函数似乎不能设置成除了手动触发之外的触发方式,希望大神给我解答。

2.ADC的初始化和DMA的初始化的逻辑顺序是怎样的?究竟先初始化通道然后打开再初始化ADC,还是反过来?之前在另一个帖子我也问了,但是没有回答,希望TI的工程师给我反馈,感谢!!!!!!!!

更新一下我的代码,bspDmaInit()是DMA配置文件、ADCInit()是ADC的驱动

/*********************************************************************
 * MACROS
 */

#define Board_BAT_Volt            IOID_24  //adc采样

/*********************************************************************
 * LOCAL VARIABLES
 */
static uint8 ucDMAControlTable[1024];

uint16 buffer[400] = {0};

//static UDMACC26XX_Handle SbpDmaHandle;

//static Semaphore_Struct mutex;
/*********************************************************************
 * LOCAL FUNCTIONS
 */
void bspDmaInit(void);
void ADCInit(uint32 input);


void bspDmaInit(void)
{
//  Semaphore_Params semParamsMutex;
//
//  // Create protection semaphore
//  Semaphore_Params_init(&semParamsMutex);
//  semParamsMutex.mode = Semaphore_Mode_BINARY;
//  Semaphore_construct(&mutex, 1, &semParamsMutex);
  
  //enable udma peripher clock
  PRCMPeripheralRunEnable(PRCM_PERIPH_UDMA);
  PRCMLoadSet();
  
  //config udma base address
  uDMAEnable(UDMA0_BASE);
  uDMAControlBaseSet(UDMA0_BASE ,ucDMAControlTable);
  
  //config adc channel 7、src、des、len
  uDMAChannelAttributeDisable(UDMA0_BASE ,UDMA_CHAN_AUX_ADC ,UDMA_ATTR_ALL);
  uDMAChannelAttributeEnable(UDMA0_BASE ,UDMA_CHAN_AUX_ADC ,UDMA_ATTR_HIGH_PRIORITY);
  
  uDMAChannelControlSet(UDMA0_BASE ,UDMA_PRI_SELECT ,
                        UDMA_SIZE_16 | UDMA_SRC_INC_NONE |
                        UDMA_DST_INC_16 | UDMA_ARB_1);
  
  uDMAChannelTransferSet(UDMA0_BASE ,UDMA_PRI_SELECT ,
                         UDMA_MODE_BASIC, 
                         (void *)ADC_SOURCE_ADDRESS,
                         buffer,11);
  
  ADCInit(ADC_COMPB_IN_AUXIO6);
  
  //config dma trigger on adc
  HWREG(AUX_EVCTL_BASE + DMACTL_ADDRESS) |= 0x06;
  
  //open DMA channel 7
  uDMAChannelEnable(UDMA0_BASE ,UDMA_CHAN_AUX_ADC);    
}

void ADCInit(uint32 input)
{
      uint32_t turnedOnClocks = 0;  
    //////////// Config clock/////////////////////  
    // Only turn on clocks that are not already enabled. Not thread-safe, obviously.  
    turnedOnClocks |= AUXWUCClockStatus(AUX_WUC_ADC_CLOCK) ? 0 : AUX_WUC_ADC_CLOCK;  
    turnedOnClocks |= AUXWUCClockStatus(AUX_WUC_ADI_CLOCK) ? 0 : AUX_WUC_ADI_CLOCK;  
    turnedOnClocks |= AUXWUCClockStatus(AUX_WUC_SOC_CLOCK) ? 0 : AUX_WUC_SOC_CLOCK;  
    
    // 打开时钟
    AUXWUCClockEnable(turnedOnClocks);    
    while(AUX_WUC_CLOCK_OFF == AUXWUCClockStatus(turnedOnClocks));  

    //同步采样率
    AUXADCEnableSync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_10P9_MS, AUXADC_TRIGGER_MANUAL);  
    
    //设置输入
    AUXADCSelectInput(input);  
    
    //Scaling disable  
    AUXADCDisableInputScaling();  
    
    //开始触发
    AUXADCGenManualTrigger();       // Trigger sample   
    
//    AUXADCReadFifo();
}


主动去读ADC的值,很正常,但是开启DMA后无法获取相应数据。

  • 没有TI的工程师帮忙解答一下么?!!!

  • 你好.抱歉,现在只有SPI DMA的例程.我建议你把这个帖子发到我们的e2e.ti.com L论坛。产品线会针对你问题回复。

  • Hello, Loops 

    Sorry I can't input Chinese from work station. I guess that he, other developers and myself are facing the same issue with cc2640r2f.

    I am developing a flash bootloader on cc2640rf development kit, I am following the DAM initialization procedure in user technical reference document, but the problems are that, the CFG register shows error information while the PRCM registers show that DMA is already powered up and clock set up properly, so thereafter channel enable and other configuration would not work at all

    / Enable peripheral domain
    PRCMPowerDomainOn(PRCM_DOMAIN_PERIPH);
    while (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH) != PRCM_DOMAIN_POWER_ON)
    {
    ;
    }

    // Enable uDMA controller
    PRCMPeripheralRunEnable(PRCM_PERIPH_UDMA);
    PRCMPeripheralSleepEnable(PRCM_PERIPH_UDMA);
    // Load the setting to clock controller
    PRCMLoadSet();
    // Wait setting done
    while (!PRCMLoadGet())
    {
    ;
    }

    //-Enable DMA: HWREG(UDMA0_BASE + UDMA_O_CFG) = UDMA_CFG_MASTERENABLE;

    uDMAEnable(UDMA0_BASE);

    // Set control table
    uDMAControlBaseSet(UDMA0_BASE, (void*)&ucDMAControlTable[0]);

    I am using code composer studio "Version: 7.4.0.00015 " and LAUNCHXL CC26040R2 Rev 1.0

      

  • 你指的ERROR是CFG全0 吗?

  • 帮你把帖子转到我们e2e英文社区。你可以跟踪下。e2e.ti.com/.../663637
  • 产品线回复如下:

    Have you had a look on the ADBufCC26xx driver (ADCBufCC26XX.c)? It sets up the ADC and DMA to work together an should work as a guide on how to do the initialization as well as operation on a driverlib level. 

    Making a fast comparison of this code to the ADCBufCC26xx.c (and UDMACC26xx.c) it seems so be quite similar but the operations is not performed in the same order (not sure if this should cause a problem). 
    Following the ADCBufCC26XX_open() -> ADCBufCC26XX_convert() -> ADCBufCC26XX_hwi() -> ADCBufCC26XX_swi() flow should cover start to end of a ADC + DMA operation.