MAP_ADC14_enableModule(); //使能ADC14模块
MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_3, ADC_NOROUTE); //初始化ADC 时钟 分频 通道 9.6MHz
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN5, GPIO_TERTIARY_MODULE_FUNCTION); //模拟输入(p5.5 A0)
MAP_ADC14_configureSingleSampleMode(ADC_MEM0, true); //单通道配置 多次转化true
MAP_ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A0, false); //使用内部电源电压参考 非差分输入false
MAP_ADC14_enableInterrupt(ADC_INT0); //ADC通道0的中断
/* Configuring DMA module */
MAP_DMA_enableModule();
MAP_DMA_setControlBase(controlTable);
/*
* Primary DMA Channel, ADC12C
* Size = 16bits
* Source Increment = 16bits
* Destination Increment = 16bits
* Arbitration = 1 , no other sources
*/
MAP_DMA_setChannelControl(UDMA_PRI_SELECT | DMA_CH7_ADC14,
UDMA_SIZE_16 | UDMA_SRC_INC_NONE | UDMA_DST_INC_16 | UDMA_ARB_1);
MAP_DMA_setChannelTransfer(UDMA_PRI_SELECT | DMA_CH7_ADC14,
UDMA_MODE_PINGPONG, (void*) &ADC14->MEM[0],
(void*)adc_v,1024);
//UDMA_MODE_PINGPONG UDMA_MODE_AUTO UDMA_MODE_BASIC
/* Assigning/Enabling Interrupts */
MAP_DMA_assignInterrupt(DMA_INT1, 7);
MAP_Interrupt_enableInterrupt(INT_DMA_INT1);
MAP_DMA_assignChannel(DMA_CH7_ADC14);
MAP_DMA_clearInterruptFlag(7);
MAP_Interrupt_enableMaster();
/* Now that the DMA is primed and setup, enabling the channels. The ADC14
* hardware should take over and transfer/receive all bytes.The DMA is
* triggered after the conversion in single-channel conversion mode or
* after the completion of a sequence of channel conversions in
* sequence-ofchannels conversion mode. */
MAP_DMA_enableChannel(7);
/* Setting up the sample timer to automatically step through the sequence
* convert.
*/
ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
/* Triggering the start of the sample */
MAP_ADC14_enableConversion();
MAP_ADC14_toggleConversionTrigger();