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

Thread: Reboot Teensy programmatically ...

  1. #1

    Reboot Teensy programmatically ...

    Is there a safe way to do an intended reboot for my Teensy?
    I read a little and it sounds that all methods seem to be complicated, needing hardware changes and/or are prone to damage the Teensy even substantially.

    And - why is such a method NOT implemented so far?

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,907
    It certainly is available and implemented and posted widely ...

    Not indicated what Teensy is in use? There was an issue at some point - now resolved - with Teensy 4.0 - but for AVR Teensy there is a documented and posted solution.

    I found this for you: pjrc.com/threads/55429-Easy-Reset-from-Software

  3. #3
    OKay, I am currently using a Teensy 3.6.
    I know this posting and was searching for a more straightforward method.

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,907
    Code:
    #define CPU_RESTART_ADDR (uint32_t *)0xE000ED0C
    #define CPU_RESTART_VAL 0x5FA0004
    #define CPU_RESTART (*CPU_RESTART_ADDR = CPU_RESTART_VAL);
    This is pretty easy and should work given those three lines:

    Code:
          if ( 'r' == foo ) CPU_RESTART; // restart CPU

  5. #5
    Member
    Join Date
    Jan 2020
    Location
    Port Elizabeth
    Posts
    71
    This is what I do on the Teensy 4.0
    Code:
    void doReboot() {
      saveStatus();
      // send reboot command -----
      SCB_AIRCR = 0x05FA0004;
    }
    saveStatus() is my routine to save the machine state in a FRAM.
    This works for me.

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,907
    Quote Originally Posted by PDOS View Post
    This is what I do on the Teensy 4.0
    Code:
    void doReboot() {
      saveStatus();
      // send reboot command -----
      SCB_AIRCR = 0x05FA0004;
    }
    saveStatus() is my routine to save the machine state in a FRAM.
    This works for me.
    That is a cleaner example - where post #4 hard codes the value to a new #define :: #define SCB_AIRCR (*(volatile uint32_t *)0xE000ED0C) // Application Interrupt and Reset Control

    ... a simple search and found that one not using the #define.

  7. #7
    Junior Member
    Join Date
    Dec 2020
    Posts
    7
    Does this also work for teensy 4.1?

  8. #8
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,907
    Yes, it uses the same processor and responds the same way.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,080
    It works on all ARM Cortex-M processors.

Posting Permissions

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