Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: Teensy 4.1 ON/OFF Pin Access/Use

  1. #1

    Teensy 4.1 ON/OFF Pin Access/Use

    "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?

  2. #2
    Member KD0RC's Avatar
    Join Date
    May 2019
    Location
    Colorado, USA
    Posts
    75
    Hi Neal,
    This thread should have the info you need.

    https://forum.pjrc.com/threads/65716...-in-the-middle

    Len

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,440
    There is this library that allows working with the On/Off :: github.com/FrankBoesing/T4_PowerButton

    The examples show usage - it was recently updated to catch and show FAULTS as well.

  4. #4
    Member KD0RC's Avatar
    Join Date
    May 2019
    Location
    Colorado, USA
    Posts
    75
    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

  5. #5
    Member KD0RC's Avatar
    Join Date
    May 2019
    Location
    Colorado, USA
    Posts
    75
    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

  6. #6
    Member KD0RC's Avatar
    Join Date
    May 2019
    Location
    Colorado, USA
    Posts
    75
    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
    }

  7. #7
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    7,936
    Quote Originally Posted by KD0RC View Post
    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)

  8. #8
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,440
    Quote Originally Posted by KD0RC View Post
    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:

    Quote Originally Posted by Frank B View Post
    The Arduino IDE does not provide such a function.

    In your program you can use

    SCB_AIRCR = 0x05FA0004;

  9. #9
    Member KD0RC's Avatar
    Join Date
    May 2019
    Location
    Colorado, USA
    Posts
    75
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •