Designed a own PCB and a button doesn't work

Hi,

I wired a button in pull-down mode at PA13 of a SAMD21 chip.

I can read the status of the pin which works. When pushing the button Serial.print returns "1" and when not "0".
So the wiring and pin mapping seems correct.

However since weeks I couldn't figure out a strange behaviour with one library:

I need to put it to sleep and wake it on Porta 13.

I would be very grateful if anyone know a solution to this

That's my test code which doesnt wake up

#include "Arduino.h"
#include "ArduinoLowPower.h"

#define ENCODER_BUTTON 43    // PA13, physical IC PIN 22

volatile int i = 0;

void setup() {
  Serial.begin(115200);
  pinMode(ENCODER_BUTTON, INPUT);

  Serial.println("Start");
  LowPower.attachInterruptWakeup(ENCODER_BUTTON, encoder_int_func, RISING);
}


void loop() {
  delay(500);
  LowPower.sleep();
  Serial.print(i); Serial.println(digitalRead(ENCODER_BUTTON));

}

void encoder_int_func() {
  i = 1;
  Serial.println("encoder_int_func");
}

That's my variant.cpp

// 43 .. 46 - EDBG/Digital
  { PORTA, 13, PIO_PWM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), No_ADC_Channel, PWM0_CH5, NOT_ON_TIMER, EXTERNAL_INT_13 }, // EIC/EXTINT[13] *TCC2/WO[1] TCC0/WO[7]
  { PORTA, 21, PIO_PWM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), No_ADC_Channel, PWM0_CH7, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // Pin 7
  { PORTA,  6, PIO_PWM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), No_ADC_Channel, PWM1_CH0, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // Pin 8
  { PORTA,  7, PIO_PWM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), No_ADC_Channel, PWM1_CH1, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // Pin 9

I think your code is a bit mixed up.

You want the LowPower.sleep(); to be at the end of your loop, after the Serial.print

Also The official code says: // Remember to avoid calling delay() and long running functions since this functions executes in interrupt context
So i don't feel like the encoder_int_func() should have the call to the Serial.print Although that shouldn't cause these problems.

What output do you get after switching the things around like that?