DMA_DeInit(DMA1_Channel1); 凡是遇到DMA1_Channel1 都是找不到,我是参考2.0库ADC转换例子
下边是例子 void adc_init_Configuration(void) { GPIO_adc_Configuration(); // DMA 通道1配置 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); // 使能DMA的时钟
/* DMA1 channel1 configuration ----------------------------------------------*/ DMA_DeInit(DMA1_Channel1); // 复位 DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address; // 外围设备的基址 DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_collection; // 存储空间的基址 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; // 方向:外围->内存 DMA_InitStructure.DMA_BufferSize = ADC_number; // 传输的数目 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; // 外围设备地址不增加 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; // 内存空间地址加1 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; // 外围设备的字长 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word; // 内存空间的字长 DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; // 模式:循环缓冲 DMA_InitStructure.DMA_Priority = DMA_Priority_High; // 优先级:高 DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; // 没有使用内存到内存方式 DMA_Init(DMA1_Channel1, &DMA_InitStructure); DMA_Cmd(DMA1_Channel1, ENABLE); // 使能
/* ADC1 configuration ------------------------------------------------------*/ ADC_InitStructure.ADC_Mode = ADC_Mode_RegSimult; ADC_InitStructure.ADC_ScanConvMode = ENABLE; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = 9;//装换9个通道 ADC_Init(ADC1, &ADC_InitStructure); /* ADC1 regular channels configuration */ ADC_RegularChannelConfig(ADC1, ADC_Channel_UA, 1, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_UB, 2, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_UC, 3, ADC_SampleTime_239Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_UA, 4, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_UB, 5, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_UC, 6, ADC_SampleTime_239Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_UA, 7, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_UB, 8, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_UC, 9, ADC_SampleTime_239Cycles5); ADC_DiscModeChannelCountConfig (ADC1, 3);//一次转换3个数据 /* Enable ADC1 DMA */ ADC_DMACmd(ADC1, ENABLE);
/* ADC2 configuration ------------------------------------------------------*/ ADC_InitStructure.ADC_Mode = ADC_Mode_RegSimult; ADC_InitStructure.ADC_ScanConvMode = ENABLE; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = 9; //装换9个通道 ADC_Init(ADC2, &ADC_InitStructure); /* ADC2 regular channels configuration */ ADC_RegularChannelConfig(ADC2, ADC_Channel_IA1, 1, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_IB2, 2, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_IC3, 3, ADC_SampleTime_239Cycles5);
ADC_RegularChannelConfig(ADC2, ADC_Channel_IA4, 4, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_IB5, 5, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_IC6, 6, ADC_SampleTime_239Cycles5);
ADC_RegularChannelConfig(ADC2, ADC_Channel_IA7, 7, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_IB8, 8, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_IC9, 9, ADC_SampleTime_239Cycles5);
ADC_DiscModeChannelCountConfig (ADC2, 3);//一次转换3个数据 /* Enable ADC2 external trigger conversion */ ADC_ExternalTrigConvCmd(ADC2, ENABLE);
/* Enable ADC1 */ ADC_Cmd(ADC1, ENABLE);//使能ADC /* Enable Vrefint channel17 */ ADC_TempSensorVrefintCmd(ENABLE);//使能温度传感器和内部电压参考通道
/* Enable ADC1 reset calibaration register */ ADC_ResetCalibration(ADC1);//校准ADC1 /* Check the end of ADC1 reset calibration register */ while(ADC_GetResetCalibrationStatus(ADC1));//获取ADC校准的状态
/* Start ADC1 calibaration */ ADC_StartCalibration(ADC1);//开始指定ADC校准状态 /* Check the end of ADC1 calibration */ while(ADC_GetCalibrationStatus(ADC1));//获取指定ADC的校准状态
/* Enable ADC2 */ ADC_Cmd(ADC2, ENABLE); //使能ADC
/* Enable ADC2 reset calibaration register */ ADC_ResetCalibration(ADC2);//校准ADC1 /* Check the end of ADC2 reset calibration register */ while(ADC_GetResetCalibrationStatus(ADC2));//获取ADC校准的状态
/* Start ADC2 calibaration */ ADC_StartCalibration(ADC2); /* Check the end of ADC2 calibration */ while(ADC_GetCalibrationStatus(ADC2));
/* Start ADC1 Software Conversion */ ADC_SoftwareStartConvCmd(ADC1, ENABLE);
/* Test on DMA1 channel1 transfer complete flag */ while(!DMA_GetFlagStatus(DMA1_FLAG_TC1)); /* Clear DMA1 channel1 transfer complete flag */ DMA_ClearFlag(DMA1_FLAG_TC1); } |
|