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

Thread: Looking for code to do a software restart with the Teensy LC

  1. #1
    Member
    Join Date
    Jun 2015
    Location
    Oakdale, CT
    Posts
    37

    Looking for code to do a software restart with the Teensy LC

    First, I have to say the the prjc.com site has a lot of documentation for their products. However, after reading the programming manual for Freescale MKL26Z64, I am confused. The manual says a software restart can be done. The problem is the manual refers to another document for the ARM processor. I did do a Google search for information on "Teensy LC restart" without any luck.

    I am using this code for the same function with Teensy 3.1:
    Code:
    #define SCB_AIRCR (*(volatile uint32_t *)0xE000ED0C) // Application Interrupt and Reset Control location
    
    void softRestart(int pinUsed) {
      int test1 = HIGH;
      int test2 = LOW;
      test1 = digitalRead(pinUsed);
      delay(100); //for debounce
      test2 = digitalRead(pinUsed);
      if ((test1 == test2) && (test1 == LOW)) {
        delay(1000); //allow human to release button
        Serial.end();  //clears the serial monitor  if used
        //turn off serial for restart, it will be properly turned after restart with IDE serial monitor
        //However, microcom and putty serial connection is killed after restart with or without serial.end()!
      SCB_AIRCR = 0x05FA0004;  //write value for restart
      }
    I suspect the same code could be used, but, with a different register location and value. Thank you in advance for any help on this one.

    Enjoy Life, Greg
    Live Well, Laugh Often, Love Much

  2. #2
    Senior Member
    Join Date
    Aug 2013
    Location
    Gothenburg, Sweden
    Posts
    295
    SCB->AIRCR or simply try NVIC_SystemReset(void)

  3. #3
    Member
    Join Date
    Jun 2015
    Location
    Oakdale, CT
    Posts
    37
    Thanks, mlu! I will try NVIC_SystemReset(void). It seems the easier approach.

    Enjoy life, Greg
    Live Well, Laugh Often, Love Much

    Try the NVIC_SystemReset(void) and got a compilation error of "not in scope". This must be a library call, but, what library?
    Last edited by GregM; 07-14-2015 at 07:02 PM. Reason: additional information

  4. #4
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,828
    Somewhere in these forums, there are other/different solutions to doing a software reset on the Teensy 3.1. May work too for the LC, or with small changes.
    It didn't use the NVIC-direct mechanism.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,298
    You're really not getting any results with "SCB_AIRCR = 0x05FA0004;" ??

  6. #6
    Member
    Join Date
    Jun 2015
    Location
    Oakdale, CT
    Posts
    37
    Thank Paul, for the confirmation that "SCB_AIRCR = 0x05FA0004;" should work. After checking the connections and re-doing them, it now works. It is not as fast as with the Teensy 3.1, I may have to change something in the code. But, it does work. Thank you to all for the help. Maybe now, I can do something useful.

    Enjoy Life, Greg
    Live Well, Laugh Often, Love Much

  7. #7
    Member
    Join Date
    Jun 2015
    Location
    Oakdale, CT
    Posts
    37

    Follow Up, Found Post with Information

    I was looking for some other information and found this post with Teensy Tips and Tricks:https://forum.pjrc.com/threads/25395...ips-and-Tricks

    It has provides a link to for a restart code. This is a compiler macro :
    Code:
    #define RESTART_ADDR       0xE000ED0C
    #define READ_RESTART()     (*(volatile uint32_t *)RESTART_ADDR)
    #define WRITE_RESTART(val) ((*(volatile uint32_t *)RESTART_ADDR) = (val))
    To restart the program, one calls this in code:
    Code:
    WRITE_RESTART(0x5FA0004);
    I have tried this and it does work with my projects. The referenced post with the tips and tricks has a lot of good information. I hope this is a help to someone.

    Enjoy life, Greg
    Live Well, Laugh Often, Love Much

  8. #8
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    329
    I have the same question for teensy 4. I've tried various things and they all lock up the processor, but it's doesn't come back up.

    My vote is for a reboot() to be written and supported for all teensy MCUs.

  9. #9
    Quote Originally Posted by jonr View Post
    I have the same question for teensy 4. I've tried various things and they all lock up the processor, but it's doesn't come back up.
    I'm also having the same experience on teensy 4, any advice on who to reboot/reset teensy4?

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,298
    Quote Originally Posted by manatee View Post
    any advice on who to reboot/reset teensy4?
    The soft reboot bug was recently fixed. Just update to 1.50-beta1, and then you can use SCB_AIRCR to reboot Teensy 4.0.

    https://forum.pjrc.com/threads/59297...no-1-50-Beta-1

  11. #11
    Senior Member
    Join Date
    Apr 2019
    Posts
    158
    is there a hard and a soft reboot ?

    which one is _reboot_Teensyduino_()

Posting Permissions

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