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

Thread: Sleep modes and USB Keyboard class

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    2

    Sleep modes and USB Keyboard class

    UPD: The problem was resolved. The reason was in the time required to wake up from pwr_down mode, delay(2000) after wake up resolved an issue.
    Initial question was:

    Hi.
    I am trying to make power efficient keyboard with Teensy 2.0, and need your advice.
    I use keyboard class and watchdog timer to check key presses in idle mode. When key press detected, keyboard remains in full speed mode for some time ,then goes to sleep.

    It works just fine if I use SLEEP_MODE_IDLE, but it still consume about 6mA, so I want to use SLEEP_MODE_PWR_DOWN which consumes much less power.
    But after SLEEP_MODE_PWR_DOWN mode Keyboard is not working ( no reaction on Keyboard.print() etc. )

    Is it normal behavior, how can I save battery, preserving USB connectivity?
    Thank you

    My sleep code is:

    void system_sleep() {
    cli();
    CPU_PRESCALE(CPU_125kHz);
    sei();

    set_sleep_mode(SLEEP_MODE_IDLE); // SLEEP_MODE_PWR_DOWN is not working properly with usb
    power_all_disable();
    noInterrupts();
    sleep_enable();

    interrupts();
    sleep_cpu();
    sleep_disable();
    power_all_enable();
    cli();
    CPU_PRESCALE(CPU_1MHz);
    sei();
    }
    Last edited by kotoezh; 05-14-2013 at 09:25 AM. Reason: resolved

  2. #2
    Junior Member
    Join Date
    May 2013
    Posts
    2
    Hi. The problem still exists. I still cannot get stable behavior of keyboard after power down. It can work with watchdog interval of 1s, but can not work with 2s or 4s. Keyboard output is missed or keyboard stops completely. Similar behavior with Serial output.
    Can you give me advice or link on similar working project ?
    Thanks a lot.
    Current sleep routine is :

    void system_sleep()
    {
    Keyboard.print("S");
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
    delay(50);
    Keyboard.end();
    delay(500);
    noInterrupts();
    sleep_enable();
    interrupts();
    sleep_cpu();
    sleep_disable();
    power_all_enable();
    delay(50);
    Keyboard.begin();
    delay(500);
    Keyboard.print("W");
    }

Tags for this Thread

Posting Permissions

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