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

Thread: Problem with Snooze library - USB Program mode

  1. #1
    Junior Member
    Join Date
    Feb 2019

    Problem with Snooze library - USB Program mode

    Hi All,

    Great stuff on the Teensy and all the amazing libraries especially targeted to it.

    I have an embedded application where the Teensy will be powered 24/7. It will sleep (hibernate or deepSleep) using the Snooze library. Occasionally, I may want to program the Teensy. Problem is, it will be inaccessible, so I won't be able to press the Program button.

    Normally that's not an issue, but I'm finding that the Teensy will not respond to a USB-based request to enter program mode AFTER it has been slept and woken. Does anyone have any experience of solving this issue?

    I don't want to add a manual button to my project due to its embedded nature - I only have two button inputs to the project and these have different functions.

    Here's my code. Yes, I am using the USBSerial driver for Snooze.

    SnoozeDigital motionDigital;
    SnoozeDigital ignDigital;
    SnoozeUSBSerial usb;
    SnoozeBlock config_teensy32(usb, motionDigital, ignDigital);
    motionDigital.pinMode(wakePin, INPUT, FALLING);//pin, mode, type 
    ignDigital.pinMode(ignPin, INPUT, RISING);//pin, mode, type 
    int who = Snooze.hibernate( config_teensy32 );// return module that woke processor
    // wait for serial monitor
      elapsedMillis time = 0;
      while (!Serial && time < 1000) {
        Serial.write(0x00);// print out a bunch of NULLS to serial monitor
        digitalWriteFast(LED_BUILTIN, HIGH);
        digitalWriteFast(LED_BUILTIN, LOW);
      // normal delay for Arduino Serial Monitor

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Not sure about Snooze and if Hibernate somehow precludes USB from restarting - glanced at the Snooze page and it didn't say so.

    Also no idea if threads.delay() may be doing something that prevents the USB initialization process - or the controlling code has this as one thread among others where its servicing process may be the problem. That isn't a complete runnable program.

    There is an example :: hardware\teensy\avr\libraries\Snooze\examples\slee p\sleep_usb_serial\sleep_usb_serial.ino That should give proper function, though - except the threads.delay() - looks like that code may have been used for reference. That code isn't going to run for the application at hand - but if it runs as written and then again substituting Hibernate then the problem would seem to be elsewhere in code shown or not shown.

    Also not indicated what the USB Host OS and Serial App in use is - it may not respond as quickly as hoped in this situation either because the app or OS isn't getting/giving clear signals. Depending on the hub or connective hardware and software 2 or 2.5+ seconds might be needed. Running the indicated sample will give a way to see that needed time beyond 1000 ms.

  3. #3
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Las Vegas
    Using deepSleep or hibernate will put the boot-loader chip into a low power state that only wakes with the program button push to get it into boot loader mode again. You don't have to use Snooze and roll your own lower power code and this will be true also.

  4. #4
    Junior Member
    Join Date
    Feb 2019
    Thanks guys. Sorry for not posting a fully runnable program. I know the rules!

    So the boot-loader goes into a low power state that only wakes with the program button push. Interesting!

    I wonder if it could be pulled low by a digital write from another Teensy pin? Obviously I'd need some way of triggering it at the appropriate time...


Posting Permissions

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