Skip to main content
SRees.2
Associate
November 23, 2022
Question

Wanting to use external interrupt to turn on internal led.

  • November 23, 2022
  • 6 replies
  • 1814 views

I am not wanting to use the HAL interface because I want to try and gain experience with the ARM bare metal programming. I have examples online and seem to be following them exactly but the led will not light up when a pin is pulled to ground. I measured the voltage on the pull up and do get voltage. The led will turn on if I put the code in the main while loop. I am using PB5 as the input.

    This topic has been closed for replies.

    6 replies

    S.Ma
    Principal
    November 23, 2022

    Use the debugger ans put a breakpoint in the exti interrupt routine. Check exri works alone, then check led.control. view the he registerd, edit them manually live to get a feel and learn with fewer project rebuild cycles.

    SRees.2
    SRees.2Author
    Associate
    November 28, 2022

    Hello,

    Thanks so much for responding to my question. I've used the debugger and have checked the registers as I went through. All the registers are changing as expected with the exception of the NVIC. When I get to that point, I notice the SETENA and CLRENA both get a new value. When I pull the PB5 to zero volts nothing happens. If I use PB5 as a regular input and with the pull up and use an if statement, then the led will come on when the input is pulled to ground so I know I have my pin inputs and outputs set right. It's like the interrupt is just not enabled. Checking the PR5 bit it actually does change to 1 when I pull the PB5 low. Are there some additional settings or check boxes hidden away?

    S.Ma
    Principal
    November 28, 2022

    Older EXTI have only PR bit for falling edge. Newer ones have both. Without mentionning the STM32 code product name, answers will remain general.

    SRees.2
    SRees.2Author
    Associate
    November 28, 2022

    It's a STM32F303RE. I wonder if the HAL files are causing a problem. I may try and start an empty project and add only needed files. When I go to the graphic interface to see available interrupts it actually shows only to available, the exti15-10. I tried that one and still nothing happens.

    S.Ma
    Principal
    November 28, 2022

    Read in detail the EXTI chapter in the refmanual. Now EXTI does not generate 1 unique interrupt vector per pin, it is by group of pins. Pin 0,1,2,3 are usually 1 vector per pin, not the others... you will need to poll the PR bit to find the source.

    SRees.2
    SRees.2Author
    Associate
    November 28, 2022

    I only selected whichever interrupt I wanted with the IMR mask register. So only one pending interrupt will be triggered.