/* ÉùÃ÷TIMµÄ¼Ä´æÆ÷½á¹¹Ìå*/
ADC_InitTypeDef ADC_InitStruct;
ADC_CommonInitTypeDef ADC_CommonInitStruct;
DMA_InitTypeDef DMA_InitStruct;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOF, ENABLE);
/* ÉèÖÃAD²ÉÑù¶Ë¿Ú:Ä£ÄâÊäÈë*/
/* DMA2 channel2 configuration*/
DMA_InitStruct.DMA_Channel = DMA_Channel_2; //»Ö¸´Ä¬ÈÏÖµ¸Ã²Ù×÷ҪעÒâ²»ÒªÖظ´²Ù×÷Ôì³É¼Ä´æÆ÷״̬»ìÂÒ
DMA_InitStruct.DMA_PeripheralBaseAddr = ADC3_DR_Address; //ÍâÉèµØÖ· 32λµØÖ·
DMA_InitStruct.DMA_Memory0BaseAddr = (u32)&Tx_Buffer[2]; //ÄÚ´æµØÖ·£¬Êý×é½á¹¹À´´æ´¢²É¼¯µÄADÁ¿ ¼Ó(u32) ÒòΪ´æ´¢Æ÷µØÖ·¼Ä´æÆ÷ÊÇ32λµÄ
DMA_InitStruct.DMA_DIR = DMA_DIR_PeripheralToMemory; //dma´«Êä·½Ïòµ¥Ïò ÍâÉèΪԴ¡£
DMA_InitStruct.DMA_BufferSize = sampling_dot*chn*25*2; //ÉèÖÃDMAÔÚ´«Êäʱ»º³åÇøµÄ³¤¶È word 3¸öͨµÀ ÿ¸öͨµÀ32µã ¹²´æ96µãÖµ
DMA_InitStruct.DMA_PeripheralInc = DMA_PeripheralInc_Disable;//ÉèÖÃDMAµÄÍâÉèµÝÔöģʽ£¬Ò»¸öÍâÉè
DMA_InitStruct.DMA_MemoryInc = DMA_MemoryInc_Enable; //ÉèÖÃDMAµÄÄÚ´æµÝÔöģʽ£¬
DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;//ÍâÉèÊý¾Ý×Ö³¤
DMA_InitStruct.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;//ÄÚ´æÊý¾Ý×Ö³¤
DMA_InitStruct.DMA_Mode = DMA_Mode_Circular; //ÉèÖÃDMAµÄ´«Êäģʽ£ºÁ¬Ðø²»¶ÏµÄÑ»·Ä£Ê½
DMA_InitStruct.DMA_Priority = DMA_Priority_High; //ÉèÖÃDMAµÄÓÅÏȼ¶±ðΪ¸ß
DMA_InitStruct.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStruct.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_InitStruct.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStruct.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; //
DMA_Init(DMA2_Stream0, &DMA_InitStruct);
/*Enable DMA1 channel1*/
DMA_Cmd(DMA2_Stream0, ENABLE);
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_HTIF0);
DMA_ITConfig(DMA2_Stream0, DMA_IT_HT, ENABLE);
DMA_ITConfig(DMA2_Stream0, DMA_IT_TC, ENABLE);
/* Configure PC.03 (ADC Channel13) as analog input -------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOF, &GPIO_InitStructure);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC3, ENABLE);
/* Common configuration (applicable for the three ADCs) ******/
/* Single ADC mode */
ADC_CommonInitStruct.ADC_Mode = ADC_Mode_Independent;
/* ADCCLK = PCLK2/2 */
ADC_CommonInitStruct.ADC_Prescaler = ADC_Prescaler_Div6;
ADC_CommonInitStruct.ADC_Prescaler = ADC_Prescaler_Div8;
/* Available only for multi ADC mode */
// ADC_CommonInitStruct.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
ADC_CommonInitStruct.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
/* Delay between 2 sampling phases */
ADC_CommonInitStruct.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_20Cycles;
ADC_CommonInit(&ADC_CommonInitStruct);
/* Configure ADC1 to convert continously channel/2/3 ***********/
ADC_InitStruct.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStruct.ADC_ScanConvMode = ENABLE ;
ADC_InitStruct.ADC_ContinuousConvMode = DISABLE;
// ADC_InitStruct.ADC_ContinuousConvMode = ENABLE;
ADC_InitStruct.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
ADC_InitStruct.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStruct.ADC_NbrOfConversion = chn;
ADC_Init(ADC3, &ADC_InitStruct);
/* ADC1 regular channels configuration [¹æÔòģʽͨµÀÅäÖÃ]*/
ADC_RegularChannelConfig(ADC3, ADC_Channel_5 , 6, ADC_SampleTime_480Cycles);//ͨµÀ1£¬UA
ADC_RegularChannelConfig(ADC3, ADC_Channel_10, 5, ADC_SampleTime_480Cycles);//ͨµÀ2£¬IA
ADC_RegularChannelConfig(ADC3, ADC_Channel_6 , 4, ADC_SampleTime_480Cycles);//ͨµÀ3£¬UB
ADC_RegularChannelConfig(ADC3, ADC_Channel_4 , 3, ADC_SampleTime_480Cycles);//ͨµÀ4£¬IB
ADC_RegularChannelConfig(ADC3, ADC_Channel_7 , 2, ADC_SampleTime_480Cycles);//ͨµÀ5£¬UC
ADC_RegularChannelConfig(ADC3, ADC_Channel_13 ,1, ADC_SampleTime_480Cycles);//ͨµÀ6£¬IC
ADC_DMARequestAfterLastTransferCmd(ADC3, ENABLE);
/* ʹÄÜADC1 DMA*/
ADC_DMACmd(ADC3, ENABLE);
/* Enable ADC1 ʹÄÜADC1*/
// ADC_ITConfig(ADC3, ADC_IT_EOC, ENABLE);
/* Enable ADC1 ʹÄÜADC1*/
ADC_Cmd(ADC3, ENABLE);
ADC_SoftwareStartConv(ADC3); |