Teensy 4.1 Power On/Off Help Requested

Hey all,

I have two buttons on my teensy 4.1 project that I'd like to merge to one. I got it mostly working, but I am having an issue I will detail below. First, here's their functionality:

Button 1: This is a record button to start logging data to a file on the SD card. I have is configured as follows:

Code:
  pinMode(REC_PIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(REC_PIN), ISR_ToggleLogging, RISING);

And some simple interrupt function:

Code:
  void ISR_ToggleLogging() {
      if ((millis() - lastPress) > debounceTime) {
        if (!isLogging) {
          Serial.println("STARTING LOGGER");
          StartLogging();
          isLogging = true;
          lastPress = millis();
        }
        else if (isLogging) {
        Serial.println("STOPPING LOGGER");
        QuitLogging();
        isLogging = false;
        lastPress = millis();
        }
      }
  }

Button 2: Power On/Off. I have the Power on/off pin (I'll call this Pof) that gets pulled to GND when the button is held down.

Here is a photo of the setup (sorry it's a bit of a rat's nest right now...)

wiring.jpeg

Goal: I am trying to combine these to one button. I connected the leads from D2 and Pof to the same rail which goes through the button to GND. The record button functionality works well, I have the interrupt set to RISING as well so that when you hold the button down for 5 seconds to power off the Teensy, that works too without triggering an unwanted record before power off. When I probe these for voltage, they are both around 3V.

BUT when the power is off, I cannot get the Teensy to turn back on in this configuration. I discovered that when I probe for voltage that Pof is at something like 0.4V. So something is amiss: this seems to obviously be due to the connection with D2 brining the voltage down when the power is off (when I disconnect D2 from Pof/button, the voltage goes back to 3V and I can power on again). Since D2 is configured with the pullup resistor I think it should default to high (~3V) when off? And Pof is normally 3V when the device is off and I probe it, but when they are connected -- I'm only getting 0.4V, so I suspect this drop from 0.4V to 0V when I hit the button to connect Pof to ground is not enough to trigger the device to turn back on.

Any thoughts on how to proceed? Changing something in the circuit, or firmware to get this to work? Ideally I can make this one button configuration work.

Thanks!
 
Back
Top