1 void _DMA_Configuration(void) 2 { 3 DMA_InitTypeDef DMA_InitStructure; 4 5 /* DMA2 Stream0 channel0 configuration */ 6 DMA_InitStructure.DMA_Channel = DMA_Channel_0; 7 DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(ADC->CDR); 8 DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)_AD_Value; 9 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; 10 DMA_InitStructure.DMA_BufferSize = 24; 11 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; 12 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; 13 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; 14 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word; 15 DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; 16 DMA_InitStructure.DMA_Priority = DMA_Priority_High; 17 DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; 18 DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; 19 DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; 20 DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; 21 DMA_Init(DMA2_Stream0, &DMA_InitStructure); 22 23 /* DMA2_Stream0 enable */ 24 DMA_Cmd(DMA2_Stream0, ENABLE); 25 } 26 void _ADC_Configuration(void) 27 { 28 ADC_InitTypeDef ADC_InitStructure; 29 ADC_CommonInitTypeDef ADC_CommonInitStructure; 30 31 /* ADC Common configuration *************************************************/ 32 ADC_CommonInitStructure.ADC_Mode = ADC_TripleMode_RegSimult; 33 ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles; 34 ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_1; 35 ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2; 36 ADC_CommonInit(&ADC_CommonInitStructure); 37 38 /* ADC1 regular channel 12 configuration ************************************/ 39 ADC_InitStructure.ADC_Resolution = ADC_Resolution_10b; 40 ADC_InitStructure.ADC_ScanConvMode = ENABLE; 41 ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; 42 ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; 43 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; 44 ADC_InitStructure.ADC_NbrOfConversion = 8; 45 ADC_Init(ADC1, &ADC_InitStructure); 46 47 ADC_RegularChannelConfig(ADC1, ADC_Channel_0 , 1, ADC_SampleTime_480Cycles); 48 ADC_RegularChannelConfig(ADC1, ADC_Channel_1 , 2, ADC_SampleTime_480Cycles); 49 ADC_RegularChannelConfig(ADC1, ADC_Channel_2 , 3, ADC_SampleTime_480Cycles); 50 ADC_RegularChannelConfig(ADC1, ADC_Channel_3 , 4, ADC_SampleTime_480Cycles); 51 ADC_RegularChannelConfig(ADC1, ADC_Channel_4 , 5, ADC_SampleTime_480Cycles); 52 ADC_RegularChannelConfig(ADC1, ADC_Channel_5 , 6, ADC_SampleTime_480Cycles); 53 ADC_RegularChannelConfig(ADC1, ADC_Channel_6 , 7, ADC_SampleTime_480Cycles); 54 ADC_RegularChannelConfig(ADC1, ADC_Channel_7 , 8, ADC_SampleTime_480Cycles); 55 /* Enable ADC1 DMA */ 56 ADC_DMACmd(ADC1, ENABLE); 57 58 /* ADC2 regular channel 12 configuration ************************************/ 59 ADC_Init(ADC2, &ADC_InitStructure); 60 /* ADC2 regular channel12 configuration */ 61 ADC_RegularChannelConfig(ADC2, ADC_Channel_8 , 1, ADC_SampleTime_480Cycles); 62 ADC_RegularChannelConfig(ADC2, ADC_Channel_9 , 2, ADC_SampleTime_480Cycles); 63 ADC_RegularChannelConfig(ADC2, ADC_Channel_10, 3, ADC_SampleTime_480Cycles); 64 ADC_RegularChannelConfig(ADC2, ADC_Channel_11, 4, ADC_SampleTime_480Cycles); 65 ADC_RegularChannelConfig(ADC2, ADC_Channel_12, 5, ADC_SampleTime_480Cycles); 66 ADC_RegularChannelConfig(ADC2, ADC_Channel_13, 6, ADC_SampleTime_480Cycles); 67 ADC_RegularChannelConfig(ADC2, ADC_Channel_14, 7, ADC_SampleTime_480Cycles); 68 ADC_RegularChannelConfig(ADC2, ADC_Channel_15, 8, ADC_SampleTime_480Cycles); 69 70 /* ADC3 regular channel 12 configuration ************************************/ 71 ADC_Init(ADC3, &ADC_InitStructure); 72 /* ADC3 regular channel12 configuration */ 73 ADC_RegularChannelConfig(ADC3, ADC_Channel_4 , 1, ADC_SampleTime_480Cycles); 74 ADC_RegularChannelConfig(ADC3, ADC_Channel_5 , 2, ADC_SampleTime_480Cycles); 75 ADC_RegularChannelConfig(ADC3, ADC_Channel_6 , 3, ADC_SampleTime_480Cycles); 76 ADC_RegularChannelConfig(ADC3, ADC_Channel_7 , 4, ADC_SampleTime_480Cycles); 77 ADC_RegularChannelConfig(ADC3, ADC_Channel_8 , 5, ADC_SampleTime_480Cycles); 78 ADC_RegularChannelConfig(ADC3, ADC_Channel_9 , 6, ADC_SampleTime_480Cycles); 79 ADC_RegularChannelConfig(ADC3, ADC_Channel_14, 7, ADC_SampleTime_480Cycles); 80 ADC_RegularChannelConfig(ADC3, ADC_Channel_15, 8, ADC_SampleTime_480Cycles); 81 82 /* Enable DMA request after last transfer (multi-ADC mode) ******************/ 83 ADC_MultiModeDMARequestAfterLastTransferCmd(ENABLE); 84 85 /* Enable ADC1 **************************************************************/ 86 ADC_Cmd(ADC1, ENABLE); 87 88 /* Enable ADC2 **************************************************************/ 89 ADC_Cmd(ADC2, ENABLE); 90 91 /* Enable ADC3 **************************************************************/ 92 ADC_Cmd(ADC3, ENABLE); 93 94 /* Start ADC1 Software Conversion */ 95 ADC_SoftwareStartConv(ADC1); 96 97 }