10 years, 1 month ago.

Attaching interrupt to pins other than PC_13

I am not understanding the behavior of my F401RE. The following code:

#include "mbed.h"

DigitalOut  my_led(LED1);
InterruptIn my_button(PC_13); // Button
//InterruptIn my_button(PC_9); 

int presses = 0;

void pressed()
{
    presses++;
}

int main()
{
    my_led=1; // let me know main() is running
    wait(0.5);
    my_led=0;
 
    my_button.mode(PullUp);
    my_button.fall(&pressed);
    
    while (1) {
        for(int i=0; i<presses; i++) {
            my_led=1;
            wait(0.2);
            my_led=0;
            wait(0.2);
        }
        wait(0.5);
    }
}

This code works as expected. After reset is released, the board LED lights briefly, and then blinks once for each time the user button is pressed.

However, if I uncomment the assignment of the interrupt to PC_9 (and obviously comment out the assignment to PC_13), Nothing happens. I have a physical 1k pullup resistor on PC_9. The LED never lights to tell me main() has started, and never blinks no matter how many times I press a button to short PC_9 to GND.

I've tried this same experiment on a few pins - PC_8, PC_7, and some more I don't remember. The interrupt only seems to work properly on PC_13. What am I missing?

Thanks in advance.

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F401RET6 microcontroller.

i`ve tried too some pins including PC_5, PA_5, and few others, and i use printf() function to uart and on screen I get this message "InterruptIn error: pin not supported" and that`s all, but when I change to PC_13 i can see the program works nicely . any help? Thanks

posted by Eduard Soltuzu 01 May 2014

1 Answer

10 years, 1 month ago.

The pins shown here as intin can be used as interrupt in: https://mbed.org/platforms/ST-Nucleo-F401RE/

Yes it is known way more pins could be interruptin with proper code, no it isn't known when it will be done.

Accepted Answer

I looked at (and printed out) that diagram, and somehow never absorbed what "int. in" meant. Thank you for a quick and helpful response!

posted by Jim Wagner 01 Mar 2014

As Jim noted - I also cannot find any reference to intin in the pinout diagram - can you help? Thanks

posted by David Russ 07 Apr 2014

That's not what Jim noted, he missed it at first ;). But I see the pinout diagram was changed, and references to intin removed.

I think because meanwhile the code was updated, and now pretty much every pin should support interruptin. I *think*, but since I dont have one myself I never looked too much into it, that the limitation is that you can only have one interruptin per pin number (if you still want it to function properly). So if you make PC_5 an interrupt, you can not make PA_5 also one.

posted by Erik - 07 Apr 2014