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

Thread: Unable to wake Teensy LC using Snooze

  1. #1
    Junior Member
    Join Date
    Dec 2019
    Posts
    19

    Unable to wake Teensy LC using Snooze

    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);
            }
        }
    }
    Click image for larger version. 

Name:	188-FB1-F9-DD1-C-4408-B6-F9-9-DF358-C9-A517.jpg 
Views:	12 
Size:	152.6 KB 
ID:	18909

  2. #2
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    215
    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.

  3. #3
    Junior Member
    Join Date
    Dec 2019
    Posts
    19
    Quote Originally Posted by neurofun View Post
    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.

  4. #4
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    215
    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.

  5. #5
    Junior Member
    Join Date
    Dec 2019
    Posts
    19
    Quote Originally Posted by neurofun View Post
    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

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,765
    Links to prior copies like for TD 1.48 are: https://www.pjrc.com/teensy/td_148/

  7. #7
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    215
    Quote Originally Posted by ErkelByte View Post
    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!

  8. #8
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    215
    It might actually be a better idea to download v6.3.3 of the Snooze lib and install it in the user library folder instead of downgrading TeensyDuino.

    Snooze lib v6.3.3 -> https://github.com/duff2013/Snooze/t...81e164ca123e3a

  9. #9
    Junior Member
    Join Date
    Dec 2019
    Posts
    19
    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.

  10. #10
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    1,023
    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.

  11. #11
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    215
    Quote Originally Posted by duff View Post
    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.

  12. #12
    Junior Member
    Join Date
    Aug 2020
    Posts
    9
    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 by sntnjrg; 09-24-2020 at 12:46 PM.

  13. #13
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    335
    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:

    Click image for larger version. 

Name:	TeensyLC Snooze.jpg 
Views:	10 
Size:	89.6 KB 
ID:	21952

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

    Click image for larger version. 

Name:	TeensyLC Snooze serial monitor.png 
Views:	9 
Size:	5.1 KB 
ID:	21953

    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

  14. #14
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    1,023
    @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?

  15. #15
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    335
    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

  16. #16
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,594
    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 by manitou; 10-11-2020 at 10:40 PM.

  17. #17
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    1,023
    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!

  18. #18
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    335
    Thanks Manitou and Duff!
    LC waking up on grounding pin 6 is working fine with the updated sketch https://github.com/duff2013/Snooze/b...old_wakeup.ino.
    Measured deepsleep current [USB cable removed, line 44 // while (!usb); uncommented and powered externally with 5V on the Vin pin]: 191 uA. Alive current is 12.7 mA.

    Paul

Posting Permissions

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