2021-03-10 09:16 PM
I am using STM8L152R8 development board. I have configured push button interrupt on Pin no. PG6. i required both edges interrupt . but interrupt is occurring on falling edge only .
Can you give any suggestion to this problem.?
can you suggest me any logic to trigger the interrupt on both edges though it is only occurring on falling ?
2021-03-20 03:50 AM
I experienced the same problem. The problem lies in having (global) interrupts enabled before setting EXTI_SetPinSensitivity. The next example does work with me:
static void EXTI_config(void)
{
GPIO_Init(GPIOE, GPIO_Pin_6, GPIO_Mode_In_PU_IT);
disableInterrupts();
EXTI_DeInit();
EXTI_ClearITPendingBit(EXTI_IT_Pin6); //to be absolutely sure
EXTI_SetPinSensitivity(EXTI_Pin_6, EXTI_Trigger_Rising_Falling);
enableInterrupts();
}
And the interrupt routine:
INTERRUPT_HANDLER(EXTI6_IRQHandler,14)
{
if (EXTI_GetITStatus(EXTI_IT_Pin6))
{
EXTI_ClearITPendingBit(EXTI_IT_Pin6);
exti_signal = 1;
}
}
2021-03-21 10:01 PM
thank you .
I will try it
thanks and regards
deoyani
2021-03-23 12:55 AM
Hello ,
I have tried the solution you have given me. It didn't work for me . continuous interrupt is coming.
Do you have any another solution .
I want to count how much time button is pressed ,using interrupt.
Please suggest me any solution.
thanks and regards
Deoyani
2021-03-23 06:54 AM
Hi Deoyani,
I can only guess, as I do not have the code but here are some suggestions. I assume your signal is connected to PG6 only.
Do you use EXTI on PIN-6 or on PORT-G? If I understand it correctly, when you use EXTI on PORT-G, any signal on any PIN of PORTG it will trigger an EXTI.
Do you have any other PIN6 (PA6, PB6... etc) in use? When you have a signal on, for instance PB6, it will also trigger an EXTI.
Wilko
2021-03-23 09:25 PM
Hello,
I have connected push button to PD6 and i have used EXTIpin6 handler .
Even if I have not touched to the button, interrupt is coming continuously.
I have configured the pin according to the post on st community . I am sending you the screenshot, please find the attachment.
I want both edges interrupt rising/falling . When i pressed the button i should get the count how much time i have pressed the button .
I want to enable the timer when interrupt occurs on falling edge and count should increase. and after releasing the button I should get count.
2021-03-24 04:13 AM
Hi Deoyani,
Next time you may want to use the "code-snippet" </> to show your code :grinning_face:
I have typed what I think you are doing into Notepad++. So here is what I think you are doing in main.
That looks okay to me although I think that the while loop will not do much, temp will perhaps be incremented once or twice. It looks like it was part of a timeout.
disableInterrupts(); //temporarily disable interrupts
GPIO_Init(GPIOE, GPIO_Pin_6, GPIO_Mode_In_FL_IT); //PE6 input, floating, interrupt
EXTI_SetPinSensitivity(EXTI_Pin_6, EXTI_Trigger_Rising_Falling); //EXTI6 on any edge
while (EXTI_GetPinSensitivity(EXTI_Pin_6) != EXTI_Trigger_Rising_Falling)
{ //you just set EXTI_Pin_6 to EXTI_Trigger_Rising_Falling
temp++; //so this will not do much
}
enableInterrupts(); //re-enable interrupts
And here is how I think your interrupt routine is made.
It seems that you clear the interrupt status and after that in the while loop you are checking if it is set!?
It probably will not be, at least not for very long.
@far @interrupt void EXTI6_IRQHandler(void) //unknown (for me) way of handling interrupts
{
uint16_t temp = 0; //not static so at every interrupt set to 0
EXTI_ClearITPendingBit(EXTI_IT_Pin6); //okay, clear interrupt status
while (EXTI_GetITStatus(EXTI_IT_Pin6) != RESET) //but, but, but, you just cleared it!
{
temp++;
}
}
What happens when you make the interrupt routine lke this.
And in main do something when exti_signal == 1 (don't forget to set it to 0 again)
@far @interrupt void EXTI6_IRQHandler(void)
{
if (EXTI_GetITStatus(EXTI_IT_Pin6) != RESET)
{
EXTI_ClearITPendingBit(EXTI_IT_Pin6);
exti_signal = 1;
}
}
Something else... what have you done with all unused GPIO? Don't leave them floating, set them to input with a pull up. If I do not do that, often weird things happen.
2021-03-25 10:21 PM
Hello,
thank you for suggestion
I have implemented what you have sent to me.now its working good
thanks and regards
Deoyani
2021-03-26 02:05 AM
Good to hear, but what exactly made the change?
2021-03-26 02:41 AM
Hello,
main changes on hardware side .
and GPIO_Init(GPIOE, GPIO_Pin_6, GPIO_Mode_In_PU_IT); // I made it pull up not floating , this also the mistake .
thank you for your support
thanks and regards
Deoyani