本帖最后由 sptek 于 2009-9-30 10:36 编辑
不想用DMA方式进行ADC.初始化代码如下,我该如何获得每个通道的AD转换数据呢?看手册都没有明白.
/* ADC1 Configuration ------------------------------------------------------*/
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;//工作在单通道模式.(另外一种多通道模式)
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; //工作在连续转换还是单词转换模式
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;//触发转换的模式:有软件触发转换
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //数据对齐模式
ADC_InitStructure.ADC_NbrOfChannel = 2;//顺序进行AD转换的数码.
ADC_Init(ADC1, &ADC_InitStructure);
/* ADC1 regular channel0 configuration */
/*设置ADC_SMPR和ADC_SQR寄存器*/
ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_13Cycles5); //指定ADC规则组通道.
/* ADC1 regular channel0 configuration */
ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 2, ADC_SampleTime_13Cycles5);
/* Configure high and low analog watchdog thresholds */
ADC_AnalogWatchdogThresholdsConfig(ADC1, 0x0B00, 0x0300);
/* Configure channel14 as the single analog watchdog guarded channel */
ADC_AnalogWatchdogSingleChannelConfig(ADC1, ADC_Channel_0 );
/* Enable analog watchdog on one regular channel */
ADC_AnalogWatchdogCmd(ADC1, ADC_AnalogWatchdog_SingleRegEnable);
/* Enable AWD interupt */
//ADC_ITConfig(ADC1, ADC_IT_AWD, ENABLE);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Enable ADC1 reset calibaration register */
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));
/* Start ADC1 calibaration */
ADC_StartCalibration(ADC1);
/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1));
/* Start ADC1 Software Conversion */
/*设置ADC_CR2的软件启动位,启动ADC软件启动转换功能*/
ADC_SoftwareStartConvCmd(ADC1, ENABLE); |