Incompatible interrupt pins on Portenta H7

Hello, I am facing an issue with Portenta H7 which I cannot seem to solve. Basically I found some combinations of pins that I cannot use whithin the attachInterrupt() method simultaneously. Take this as an example (pins are defined using their port names and an underscore):

#define CHA1 PC_7 //corresponding to pin J2-63
#define CHA2 PJ_7  //corresponding to pin J2-64

void SetCHA1()
{
    digitalRead(CHA1);
}

void SetCHA2()
{
    digitalRead(CHA2);
}

void setup()
{
  attachInterrupt(CHA1, SetCHA1, CHANGE);
  attachInterrupt(CHA2, SetCHA2, CHANGE);
  
  pinMode(CHA1, INPUT_PULLUP);
  pinMode(CHA2, INPUT_PULLUP);
}

void loop() {}

If I push this code to my Portenta H7 and power it, then it immediately goes into an error blinking the red led (4x long and 4x short). Does anyone know why this is happening and what I can do to solve it?

Sorry, I have done very little with the Portenta H7. Bought one as well as the HAT shield to play with a couple of months ago.

I believe that this issue is very much related to another thread on the GIGA:

As I mentioned on the other thread, I though earlier I read something about this...
But could be wrong. :laughing:

Hi @matteolavitnicora. I found some useful information on the subject from one of the developers of the "Arduino Mbed OS Portenta Boards" platform here:

https://github.com/arduino/ArduinoCore-mbed/issues/789#issuecomment-1840246454

the Giga allows a maximum of 16 interrupts at the same time, and the coexistence is based on STM32 peculiar way of handling them (like, PA_0 will share the interrupt with PB_0 , PC_0 and so on). If you instantiate 2 interrupts on the same line the board will "crash" (report it as invaliud).
To associate pin name and pin number you can use this table ArduinoCore-mbed/variants/GIGA/variant.cpp at main · arduino/ArduinoCore-mbed · GitHub

That is about the GIGA, but should be relevant to the Portenta H7 as well. The Portenta H7 equivalent to the link in that comment is here:

https://github.com/arduino/ArduinoCore-mbed/blob/4.1.1/variants/PORTENTA_H7_M7/variant.cpp#L22-L225

1 Like