This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

External Interrupt Problem.

Hi, I'm trying to get an External Interrupt from my User Button (PB7) on the board (MCBSTM32C). I'm using a sample code i found from the web called; stm32_exti. Even if I clear the interrupt pending bit, I only get the interrupt from the button once. How can i make my program has interrupts anytime i hit the button. Thanks..

The code's like this;

/*---------------------------------------------------------------------------- EXTI9..5 Interrupt Handler for USER button connected to GPIOB.7 *----------------------------------------------------------------------------*/
void EXTI9_5_IRQHandler(void)
{ if (EXTI->PR & (1<<7)) // EXTI0 interrupt pending? { EXTI->PR |= (1<<7); // clear pending interrupt

if ((ledExti ^=1) == 0) GPIOE->ODR &= ~(1 << (ledPosExti+8)); // switch off LED else GPIOE->ODR |= (1 << (ledPosExti+8)); // switch on LED }
}

Parents
  • If the code is really like this:

    /*---------------------------------------------------------------------------- EXTI9..5 Interrupt Handler for USER button connected to GPIOB.7 *----------------------------------------------------------------------------*/
    void EXTI9_5_IRQHandler(void)
    { if (EXTI->PR & (1<<7)) // EXTI0 interrupt pending? { EXTI->PR |= (1<<7); // clear pending interrupt

    if ((ledExti ^=1) == 0) GPIOE->ODR &= ~(1 << (ledPosExti+8)); // switch off LED else GPIOE->ODR |= (1 << (ledPosExti+8)); // switch on LED }
    }

    then it's hardly surprising that it doesn't work!

    There are specific instructions right above where you typed your message that clearly tell you how to post source code:
    www.danlhenry.com/.../keil_code.png

    If you missed those instructions, it is quite possible that you also missed some important details on that web page where you found the code.

    Therefore, I suggest that you go back to that web page where you found this code, and read it again carefully to see if it also has some important information that you missed...

Reply
  • If the code is really like this:

    /*---------------------------------------------------------------------------- EXTI9..5 Interrupt Handler for USER button connected to GPIOB.7 *----------------------------------------------------------------------------*/
    void EXTI9_5_IRQHandler(void)
    { if (EXTI->PR & (1<<7)) // EXTI0 interrupt pending? { EXTI->PR |= (1<<7); // clear pending interrupt

    if ((ledExti ^=1) == 0) GPIOE->ODR &= ~(1 << (ledPosExti+8)); // switch off LED else GPIOE->ODR |= (1 << (ledPosExti+8)); // switch on LED }
    }

    then it's hardly surprising that it doesn't work!

    There are specific instructions right above where you typed your message that clearly tell you how to post source code:
    www.danlhenry.com/.../keil_code.png

    If you missed those instructions, it is quite possible that you also missed some important details on that web page where you found the code.

    Therefore, I suggest that you go back to that web page where you found this code, and read it again carefully to see if it also has some important information that you missed...

Children
No data