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

Thread: How do I software reset the Teensy 3.6?

  1. #1
    Member
    Join Date
    Dec 2016
    Location
    Buena Park ca
    Posts
    97

    How do I software reset the Teensy 3.6?

    I found the commands that supposedly work on the 4.0 but they do nothing for the 3.6.

    I am triggering the reset by a serial command

    HTML Code:
      if (Serial5.available()) { // Read intstructions from Win 10 tablet
    
     if  (First == 'R')
        { Serial.println (" RESETTING TEENSY");
         #define CPU_RESTART_ADDR (uint32_t *)0xE000ED0C
        #define CPU_RESTART_VAL 0x5FA0004
        #define CPU_RESTART (*CPU_RESTART_ADDR = CPU_RESTART_VAL);
        }
    I get the message " RESETTING TEENSY" but the teensy does not restart.
    I would know from all the calibration messages that my attach MPU9250 is sending me when I power up.

    Thanks

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,104
    Well of course that won't work. You've added 3 defines which create the ability to reboot, but you haven't actually used them, only defined them.

    Also, we generally ask on this forum that you show a complete program. We can help much better when the problem is reproducible. If you have a large program, that usually means creating a small one with just the problematic part.

    For example, here's a complete program I tried just now on a Teensy 3.6. It absolutely does work. Just open the serial monitor, type anything in the top and click "Send". The USB disconnects and the LED blinks, then the serial monitor reestablishes a connection when Teensy comes back up.

    Code:
    void setup() {
      pinMode(13, OUTPUT);
      digitalWrite(13, HIGH); // flash LED at startup
      delay(500);
      digitalWrite(13, LOW);
    }
    
    #define CPU_RESTART_ADDR (uint32_t *)0xE000ED0C
    #define CPU_RESTART_VAL 0x5FA0004
    #define CPU_RESTART (*CPU_RESTART_ADDR = CPU_RESTART_VAL)
    
    void loop() {
      if (Serial.available()) {
        CPU_RESTART;
      }
    }

  3. #3
    Junior Member
    Join Date
    Jan 2018
    Posts
    5
    #define is a so-called preprocessor directive. What that means is that before compiling your program, the preprocessor goes through and replaces one set of text characters with a different set of text characters everywhere in your source code following the #define. It doesn't actually leave anything behind in the source file where the #define is located. The line

    #define NAME Bob

    goes through your source code and everywhere it finds "NAME" it replaces it with "Bob". Then it deletes the line starting with #define from your source code.

    So, what you need to do is put all three of the #define lines somewhere near the top of your .ino file. Then, where you have the #define lines now, place the following text:

    CPU_RESTART

    (notice a semicolon is not needed because it's in the #define line, though it won't hurt if you add another one.)

    I haven't verified that the numbers assigned to CPU_RESTART_ADDR and CPU_RESTART_VAL are the correct values for the MK66 used in the Teensy3.6. I'm going to guess you found the code snippet somewhere on the web... it might have been meant for an earlier Teensy. I believe it should still work with the T3.6, but the _ADDR and _VAL values might need to be changed.

  4. #4
    Member
    Join Date
    Dec 2016
    Location
    Buena Park ca
    Posts
    97
    Thanks a lot , that worked

Posting Permissions

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