2012-11-13 12:25 PM
Hi, I have enabled external interrupt (EXTI) by connecting to pin PA4 a button, with its pull-up (I also tried the pull down) but when I pressed the button sometimes is performed twice Iterrupt routine (or more times)! I think it's a problem of dimensioning of the resistors, There has never happened to you? and how you solved it? maybe it's because I neglect the resistance offered by pin PA4, can you tell me that resistance have the pin or what is the average current consumption of the pin?
the code I used is://EXTI CONFIG
void Exti_Config(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable GPIOA clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
/* Enable SYSCFG clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* Configure PA0 pin as input floating */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Connect EXTI Line0 to PA5 pin */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource4);
/* Configure EXTI Line0 */
EXTI_InitStructure.EXTI_Line = EXTI_Line4;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;//EXTI_Trigger_Rising; Falling
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Enable and set EXTI Line0 Interrupt to the lowest priority */
NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
//Interrupt routine
void EXTI4_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line4)==SET)
{
/* Clear the EXTI line 0 pending bit */
EXTI_ClearITPendingBit(EXTI_Line4);
k=k+1;
STM_EVAL_LEDOn(LED4);
}
if(k==2){
STM_EVAL_LEDOff(LED4);
k=0;
}
}
2012-11-13 12:36 PM
You can add little delay inside interrupt, so even if you have second trigger , it will be ignored.
or use RC for that pin, add capacitor so it will filter your key voltage I use 1K 0.1uF and trigering on falling edge with no problem2012-11-13 12:41 PM
Sounds more like an issue with contact bounce than with the resistor.
To get a clean pulse consider a mono-stable circuit.There has never happened to you? and how you solved it? I think people have been encountering this since they start connecting switches to circuits, and later computers.2012-11-13 09:04 PM
2012-11-14 05:51 AM
Hi,
I had the same problem yesterday on my prototype board. I have 8 push buttons and rotary encoder. Although i have software debounce routines, connecting anything to the GND of the board was causing random buttons or phases of the encoder to be triggered. 10 - 33 nF capacitors to GND on each input fixed it well. BR2012-11-14 08:32 AM
thanks for all your advice, in fact, the problem is on the rebound, and I solved it by using a low pass filter or by using a flip flop!