cancel
Showing results for 
Search instead for 
Did you mean: 

problem with the dimensioning of the resistors pull-up?

orn
Associate II
Posted on November 13, 2012 at 21:25

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;

}
}

5 REPLIES 5
linas2
Associate II
Posted on November 13, 2012 at 21:36

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 problem

Posted on November 13, 2012 at 21:41

Sounds more like an issue with contact bounce than with the resistor.

To get a clean pulse consider a mono-stable circuit.

http://www.patchn.com/index.php?option=com_content&view=article&id=59:debounce&catid=20:plc&Itemid=118

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.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
its
Associate II
Posted on November 14, 2012 at 06:04

clive is right.

I have the same issue when working on ATmega2560.

I have also tried a debouncing delay in interrupt routine, so that I can avoid multi contact issue of the switch, but even then I got two interrupts on a single push button. I didn't remember exactly how I solve the problem. but some things may help you

-use debouncer, It is  must.

-check your register setting either it is on level change OR edge trigger

-as a guess clear interrupt Flag and status FLAG bits of that PIN just before exiting the ISR.

M0NKA
Senior
Posted on November 14, 2012 at 14:51

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.

BR
orn
Associate II
Posted on November 14, 2012 at 17:32

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!