int main() { uint8_t cnt; float VTUNE_temp; float VTUNE_delta_temp; uint16_t ii; Cache_Enable(); //open L1-Cache HAL_Init(); //Initialize HAL library Stm32_Clock_Init(432,25,2,9); //Set clock 216M /////////////////////ADC初始化//////////////////////////////////// DELAY_init(216); //Delay initialization UART_init(115200); //Serial port initialization ADC123_Config(); my_adc1_handle = &ADC1_Handler; USART6_DMA_Config(DMA2_Stream6,DMA_CHANNEL_5); DAC1_INIT(); TIM3_Init(2-1,108-1); //Generate DAC table VTUNE_delta_temp = (g_VTUNE_SET[1] - g_VTUNE_SET[0])/CHIRP_LEN; for(ii = 0;ii < CHIRP_LEN;ii++) { VTUNE_temp = g_VTUNE_SET[0] + ii*VTUNE_delta_temp; g_DAC_TABLE[ii] = (uint16_t)(VTUNE_temp/3.3*4096); } for(ii = CHIRP_LEN;iiInstance->CR2 |= (uint32_t)ADC_CR2_SWSTART; //Start ADC while(!sampling_over) {}; SCB_CleanInvalidateDCache(); sampling_over = 0; } ADC_HandleTypeDef ADC1_Handler; ADC_HandleTypeDef ADC2_Handler; ADC_HandleTypeDef ADC3_Handler; DMA_HandleTypeDef hdma_adc; ADC_MultiModeTypeDef adc_mode; extern volatile uint8_t sampling_over; extern uint16_t ADC_Buff[ADC_DATA_LEN]; int i=0; void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { GPIO_InitTypeDef GPIO_InitStruct; DMA_HandleTypeDef hdma_adc; __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_ADC1_CLK_ENABLE(); __HAL_RCC_ADC2_CLK_ENABLE(); __HAL_RCC_ADC3_CLK_ENABLE(); __HAL_RCC_DMA2_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); hdma_adc.Instance = DMA2_Stream0; hdma_adc.Init.Channel = DMA_CHANNEL_0; hdma_adc.Init.Direction = DMA_PERIPH_TO_MEMORY; hdma_adc.Init.PeriphInc = DMA_PINC_DISABLE; hdma_adc.Init.MemInc = DMA_MINC_ENABLE; hdma_adc.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; hdma_adc.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; hdma_adc.Init.Mode = DMA_CIRCULAR; hdma_adc.Init.Priority = DMA_PRIORITY_HIGH; hdma_adc.Init.FIFOMode = DMA_FIFOMODE_DISABLE; / hdma_adc.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_HALFFULL; hdma_adc.Init.MemBurst = DMA_MBURST_SINGLE; hdma_adc.Init.PeriphBurst = DMA_PBURST_SINGLE; HAL_DMA_Init(&hdma_adc); __HAL_LINKDMA(hadc, DMA_Handle, hdma_adc); HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); } void ADC123_Config(void) { ADC_ChannelConfTypeDef sConfig; ADC_MultiModeTypeDef mode; /*##-1- Configure the ADC2 peripheral ######################################*/ ADC3_Handler.Instance = ADC3; ADC3_Handler.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV6;216/6 ADC3_Handler.Init.ScanConvMode = DISABLE; ADC3_Handler.Init.ContinuousConvMode = ENABLE; ADC3_Handler.Init.DiscontinuousConvMode = DISABLE; ADC3_Handler.Init.NbrOfDiscConversion = 0; ADC3_Handler.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; ADC3_Handler.Init.ExternalTrigConv = ADC_SOFTWARE_START ; ADC3_Handler.Init.DataAlign = ADC_DATAALIGN_RIGHT; ADC3_Handler.Init.NbrOfConversion = 1; ADC3_Handler.Init.DMAContinuousRequests = DISABLE; ADC3_Handler.Init.EOCSelection = DISABLE; if (HAL_ADC_Init(&ADC3_Handler) != HAL_OK) { /* Initialization Error */ // Error_Handler(); } /*##-2- Configure ADC3 regular channel #####################################*/ sConfig.Channel = ADC_CHANNEL_1; sConfig.Rank = 1; sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; sConfig.Offset = 0; if(HAL_ADC_ConfigChannel(&ADC3_Handler, &sConfig) != HAL_OK) { /* Channel Configuration Error */ // Error_Handler(); } /*##-3- Configure the ADC2 peripheral ######################################*/ ADC2_Handler.Instance = ADC2; ADC2_Handler.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV6; ADC2_Handler.Init.ScanConvMode = DISABLE; ADC2_Handler.Init.ContinuousConvMode = ENABLE; ADC2_Handler.Init.DiscontinuousConvMode = DISABLE; ADC2_Handler.Init.NbrOfDiscConversion = 0; ADC2_Handler.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; ADC2_Handler.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T1_CC1; ADC2_Handler.Init.DataAlign = ADC_DATAALIGN_RIGHT; ADC2_Handler.Init.NbrOfConversion = 1; ADC2_Handler.Init.DMAContinuousRequests = DISABLE; ADC2_Handler.Init.EOCSelection = DISABLE; if (HAL_ADC_Init(&ADC2_Handler) != HAL_OK) { /* Initialization Error */ // Error_Handler(); } /*##-4- Configure ADC2 regular channel #####################################*/ sConfig.Channel = ADC_CHANNEL_1; sConfig.Rank = 1; sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; sConfig.Offset = 0; if (HAL_ADC_ConfigChannel(&ADC2_Handler, &sConfig) != HAL_OK) { /* Channel Configuration Error */ // Error_Handler(); } /*##-5- Configure the ADC1 peripheral ######################################*/ ADC1_Handler.Instance = ADC1; ADC1_Handler.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV6; ADC1_Handler.Init.ScanConvMode = DISABLE; ADC1_Handler.Init.ContinuousConvMode = ENABLE; ADC1_Handler.Init.DiscontinuousConvMode = DISABLE; ADC1_Handler.Init.NbrOfDiscConversion = 0; ADC1_Handler.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; ADC1_Handler.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T1_CC1; ADC1_Handler.Init.DataAlign = ADC_DATAALIGN_RIGHT; ADC1_Handler.Init.NbrOfConversion = 1; ADC1_Handler.Init.DMAContinuousRequests = ENABLE; ADC1_Handler.Init.EOCSelection = DISABLE; if (HAL_ADC_Init(&ADC1_Handler) != HAL_OK) { /* Initialization Error */ // Error_Handler(); } /*##-6- Configure ADC1 regular channel #####################################*/ if (HAL_ADC_ConfigChannel(&ADC1_Handler, &sConfig) != HAL_OK) { /* Channel Configuration Error */ // Error_Handler(); } /*##-7- Configure Multimode ################################################*/ mode.Mode = ADC_TRIPLEMODE_INTERL; mode.DMAAccessMode = ADC_DMAACCESSMODE_2; mode.TwoSamplingDelay = ADC_TWOSAMPLINGDELAY_5CYCLES; if (HAL_ADCEx_MultiModeConfigChannel(&ADC1_Handler, &mode) != HAL_OK) { /* Multimode Configuration Error */ // Error_Handler(); } } void DMA2_Stream0_IRQHandler (void) { HAL_NVIC_DisableIRQ(DMA2_Stream0_IRQn); if(DMA2->LISR & 0x00000020) { DMA2->LIFCR |= 0x00000030; sampling_over = 1; } HAL_ADC_Stop(&ADC3_Handler); HAL_ADC_Stop(&ADC2_Handler); HAL_ADCEx_MultiModeStop_DMA(&ADC1_Handler); } Thank you.