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

Thread: Odd request...How can i lock up a teensy 3.2?

  1. #1

    Odd request...How can i lock up a teensy 3.2?

    All,

    My elaborate telemetry system is working like a million bucks--most of the time. Most times is works w/o any issues but on occasion it will lock up, but I have not way to test, debug or reproduce. My loop displays measured data every second, saves to SD, and a few other things.

    I'm thinking a watchdog timer will do the trick. If code stops running, hopefully the WDT will restart the whole thing. I found this code

    Code:
    
    in setup
      // Setup WDT
      noInterrupts();                                         // don't allow interrupts while setting up WDOG
      WDOG_UNLOCK = WDOG_UNLOCK_SEQ1;                         // unlock access to WDOG registers
      WDOG_UNLOCK = WDOG_UNLOCK_SEQ2;
      delayMicroseconds(1);                                   // Need to wait a bit..
    
      // for this demo, we will use 1 second WDT timeout (e.g. you must reset it in < 1 sec or a boot occurs)
      //7.2mhz will require WDT reset < 1 second
      //WDOG_TOVALH = 0x006d;
      //WDOG_TOVALL = 0xdd00;
      
      // Kris I want make timer to reboot over 1 second, maybe this is the correct way to do this
      WDOG_TOVALH = 0x0098;
      WDOG_TOVALL = 0x9680;
    
      // This sets prescale clock so that the watchdog timer ticks at 7.2MHz
      // Kris, no clue what this is but leaving it alone
      WDOG_PRESC  = 0x400;
    
      // Set options to enable WDT. You must always do this as a SINGLE write to WDOG_CTRLH
      WDOG_STCTRLH |= WDOG_STCTRLH_ALLOWUPDATE |
                      WDOG_STCTRLH_WDOGEN | WDOG_STCTRLH_WAITEN |
                      WDOG_STCTRLH_STOPEN | WDOG_STCTRLH_CLKSRC;
      interrupts();
    
    
    
    in my loop
    
      if ((CurrentTime - UpdateTime) >= Update ) {
    
        noInterrupts();                                     //   No - reset WDT
    // kris not sure what this does but it actually works just fine
        WDOG_REFRESH = 0xA602;
        WDOG_REFRESH = 0xB480;
        interrupts();
     ...
    }

    The code implemented in setup and loop work fine, if I comment out the code in the loop, my Teensy 3.2 will restart -- this *may* simulate a lock up since the WDT is not getting reset.

    I would like to simulate a real lockup to see if this code actually restarts, Anyone know how to lock up a Teensy 3.2? Maybe by accessing some null pointer, divide by zero, something?


    Thanks in advance.

    Kris

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,229
    While it was meant for testing fault recovery on Teensy 4, maybe the myFault examples can help give you some ideas?

    https://github.com/PaulStoffregen/MyFault

  3. #3
    Paul,

    You are my hero!

    I added the code below to trigger after a certain measurement. I totally locked up my Teensy, and it automatically restarted using the watchdog timer code.


    uint32_t *y = 0;
    y[0] = 5;

    Thanks for the near immediate reply,

    Kris

Posting Permissions

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