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

Thread: Unable to wake Teensy LC using Snooze

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

    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:	4 
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
    18
    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
    18
    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
    10,937
    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
    18
    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
    999
    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.

Posting Permissions

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