当开启PA0外部中断,ADC,DMA传输采样,PA4脚串联电阻拉低,会一直PA0外部中断,PA4脚上的ADC采样时间低于等于7.5周期才不会一直误中断,这难道是BUG吗? switch (s){ case Tmp_Samp: { ADC_Channels = 5;//通道数 ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; 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 = ADC_Channels;//指定多少通道转换 ADC_Init(ADC1, &ADC_InitStructure); /* ADC1 regular channels configuration [规则模式通道配置]*/ ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_55Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 2, ADC_SampleTime_55Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 3, ADC_SampleTime_55Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 4, ADC_SampleTime_55Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 5, ADC_SampleTime_55Cycles5); ADC1_1 = TRUE; ADC1_2 = TRUE; ADC1_5 = TRUE; ADC1_6 = TRUE; ADC1_7 = TRUE; break; } case Pwr_Samp: { ADC_Channels = 2;//通道数 ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; 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 = ADC_Channels;//指定多少通道转换 ADC_Init(ADC1, &ADC_InitStructure); /* ADC1 regular channels configuration [规则模式通道配置]*/ ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 1, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 2, ADC_SampleTime_7Cycles5); ADC1_3 = TRUE; ADC1_4 = TRUE; //ADC_Channels = 2;//通道数 break; } default: break; } /* Enable ADC1 DMA */ ADC_DMACmd(ADC1, 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)); /* Enable DMA1 channel1 */ DMA_Cmd(DMA1_Channel1, ENABLE); /* Start ADC1 Software Conversion */ ADC_SoftwareStartConvCmd(ADC1, ENABLE); 下面是配置的中断,因PA4下拉引起一直中断 void SW_Init(void) { EXTI_InitTypeDef EXTI_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; /* Enable ADC1 and GPIOC clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //PA0中断输入 //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//GPIO_Mode_IPU;// GPIO_Init(GPIOA, &GPIO_InitStructure); /* Enable the RTC Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /*将EXTI线0连接到PA0*/ GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource0); /*配置EXTI线0上出现下降沿,则产生中断*/ EXTI_InitStructure.EXTI_Line = EXTI_Line0; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); EXTI_GenerateSWInterrupt(EXTI_Line0); } |
RE:stm32f100c8t6b,ADC-DMA,PA4采样时间过高引发误中断
RE:stm32f100c8t6b,ADC-DMA,PA4采样时间过高引发误中断