10 years, 2 months ago.  This question has been closed. Reason: Problem Resolved

Interrupt on Nucleo

I have a working programme that I've written for the KL25Z that is triggered from a second KL25Z. I'm trying to convert if for use on the F401RE board but I can't get the interrupt callback to be triggered. I've tried several different ports that I'm defining as InterruptIn and I'm using a falling edge trigger.

I know with the KL25Z that Interrupts would only work on certain groups of ports is this the case with the Nucleo boards or isn't this capability supported yet?

Can you share a snippet of your code or at least what pins you have tried?

posted by Martin Kojtal 28 Feb 2014

Here is my test code, only the USER_BUTTON Works

Interrupt Test

#include "mbed.h"

DigitalOut myled  (LED1);

//InterruptIn kbdlatch(USER_BUTTON);                            //This works

//InterruptIn kbdlatch(PH_0);                                   //this Doesn't work
//InterruptIn kbdlatch(PB_9);                                   //this Doesn't work
InterruptIn kbdlatch(D0);                                       //this Doesn't work

// interrupt routine  triggered by falling edge of kblatch
void kbsend()
{
        myled=!myled;                                           //Toggle LED

}// End of interrupt routine

//Main code
int main()
{
    myled=0;                                                    //LED off
    kbdlatch.fall(&kbsend);                                     //Setup interrupt on kblatch falling

//  Main loop
    while (1) {                                                 //Do nothing this code is totally interrupt driven

    }                                                           //End of main loop
}                                                               //End
posted by David Bottrill 28 Feb 2014

1 Answer

10 years, 2 months ago.

Can't you get it to be triggered, or does it tell you that the pin doesn't support InterruptIn? (On a serial terminal).

Anyway, STM manuals are well hidden, but managed to find it in the end (at least of another one from the same family, but should be the same). The following pins can be used for InterruptIn:

switch (pin) {
        case PC_13: // User button
            irq_n = EXTI15_10_IRQn;
            vector = (uint32_t)&gpio_irq0;
            irq_index = 0;
            break;
        case PB_3:
            irq_n = EXTI3_IRQn;
            vector = (uint32_t)&gpio_irq1;
            irq_index = 1;
            break;
        case PB_4:
            irq_n = EXTI4_IRQn;
            vector = (uint32_t)&gpio_irq2;
            irq_index = 2;
            break;
        case PB_5:
            irq_n = EXTI9_5_IRQn;
            vector = (uint32_t)&gpio_irq3;
            irq_index = 3;
            break;
        default:
            error("InterruptIn error: pin not supported.\n");
            return -1;

The good news, if they add proper code according to the datasheet you can add an interruptin on every single input. Downside is that it seems to kinda lack registers to see which interrupt was triggered. What should be possible is an interruptin on every pin with a seperate number, so PA_1, PB2, PA3, PC4, etc. But currently the code cannot handle that...

Accepted Answer

silly me if I'd actually looked on the pinout diagram it shows these inputs labelled as "INT.IN" I simply hadn't spotted that, thanks for your help.

posted by David Bottrill 28 Feb 2014