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


Well-known member

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

in setup
  // Setup WDT
  noInterrupts();                                         // don't allow interrupts while setting up WDOG
  WDOG_UNLOCK = WDOG_UNLOCK_SEQ1;                         // unlock access to WDOG registers
  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

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;

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.


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,