SAMD21G INPUT_PULLUP not working

A Seeed XIAO SamD21G board does not seem to work with the either INPUT_PULLUP nor INPUT_PULLDOWN.

IDE = 2.3.6
SEEED XIAO board v1.8.5

My test results: only one pin and only one board:

  • 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.

My test code; (note the XIAO was on a solderless breadboard with NOTHING else on but a 5.1k Resistor and a manual jumper for 1 and 0.

/*
  This example shows how to wake up the SAMD21 from sleep with an external interrupt
  This sketch will break the USB during normal operation.
  Double click the button contacts to enable bootloader mode for a new sketch.

  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_PULLDOWN);
  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.

*/
// --- eof --------------------------

I would leave the interrupt handling out of it completely for testing. First verify you can digitalRead(BUTTON) with expected results.

1 Like

What does Vin have to do with it?
Are you powering this via USB?
Pulldown will not work unless the button pin is connected to 3.3V. Forget about using pulldown.

I agree, that test along with a different input and a different board are only my schedule.

Of course.

Vin?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.