Snooze Wake-up Recovery Times

BriComp

Well-known member
Snooze Wake-up Recovery Times - Edited Added Teensy4 Sleep Data

I have been looking at the time it takes for Snooze to wake-up on various Teensy. (What's the plural of Teensy?).

All this started when I found that I could NOT use a Teensy4 in a project because of the very long time (all relative ~4-7ms ) it took to wake-up from a snooze.
I was using a Radio UART device which wakes up from sleep when receiving a Radio Message, signals that event by sending a PIN LOW and 5ms later starts sending out to the Teensy (or whatever MCU) the Serial Data.

Unfortunately with Teensy4 the data will have gone by the time it has woken up.

My interest is in wake-up after a time period (1min) and upon a pin going low. I have set up a test bench with a Teensy feeding the Teensy under test with a LOW going (WAKEUP) wake up signal.
When the Teensy under test wakes up it Sets pin 13 HIGH followed immediately by setting pin 14 HIGH.

Using a cheapo Logic Analyser I have been looking at the time between the WAKEUP signal and pin 13 going HIGH. Also because there is frequent mention of the time that it takes between setting one pin, then another I have also noted the time difference for theses two events.

Because Compile Frequency Setting and Target Compile Speed etc may have an effect I have carried out the tests with these as variables.

I have found that Compiling for Different Speeds i.e. Fastest, Faster, Fast etc., there is very little effect upon the wake up time. However Compile Speed Setting (MHz) does have an effect upon the Wake-up time.

Below is a graph for all three Snooze settings (Sleep, DeepSleep and Hibernate) for the Teensys that I have so far tested. LC at Hibernate and DeepSleep return virtually the same timings.

Teensy Snooze Recovery Time.JPG

If I add Teensy4 to the results we have the following graph. All the plots in the bottom left hand corner are for the other Teensys (LC,3.1 and 3.5).
Teensy Snooze Recovery Time inc Teensy 4.JPG

Just carried out a Sleep test on Teensy4. Results with others below. Peculiar looking graph. Can't help but think there might be a problem!
Teensy Snooze Recovery Time inc Teensy 4.JPG
If you are interested in the Numeric results or the graphed data for the individual Teensys then just ask.
If the graphs are too small just click on them to enlarge.
 
Last edited:
Can you post the sketch(s) you used to get the times for the teensy 4? The T4 requires a lot of stages to get it any of the sleep modes so these times don't seem that off to me but I would have to look into more to see why.
 
Here is the code, below. I will put a snapshot of the results for T4.
The resolution of my capture device is only 41.66666ns. So when you see pin to pin times doubling from 42ns to 83ns it is down at the resolution of the Logic Analyser.

Teensy 4 sleep wake up time.JPG

Teensy 4 deepsleep wake up time.JPG

Code:
#include "Arduino.h"
#include <Snooze.h>

SnoozeDigital   snoozeDigital;
SnoozeTimer     snoozeTimer;

#if defined(__IMXRT1062__)
SnoozeUSBSerial SerialUsb;
#else
#define SerialUsb Serial
#endif

#if defined(__IMXRT1062__)
SnoozeBlock config_teensy40(SerialUsb, snoozeDigital, snoozeTimer ); //alarm);
#elif defined(__MK66FX1M0__)
SnoozeBlock config_teensy36(snoozeDigital, snoozeTimer);
#elif defined(__MK64FX512__)
SnoozeBlock config_teensy35(snoozeDigital, snoozeTimer);
#elif defined(__MK20DX256__)
SnoozeBlock config_teensy32(snoozeDigital, snoozeTimer);
#elif defined(__MK20DX128__)
SnoozeBlock config_teensy30(snoozeDigital, snoozeTimer);
#elif defined(__MKL26Z64__)
SnoozeBlock config_teensyLC(snoozeDigital, snoozeTimer);
#endif


int ipPin = 6;
int opPin =13;
int opPin2 =14;
int who = 0;
int restartSlavePin =  16;
int restartPin =  8;

void SetupSnooze(){
#if defined(__IMXRT1062__)
    snoozeTimer.setTimer(60);// seconds
#else
    snoozeTimer.setTimer(60000);// milliseconds
#endif
    snoozeDigital.pinMode(ipPin, INPUT_PULLUP, FALLING);//pin, mode, type
};   // SetupSnooze  

void setup() {

  pinMode(ipPin,INPUT_PULLUP);
  pinMode(opPin,OUTPUT);
  pinMode(opPin2,OUTPUT);
  pinMode(restartSlavePin,OUTPUT);
  pinMode(restartPin,INPUT_PULLUP);
  Serial.begin(9600);
  SetupSnooze();

}

void BlinkLed( int numBlinks ){
    int n;
    for (n=0; n<numBlinks; n++){
        digitalWrite(opPin,HIGH);
        delay(200);
        digitalWrite(opPin,LOW);
        delay(200);
     }
    delay(1000);

}

void loop() {
    int n = 0;
//    BlinkLed(10);
    digitalWrite(opPin,HIGH);
    digitalWrite(opPin2,LOW);
    digitalWrite(restartSlavePin,HIGH);
    SerialUsb.flush();
    delay(2000);
    digitalWrite(opPin,LOW);
  // put your main code here, to run repeatedly:
#if defined(__IMXRT1062__)
    who = Snooze.sleep( config_teensy40 );// return module that woke processor
#elif defined(__MK66FX1M0__)
    who = Snooze.sleep( config_teensy36 );// return module that woke processor
#elif defined(__MK64FX512__)
    who = Snooze.sleep( config_teensy35 );// return module that woke processor
#elif defined(__MK20DX256__)
    who = Snooze.sleep( config_teensy32 );// return module that woke processor
#elif defined(__MK20DX128__)
    who = Snooze.sleep( config_teensy30 );// return module that woke processor
#elif defined(__MKL26Z64__)
    who = Snooze.sleep( config_teensyLC );// return module that woke processor
#endif

    digitalWrite(opPin,HIGH);   //pin 13
    digitalWrite(opPin2,HIGH);  //pin 14
    Serial.begin(9600);
    delay(2000);  
    while(n<=2){
        if (who==-1) {
            BlinkLed(10);
        }
        else if (who==36) { //timer
            BlinkLed(1);
        }
        else if (who==4) {  // pin4
            BlinkLed(2);
        }
        else {
            BlinkLed(who  );
        }
        ++n;
    }
    digitalWrite(restartSlavePin,LOW);
    SerialUsb.println("Waiting for key press");
    SerialUsb.flush();
    delay(100);
    while (digitalRead(restartPin)==HIGH);
    SerialUsb.flush();
//    digitalWrite(restartSlavePin,HIGH);
}
 
@Paul etal, has any work been done on the Teensy 4 software infrastructure that may effect the POOR Teensy 4.0 Recovery from Sleep (DeepSleep) times (at least 10x longer than other Teensy's)?
Teensy 4 takes 5-7ms to wake up whereas other Teensys take circa 0.5ms.
 
Back
Top