Unable to wake Teensy LC using Snooze

Status
Not open for further replies.

ErkelByte

Member
I'm having issues waking my teensy LC using the sleep_all_wakeups. I commented out all but the digital wakeups and added a serial output at the start of setup to make sure that the current code is running on the board. I manually connect pin 21 or 22 to the 3.3v pin. When I boot it, I manually unplug and replug that wire in order to create the rising edge. No luck. I have no idea what to do from here.

Code:
/***************************************
 This shows all the wakeups for sleep
 Expect IDD of  around 1.2mA (Teensy 3.x)
 and IDD of around 900uA for (Teensy LC).
 
 Sleep is the most flexable and any
 interrupt can wake the processor.
 
 Touch interface does not work in sleep
 mode.
 ****************************************/
#include <Snooze.h>
// Load drivers
SnoozeDigital digital;
SnoozeCompare compare;
SnoozeTimer timer;
SnoozeAlarm  alarm;
// configures the lc's 5v data buffer (OUTPUT, LOW) for low power
Snoozelc5vBuffer  lc5vBuffer;
/***********************************************************
 Teensy 3.6/LC can't use Timer Driver with either Touch or
 Compare Drivers and Touch can't be used with Compare.
 
 Teensy 3.x/LC touch interface does not work with sleep.
 
 Teensy LC does not have a rtc so Alarm driver can't be
 used as of yet.
 
 Teensy 3.2 can use any Core Drivers together.
 ***********************************************************/
#if defined(__MK66FX1M0__)
SnoozeBlock config_teensy36(digital, alarm, compare);
#elif defined(__MK64FX512__)
SnoozeBlock config_teensy35(digital, timer, compare);
#elif defined(__MK20DX256__)
SnoozeBlock config_teensy32(digital, timer, compare);
#elif defined(__MK20DX128__)
SnoozeBlock config_teensy30(digital, timer, compare);
#elif defined(__MKL26Z64__)
SnoozeBlock config_teensyLC(digital, timer, lc5vBuffer);
#endif

void setup() {
    Serial.begin(9600);
    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, HIGH);
    while(!Serial){}
    delay(100);
    digitalWrite(LED_BUILTIN, LOW);
    Serial.println("Started v1.0.8");
    delay(10000);
    
    /********************************************************
     Define digital pins for waking the teensy up. This
     combines pinMode and attachInterrupt in one function.
     
     Teensy 3.x
     Digtal pins: all pins
     
     Teensy LC
     Digtal pins: all interrupt able pins
     ********************************************************/
    digital.pinMode(21, INPUT_PULLUP, RISING);//pin, mode, type
    digital.pinMode(22, INPUT_PULLUP, RISING);//pin, mode, type
    
    /********************************************************
     Teensy 3.x only currently.
     
     Set RTC alarm wake up in (hours, minutes, seconds).
     ********************************************************/
    //alarm.setRtcTimer(0, 0, 10);// hour, min, sec
    
    /********************************************************
     Set Low Power Timer wake up in milliseconds.
     ********************************************************/
    //timer.setTimer(5000);// milliseconds
    
    /********************************************************
    In sleep the Compare module works by setting the
    internal 6 bit DAC to a volatge threshold and monitors
    the pin volatge for a voltage crossing. The internal
    DAC uses a 64 tap resistor ladder network supplied by
    VOUT33 at 0.0515625v per tap (VOUT33/64). Thus the
    possible threshold voltages are 0.0515625*(0-64). Only
    one compare pin can be used at a time.

    parameter "type": LOW & FALLING are the same and have no effect.
    parameter "type": HIGH & RISING are the same and have no effect.

    Teensy 3.x
    Compare pins: 11,9,4

    Teensy LC
    Compare pins: 11
     ********************************************************/
    // trigger at threshold values greater than 1.65v
    //compare.pinMode(11, HIGH, 1.65);//pin, type, threshold(v)
    // trigger at threshold values less than 1.65v
    //compare.pinMode(11, LOW, 1.65);//pin, type, threshold(v)
}

void loop() {
    int who;
    /********************************************************
     feed the sleep function its wakeup parameters. Then go
     to deepSleep.
     ********************************************************/
#if 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
    
    if (who == 21) { // pin wakeup source is its pin value
        while(true) {
            digitalWrite(LED_BUILTIN, HIGH);
            delay(200);
            digitalWrite(LED_BUILTIN, LOW);
            delay(200);
        }
    }
    
    if (who == 22) { // pin wakeup source is its pin value
        while(true) {
            digitalWrite(LED_BUILTIN, HIGH);
            delay(200);
            digitalWrite(LED_BUILTIN, LOW);
            delay(200);
        }
    }
    
    if (who == 34) { // compare wakeup value
        for (int i = 0; i < 3; i++) {
            digitalWrite(LED_BUILTIN, HIGH);
            delay(200);
            digitalWrite(LED_BUILTIN, LOW);
            delay(200);
        }
    }
    
    if (who == 35) { // rtc wakeup value
        for (int i = 0; i < 4; i++) {
            digitalWrite(LED_BUILTIN, HIGH);
            delay(200);
            digitalWrite(LED_BUILTIN, LOW);
            delay(200);
        }
    }
    
    if (who == 36) { // lptmr wakeup value
        for (int i = 0; i < 5; i++) {
            digitalWrite(LED_BUILTIN, HIGH);
            delay(200);
            digitalWrite(LED_BUILTIN, LOW);
            delay(200);
        }
    }
}

188-FB1-F9-DD1-C-4408-B6-F9-9-DF358-C9-A517.jpg
 
The internal pullup resistors are enabled so you need to connect pin 21 or 22 to GND.
Unplugging the wire will then create a rising edge.
 
The internal pullup resistors are enabled so you need to connect pin 21 or 22 to GND.
Unplugging the wire will then create a rising edge.

I connected 21 and 22 to GND(1 pin further from the two) and unplugging to create the rising edge. The on board still did not blink when this happen. It does blink when it boots since I added that to the code.
 
Tested the code and indeed it does not work. Upon further investigation I found 2 issues.

First:
The following does not activate the internal pullup resistors.
Code:
    digital.pinMode(21, INPUT_PULLUP, RISING);//pin, mode, type
    digital.pinMode(22, INPUT_PULLUP, RISING);//pin, mode, type

You need to add the following to setup() in order to activate the internal pullups.
Code:
    pinMode(21, INPUT_PULLUP);
    pinMode(22, INPUT_PULLUP);
    digital.pinMode(21, INPUT_PULLUP, RISING);//pin, mode, type
    digital.pinMode(22, INPUT_PULLUP, RISING);//pin, mode, type

Secondly:
Using arduino 1.8.9
Compiled with TD1.49 does not work.
Compiled with TD1.48 does work.
Apparently there was a change in the directory structure of the Snooze lib going from TD1.48 to TD1.49, maybe something got messed up.
 
Tested the code and indeed it does not work. Upon further investigation I found 2 issues.

First:
The following does not activate the internal pullup resistors.
Code:
    digital.pinMode(21, INPUT_PULLUP, RISING);//pin, mode, type
    digital.pinMode(22, INPUT_PULLUP, RISING);//pin, mode, type

You need to add the following to setup() in order to activate the internal pullups.
Code:
    pinMode(21, INPUT_PULLUP);
    pinMode(22, INPUT_PULLUP);
    digital.pinMode(21, INPUT_PULLUP, RISING);//pin, mode, type
    digital.pinMode(22, INPUT_PULLUP, RISING);//pin, mode, type
Sadly this did not fix it either.

Secondly:
Using arduino 1.8.9
Compiled with TD1.49 does not work.
Compiled with TD1.48 does work.
Apparently there was a change in the directory structure of the Snooze lib going from TD1.48 to TD1.49, maybe something got messed up.
Where would I get an old version of TD? I am using 1.49
 
Sadly this did not fix it either.
This was only meant to enable the pullup resistors, not as a fix for the Snooze lib.

Where would I get an old version of TD? I am using 1.49
See @defragster's previous post.
You must completely remove your current TD1.49 install of the Snooze lib before installing TD1.48.
If you don't, the TD1.48 installer won't be able to handle the change in the directory structure of the Snooze lib and you will end up with a mix of both Snooze libs and it still won't work!
 
The 1.48 downgrade worked! I'll look into 1.50 when that comes out as like neurofun said that is a better idea. However I just needed to check that it works as I have to finish the rest of the project until I put it into use.
 
I'm going to work on this today, been out with the death flu for the last two weeks but starting to feel like half of myself again.
 
I'm going to work on this today, been out with the death flu for the last two weeks but starting to feel like half of myself again.

To recap the problems found so far with v6.3.4.
Tested with TLC, T3.2 & T3.6.

The following does not work:
-enabling the pullup resistors via SnoozeDigital.pinMode()
-wake from digital pin
-wake from timer

Wish you a speedy recovery.
 
Hi,

The data:

  • Teensy v3.5
  • Snooze library v6.3.8

When the processor is hibernating, it does not wake up using a digital pin. From a STM32 board I signal pin 21 of the teensy so that it wakes up but it is not working.

The code in the Teensy is:

Code:
  SnoozeDigital snooze_digital;
  SnoozeBlock config_teensy35(snooze_digital);

  // more code

  pinMode(21, INPUT_PULLUP);
  snooze_digital.pinMode(21, INPUT_PULLUP, FALLING);//pin, mode, type

  // more code

  int who = Snooze.hibernate( config_teensy35 );
  if (who == 21) {  
   // magic code
  }

The code in STM32 board (I am using ChibiOS):

Code:
  palSetPadMode(GPIOG, 11, PAL_MODE_OUTPUT_PUSHPULL);
  palWritePad(GPIOG, 11, PAL_LOW);

  // more code

  palWritePad(GPIOG, 11, PAL_LOW);
  chThdSleepMilliseconds(10);
  palWritePad(GPIOG, 11, PAL_HIGH);

What am I doing wrong?

Thank you
 
Last edited:
Also struggling to get Snooze to work on a Teensy LC [while Teensy 3.2 works fine for a digital pin wake up].

Environment:
My setup:

TeensyLC Snooze.jpg

The output on the serial monitor when I plug in the Teensy LC:

TeensyLC Snooze serial monitor.png

I checked the voltage on the expected pulled-up pin 7: 3V3.
Pushing the button for >3 secs does not wake up the Teensy LC.
Running the exact same code on a Teensy 3.2 works OK: it wakes up and goes to sleep after 7 secs.
Deep-sleep current measured on the T3.2 [USB cable removed, line 44 // while (!usb); uncommented and powered externally with 5V on the Vin pin]: 271 uA - nice! Alive current is 38 mA.
I looked into the Snooze code but did not see any obvious mistake [mind you, my coding skills are mediocre...]

Your support to get the Snooze library working on a Teensy LC would definitely be appreciated.

Regards,
Paul
 
@PaulS I'll take a look at that sketch with T-LC tonight. It worked when I was testing all the different Teensy's, does just a simple pin wakeup work?
 
Hi Duff, thanks for looking into this. No need to hurry though.
I'm not sure I correctly understand you when you ask "does just a simple pin wakeup work?". The sketch I mentioned above does only wake-up from a pin?

Paul
 
OK, I ran deepsleep/button_hold_wakeup sketch on my LC. As noted in post #13 sketch did not come out of deepsleep when pin 7 was grounded. I don't pretend to understand much of the LC snooze logic, but assuming it's using LLS and the LLWU mask bits, I note that pin 7 (PTD2) is not listed as a wakeup pin in table 3-15!?!
Code:
             LLWU_P5 PTB0    16
             LLWU_P6 PTC1    22
             LLWU_P7 PTC3     9
             LLWU_P8 PTC4    10
             LLWU_P9 PTC5    13
             LLWU_P10 PTC6   11
             LLWU_P14 PTD4    6
             LLWU_P15 PTD6   21

So I changed bounce pin from 7 to 6, and LC sketch worked. With no USB deepsleep measured 188.6 ua. Hibernate example with pin 6, 4.1 ua.

Comments in other snooze examples say
Code:
    Teensy LC
    Digtal pins: 6,9,10,11,13,16,21,22
 
Last edited:
Yep, your right, (PTD2) pin 7 is not a wake up pin while in deepSleep or hibernate. I'll update the example to reflect this, thanks!
 
Status
Not open for further replies.
Back
Top