XIAO SAMD21G with Arduino IDE, INPUT_PULLUP not working

I’m using SEEED board driver V1.8.5

I’ve found the PULLUP or PULLDOWN doesn’t seem to work:

  • pinMode( BUTTON, INPUT); with 5.1k physical pullup resistor ==> works.

  • pinMode( BUTTON, INPUT); w/o 5.1k pullup resistor ==> acts like open when button open, acts like input = 0 when button closed (to ground)

  • pinMode( BUTTON, INPUT_PULLUP); w/o 5.1k, doesn’t change with input (i.e. no response to an input of 1 or zero, when button open Vin = 3.2V)

  • pinMode( BUTTON, INPUT_PULLUP); with 5.1k, doesn’t change with input (same as above)

  • pinMode( BUTTON, INPUT_PULLDOWN); Reacts the same as INPUT_PULLUP. with or without a 5.1k pull down resistor.

I’ve only tested on input to date (D3). Have others experienced anything similar?
Thanks
John

/*

  The circuit:
  - SEEED XIAO SAMD21.

*/

#define BUTTON   D3   // aka PA11 and EXTINT[11]

volatile uint16_t ButtonCount = 10;

uint32_t startingMillis;
uint32_t now;

void setup()
{
  Serial.begin(57600);
  pinMode( BUTTON, INPUT);  // using 5.1k external pullup, see end of file
  attachInterrupt( digitalPinToInterrupt( D3) , EIC_11_Handler, FALLING );
}

void loop()
{
  // Simply prints out count every 5 seconds
  now = millis();
  if(startingMillis + 5000 < now){
    Serial.print("Count = ");
    Serial.println(ButtonCount);
    startingMillis = millis();
  }
}

void EIC_11_Handler(void) {
    ButtonCount = ButtonCount + 1;
}

// -- eoc ------------------------
/*
  pinMode( BUTTON, INPUT); with 5.1k physical pullup resistor ==> works.
  pinMode( BUTTON, INPUT); w/o 5.1k pullup resistor ==> acts like open when button open, acts like input = 0 when button closed (to ground)

  pinMode( BUTTON, INPUT_PULLUP); w/o 5.1k, doesn't change with input  (i.e. no response to an input of 1 or zero, when button open Vin = 3.2V)
  pinMode( BUTTON, INPUT_PULLUP); with 5.1k, doesn't change with input (same as above)

  pinMode( BUTTON, INPUT_PULLDOWN); Reacts the same as INPUT_PULLUP. with or without a 5.1k pull down resistor.

   https://forum.arduino.cc/t/input-pullup-not-working/1013306

*/

Try this.

//#define BUTTON   D3   // aka PA11 and EXTINT[11]
#define BUTTON   A3   // aka PA11 and EXTINT[11]

I have tried this.

#define PORT A3
void setup() {
  Serial.begin(115200);

  pinMode(LED_BUILTIN, OUTPUT);     // Yellow LED
  digitalWrite(LED_BUILTIN, HIGH);  // HIGH:OFF, LOW:ON

  pinMode(PORT, INPUT_PULLUP);

}
// Connect between PORT and GND to a switch.
void loop() {
  digitalWrite(LED_BUILTIN, digitalRead(PORT));
  Serial.println(digitalRead(PORT));
  delay(100);
}