On/Off Pin on Teensy 4.1

Davidelvig

Well-known member
I can can make this work on a free-standing T4.1 by grounding the On/Off pin to any of the main GND pins on the board.
~4 seconds - turn off
then momentary - turn on.

ON my custom carrier board, the OFF step works, but no the ON.
I do have the On/Off pin in a circuit with:
- a momentary switch
- a GPIO pin (16/A2) (for software-available shut-down)

I do have VUSB to VIN severed on this board
I note that an un-severed T41 does not have this problem.

What might be subverting my ON cycle?

Thanks!
 
Don't recall seeing this ... for some reason wondering about putting 3V on the vBat pin?

That remembers the On/Off state and cutting VIN from VUSB using 'other' supply may be hitting the voltage flow on startup issue?
 
I have a coin cell installed, and VBAT reads 3.17v when the system is On.

After successful shutdown (via On/Off pin grounding):
- On/Off pin reads 0.4v
- VBAT pin floats below 0.2v down to about 50mV

I've not measured these before.
I could share a schematic
Would that help?
 
schematic wouldn't help me :)

Seems the battery wouldn't last long if it is being pulled down to 0.2V? Either is has no capacity, or it is being shorted in this state?

What voltage is on GPIO pin (16/A2)?

Does this "(for software-available shut-down)" mean you are doing DigitalWrite on GPIO pin (16/A2) in software to go to the OFF state?

Seems Frank B aka @mcu32 did code on github that would allow this without using a physical pin ...
it allowed adjusting the time or ignoring the On/Off button press IIRC - so seems it could lead to self 'Off' as well.

This one? : github.com/FrankBoesing/T4_PowerButton
 
Last edited:
I clearly have the wrong CR2032 battery holder on this board. I'll need to rig an alternate connection for a coin cell for testing.
Stay tuned!

... minutes later...
OK, I rigged up the battery holder to deliver coin cell + to the VBAT pin.
The CR2032 reads 2.95 out of fat socket.
It reads 2.79 in the socket.
 
Last edited:
At least it seems the right 'bell rang' here for hopefully finding the issue and needing proper vBat power to hold state and also go back on.

Good luck!
 
Thanks for your help.
I need to create a simpler test system for using the On/Off button.
My current board is a "fail" in that circuit at the moment.
 
Bummer. It got testing on first Beta units for T_4.0 and 4.1 with PJRC Beta hardware breakout PCB's, so it is known to work.
And that linked Frank B library showed 2 years last github edit? So, it worked then and after as much as it was used.

Indeed, if you have a simple other Teensy just battery and switch {On/Off shorting} should see it work.

Seems I had reason to use On/Off at least once in some test in recent weeks/months and it worked. Beyond 'vBat power' required for 'On' - other details are forgotten. Seems the only other complication was 'VamPower' problem solved on T_4.0 - but that was a problem the other way around where no battery needed when UART Serial lines from second Teensy leaked enough current to keep that RTC low power circuit energized when not expected.
 
I'm sure the FAIL is in my circuit, and not likely a problem with the Teensy 4.1
I expect some fails... that's why I did the minimum order ;)

If I can get this to work (and I expect I will) it eliminates a chunk of hardware compared to my last board.
Fingers crossed!
 
OK, I've found the simple reproducible case (using Blinky example code).

The Teensy 4.1 On/Off pin works as expected if On/Off is not otherwise connected to any pin.

If I connect a GPIO pin to that On/Off pin, then grounding the On/Off pin turns the Teensy off as expected, but subsequent momentary grounding does not turn it back on.
I see that the connected GPIO pin holds the On/Off pin at a lower voltage in the "off" state.

My intent in connecting a GPIO (pin 16, in this case) was to allow hardware shutoff with a button and software shutoff with driving pin 16 LOW.

I will remove the On/Off-to-16 connection to keep the physical-switch-based feature working.

The software (inactivity timer in my case) needs to be implemented otherwise.

Thanks, @defragster, for the reference to @FrankB 's github
I've reviewed it, and the examples, but don't yet grok it.

What I want is to call a shut-down function when my device has not been moved for X seconds, and have the device re-startable with press of the same button used for grounding On/Off.

@FrankB, can you clarify for me how to set up and use T4_PowerButton for this?

By the way, this simple schematic represents what DOES NOT work... with a GPIO connected to On/Off.

TestTeensy41OnOffButton.jpg
 

Attachments

  • TestTeensy41OnOffButton.pdf
    13 KB · Views: 45
Went back to code by Frank==@mcu32 and made this:
Code:
// Software trigger Teensy 4.x OFF
// Power RTC vBat
// GND pin #14 : Instant OFF
// Wake to ON Restart with short of On/Off Pin

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(14, INPUT_PULLUP);
  while (!Serial) {}
  Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
  digitalToggleFast(LED_BUILTIN);
  delay(1500);
  Serial.print(" Teensy going to loop() ... ");
}
elapsedMillis aTime;
void loop()
{
  if (!digitalReadFast(14)) {
    Serial.print("\n\tPower Down Teensy ... Teensy OFF");
    delayMicroseconds(10); // Allow USB Print to pass
    [B]arm_power_down();[/B]
    delay(100);
  }
  if ( aTime >= 1000 ) {
    digitalToggleFast(LED_BUILTIN);
    aTime = 0;
  }
}

[B]FLASHMEM __attribute__((noreturn))
void arm_power_down() { // 2020 Frank Bösing :: T4_PowerButton
  SNVS_LPCR |= SNVS_LPCR_TOP; //Switch off now
  asm volatile ("dsb");
  while (1) asm ("wfi");
}[/B]

T:\T_Drive\tCode\T1062_OnOff\SoftwareOff\SoftwareOff.ino Aug 14 2023 20:43:15
Teensy going to loop() ...
Power Down Teensy ... Teensy OFF
 
Last edited:
That solves going to OFF with a user Button.

Using the same button to go ON from Sleep likely to have the same problem.

Not sure there is a way around that - would need a button to GND the On/Off to wake the Teensy.

If total OFF wasn't needed could use a WFI and wake on a press of the pin - but that would take more power.
 
Oh my goodness! It solves it all for me!
- I disconnected pin 16 from On/Off and the push-button on-off works as expected with 5-second off and 1/2 second on.
- then I run your three lines of code at a time of my choosing...

Code:
if (myConditionIsMet) {
    SNVS_LPCR |= SNVS_LPCR_TOP; // Setting the SNVS_LPCR_TOP bit of the SNVS_LPCR register enables power off on the i.MX6SX
    asm volatile ("dsb");       // Data Synchronization Barrier - ensure that the subsequent ISB instruction is executed only after the write to the MPU Control Register is completed
    while (1) asm ("wfi");      // Wait For Interrupt
}
...and the Teensy turns off... ready to be turned back on by a 1/2-second push of the button.

I checked the power consumption in On and Off states
- 100mA when On
- 0.00 mA when off (the precision limits of my PowerJive USB power meter)

And bonus... I get a simpler schematic and an extra GPIO pin!

Brilliant!

I wish I was within range to buy you the beverage of your choice!
 
Great, glad that solves the problem with a cleaner and simpler solution.

I had not looked into the code presented - but seemed it must be in there, and there it was.

In OFF mode the consumed power will come from the vBat connection, not sure if having 5V input online passes through to save the battery in that state.

Thought of adding a test for PSRAM to see if it is kept alive - but that would have grown the example.
 
I think I tested the power with LiPo unplugged, and just USB. I’ll try again on LiPo only with an ammeter in line.
 
I think I tested the power with LiPo unplugged, and just USB. I’ll try again on LiPo only with an ammeter in line.

Quick test shows with vBat removed:: OFF state is maintained as long as USB power is present.
So vBat is optional as long as VIN is powered and there is retaining power sent from USB.
 
Got it. So some power from the coin cell (in my case) on VBAT keeps something in the MCU charged so that grounding On/Off can cause a startup (but only if there’s power at startup time on VIN to actually power a start up).

I have not worried about coin cell longevity before, assuming (with no rational basis) that it was years. Time will tell.
 
OK, with this and another thread, my conclusions are:
- the OnOff pin on the Teensy 4.1 is really cool! It allows me to eliminate a similar circuit from my daughterboard to provide push-button on-off.
- the function comes, not surprisingly, at a power cost (20-30 uA), drawing from the VBAT when off (Coin Cell in my case)
- with that all in place, and with devices intended to be in the field for years, I need to account for easier coin cell replacement if I use this feature.

Does that make sense, @defragster?
 
- on/off is cool
- other thread notes batt type and capacity ... bigger and smaller ... can be 1-2 years, depends on time off ... assuming no vBat drain when powered and On?
- batt replacement in field worthy consideration.
 
One more clarification/question before I consider enclosure redesign and battery selection:

- is it possible to get lower VBAT drain in any way and still get RTC?
- can I de-power the T41 board without using the OnOff function and achieve that?

(I don't have a way to measure uAmp currents)
 
is it possible to get lower VBAT drain in any way and still get RTC?
You could consider using one of these (RV-3028-C7). The current consumption is claimed to be down to 45nA.
I have just incorporated it into one of my designs, though not yet tested. PCBs due with me on Friday (15 Sept 2023), and its associated Rs and Cs into my own design.
Costs about $3 assembled from JLCPCB.
RTC-RV-3028-C7 Circuit1.png
 
Thanks, @BriComp!

That looks like it is fully stand-alone - i.e. with an embedded crystal. Is that your read? It would work with a just few R's and C's?

I've been perusing JLCPCB/parts and found this, though I think, while cheaper ($0.46) it requires a separate crystal.

... all the while hoping there is another way (lower-power configuration from the internal T41 RTC)
 
That looks like it is fully stand-alone - i.e. with an embedded crystal. Is that your read? It would work with a just few R's and C's?
Yes.
I've been perusing JLCPCB/parts and found this, though I think, while cheaper ($0.46) it requires a separate crystal.
You did not say what "this" is.
Be aware that with JLCPCB items can exist as a Basic Item or an Extended Item. If the latter they have to make changes to the system so charge circa $3. It's a cost of $3 for each different component from the Extended List.

If you need 5 off boards then the cost per board is $3/5 if you need 100 boards the cost per board is obviously $3/100 per board.

On one of my designs all the components initially came from the Extended list. I was able to reduce the costs by £24 by changing all but one component to come from the Basic list.
They have RTC's in the Basic List, but the advantage of the RV-3028 is it's extremely low current and High accuracy.
 
Back
Top