Teensy 4.1 ON/OFF Pin Access/Use

Neal

Well-known member
"On / Off Pin and Power Control" is mentioned at https://www.pjrc.com/store/teensy41.html. Is there a pad somewhere on the Teensy 4.1 PCB to access the ON/OFF connection to the microprocessor? I can't find it anywhere.

If a pad exists, has anyone successfully connected a pushbutton to it to accomplish a reset?
 
Thanks @defragster! I finally have a way to software reset the Teensy! I have been looking for this for a while so that people don't have to keep unplugging to reset the Teensy if they power cycle the connected SDR radio or have a glitch in their router. @FrankB - Nice library, thanks!
Len
 
It looks like there are 4 possible button hold down times for powering off the T4 - 5 sec, 10 sec, 15 sec or turn off the ability to power off using the on/off button. I am able to set these and they work as advertised, so all good from that perspective.

I was hoping for a shorter off time like 500 ms. Are these hold times pre set in the 1062 chip or can a register or flash mem location be set with arbitrary values? I don't know how this works, so I hope the question is rational...

Thanks, Len
 
Well, I found something very interesting. If I put these statements in setup, I get the elusive reset button! A push of the on/off button turns the T4 off and then right back on. If I set press_on_time to 50 ms or higher, then I get an on/off switch that uses short presses of the button. Now I can have a menu option to let users set the button as power on/off or reset. Is there any flaw in my thinking here? Will this be a reliable thing coded this way?

Code:
// configured an a reset switch
void NullCB() {}

void setup()
{
  set_arm_power_button_press_on_time(arm_power_button_press_on_time_0ms);  // 0 ms to hold power button for startup
  set_arm_power_button_callback(&NullCB);  // Immediate shut off from on/off button press
}

Code:
// configured an an on/off switch
void NullCB() {}

void setup()
{
  set_arm_power_button_press_on_time(arm_power_button_press_on_time_50ms);  // 50 ms to hold power button for startup
  set_arm_power_button_callback(&NullCB);  // Immediate shut off from on/off button press
}
 
Are these hold times pre set in the 1062 chip or can a register or flash mem location be set with arbitrary values? I don't know how this works, so I hope the question is rational...

Thanks, Len

Hi Len, If I remember correctly (It's been some time since I wrote this) the times are preset in the chip.
Maybe you want to look at the 3000+Pg Reference Manual? Quite possible that there is an option I did not realize.
(But I think the default values are pretty good)
 
Thanks @defragster! I finally have a way to software reset the Teensy! I have been looking for this for a while so that people don't have to keep unplugging to reset the Teensy if they power cycle the connected SDR radio or have a glitch in their router. @FrankB - Nice library, thanks!
Len

There is a software reset function FrankB just noted in this post:

The Arduino IDE does not provide such a function.

In your program you can use

SCB_AIRCR = 0x05FA0004;
 
Hi Frank, Yep, it looks like the times are preset as I look at your library code. The trick is that by using a null callback, you can cheat and get an immediate shutdown (can't remember where I found that tidbit). For many applications (most?) that is not desirable. But for mine, some folks are going to want that to be as quick as possible, some will be happy with the 500 ms shutdown hold.

The second part of the trick is that if I make the on time 0 ms coupled with the null call back, on and off are both effectively zero, so a touch of the button does an immediate shutdown followed by an immediate start up - voila... easy reset button! I will play around with it for a couple of days to be sure that contact bounce doesn't cause it to be unreliable. If it behaves itself, I will add some options in my app to allow folks to configure the behavior that they want (reset vs on/off, 5 sec vs immediate, etc).

defragster, I am using these functions from the power lib to power down and reset from within my app:
arm_reset();
arm_power_down();

They work great, and when I have the button wired in, I will have the best of both worlds, menu item or button. Two others have built this and a third is about to start and already the questions about a more graceful power control have been raised so thanks for the library and the help, it is all happening just in time!
Len
 
Hello Everyone,

I'm confirming some connections on a project. I have the ESP32 EN pin connected to pin 37 of a Teensy 4.1. When I shut the Teensy Down using the On/Off switch, I want to power down the ESP32 by pulling pin 37 low. The 5v will stay powered in this case so this is how I would turn off the ESP32 (EN to Low).

Does the power on/off button of the Teensy allow me to pull pin 37 low before shutting down? Will it stay low until the Teensy is powered back up? During power down mode are all IO pins floating? Or held low? Will I need some other circuit to make this work the way I envision?

Thank you,
Jay
 
Hello Everyone,

I'm confirming some connections on a project. I have the ESP32 EN pin connected to pin 37 of a Teensy 4.1. When I shut the Teensy Down using the On/Off switch, I want to power down the ESP32 by pulling pin 37 low. The 5v will stay powered in this case so this is how I would turn off the ESP32 (EN to Low).

Does the power on/off button of the Teensy allow me to pull pin 37 low before shutting down? Will it stay low until the Teensy is powered back up? During power down mode are all IO pins floating? Or held low? Will I need some other circuit to make this work the way I envision?

Thank you,
Jay

Seems the button press can be captured {see linked code in p#3) and the pin could be driven low before shutdown.

But only when the Teensy is powered and under program control can the button state be controlled or known. Outside of that - before startup/setup(), and when off, the pin will be floating versus driven high or low.

Seems a weak pulldown on pin #37 would work then the Teensy could set it high in setup() - and it should drop/stay low when the Teensy is off or otherwise not pulling it high.
 
Back
Top