Multiple Interrupts Mask

Generic boards that are not Maple or Maple mini clones, and don't contain the additional USB reset hardware
Post Reply
Posts: 7
Joined: Tue Jan 17, 2017 4:15 pm

Multiple Interrupts Mask

Post by gasparobr » Wed Aug 30, 2017 10:34 pm

I'm trying to enable to PORTS (same interrupt line) to call the same function using interrupt.

I tried to do this code, but just the last interrupt work. Any one have any clues about how can I handle it?

Code: Select all

int led = PB0;
int but = PE3;
int but2 = PF3;
volatile int bLED = LOW;

void interruptFunction() 
  bLED = !bLED;

void setup() {
   pinMode(led, OUTPUT);

   attachInterrupt(but, interruptFunction, CHANGE);
   attachInterrupt(but2, interruptFunction, CHANGE);  // <== JUST THIS WORK. IF I DELETE IT THE 'but' WORK.

void loop() {

Posts: 1607
Joined: Mon Apr 27, 2015 12:12 pm

Re: Multiple Interrupts Mask

Post by victor_pv » Thu Aug 31, 2017 2:42 am

It's the way the MCU works. Only one pin of the same pin number can have external interrupts enabled.

You can use interrupts with either PE3 or PF3, but not both at the same time.

If you want all the details, I advice you to check the reference manual for MCU in the section regarding EXTI, that will you all the litle nasty details. There is a register to check what Port a certain line will connect too, 4 bits per line. For example for line 3 (the one you want to use) you can only enter a binary number representing a port (Port E for example), when you try to enable in Port F pin 15, the binary code for port F is writen in the same bits, so overwrites the setting you entered before for Port E. End result, it's only possible to enable 1 port for each line at any given time.

User avatar
Posts: 6726
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia

Re: Multiple Interrupts Mask

Post by RogerClark » Thu Aug 31, 2017 7:49 am


I presume that you are not really calling the same function on both pins as that would also be pointless.

Posts: 103
Joined: Wed May 11, 2016 4:29 pm

Re: Multiple Interrupts Mask

Post by dannyf » Thu Aug 31, 2017 12:24 pm

You are seeing the most retarded design across the whole stm products. There can be only one pin interrupt for a given pin number across all ports.

Whoever designed that is really talented in ruining an otherwise great product family.

User avatar
Posts: 1502
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Multiple Interrupts Mask

Post by Pito » Thu Aug 31, 2017 5:48 pm

You still may use an 8259A :) or a chain of it..
Pukao Hats Cleaning Services Ltd.

Post Reply