本帖最后由 LOVE_ELEC 于 2014-10-17 15:30 编辑
先贴下代码:
/* GPIO 初始化部分 */
GPIO_InitTypeDef GPIO_InitStructure; /* MAC Pin */
GPIO_InitStructure.GPIO_Pin = MAC_GPIO_PIN; /* PA0 */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(MAC_GPIO_PORT, &GPIO_InitStructure);
/* ADC 模拟看门狗初始化部分 */
ADC_InitTypeDef ADC_InitStructure;
/* Enable the HSI */
RCC_HSICmd(ENABLE);
/* Wait until HSI oscillator is ready */
while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);
/* Enable ADC1 clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
/* ADC1 Configuration -----------------------------------------------------*/
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfConversion = 1;
ADC_Init(ADC1, &ADC_InitStructure);
ADC_ClearITPendingBit(ADC1, ADC_IT_AWD);
/* ADC1 regular channel0 configuration */
ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_4Cycles);
/* Configure channel0 as the single analog watchdog guarded channel */
ADC_AnalogWatchdogSingleChannelConfig(ADC1, ADC_Channel_0);
/* Configure high and low analog watchdog thresholds */
ADC_AnalogWatchdogThresholdsConfig(ADC1, MAC_HIGHER_THRESHOLD, MAC_LOWER_THRESHOLD);//0x16E
/* Enable analog watchdog on one regular channel: channel0 */
ADC_AnalogWatchdogCmd(ADC1, ADC_AnalogWatchdog_SingleRegEnable);
/* Enable AWD interrupt */
ADC_ITConfig(ADC1, ADC_IT_AWD, ENABLE);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Wait until the ADC1 is ready */
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_ADONS) == RESET)
{
}
/* Start ADC1 Software Conversion */
ADC_SoftwareStartConv(ADC1);
问题:1> ADC模拟看门狗只能在调用初始化时,能够正常的转换电压(接的是3.3V,DR值为0xFFF),也能够正常的产生看门狗中断;但是初始化完成后当我将对应的管腿接到GND上后,发现DR的值还是0xFFF。再重新将对应的管腿接到3.3V上,DR当然还是0xFFF,但是却再也不会产生看门狗中断。
2> 若我在初始化时将管腿直接接到GND上,也能够正常的转换当然也不会产生中断;但是当我把对应的管腿接到3.3V时,DR值依旧是0,也不会产生中断?
劳烦各位帮忙看看是什么问题? |