Go Down

Topic: Fail to set interrupt on pins other than digital pins (Read 1 time) previous topic - next topic

kangyifeizx

Hi all,

I'm rather new to the Arduino scene so any help is very welcomed.
 
I have a home made Arduino Zero.The board have two buttons which connect to PB02(19 in Zero) and PB03(25 in Zero).I want to set interrupt on these buttons.

The button connected to PB02 successd,but the other failed.

In SAMD21G datasheet,I find PB02 belongs to EXTINT[2],and PB02 belongs to EXTINT[3],so they don't conflict.

The code following

Code: [Select]

#define btn1 19
#define btn2 25

volatile int status=0;

void setup(){
  pinPeripheral(19, PIO_EXTINT);
  pinPeripheral(25, PIO_EXTINT);
  attachInterrupt(19, btn1_press, FALLING);
  attachInterrupt(25, btn2_press, FALLING);
}

void loop(){
  while(status==1){
    dosomething();
  }
}

void btn1_press(){
  status=1;
}

void btn2_press(){
  status=0;
}

MartinL

Hi kangyifeizx,

The issue with the port pin PB03 might be due to the fact that it's also used by the Arduino Zero core as it native USB Rx LED output, in file "USBCore.cpp".

You could try commenting out the PIN_LED_RXL definition in the Zero's "variant.h" file:

Code: [Select]
//#define PIN_LED_RXL          (25u)

Go Up