duff2013 / Snooze

Teensy Low Power Library
MIT License
134 stars 37 forks source link

Teensy 3.6 does not wake on pin 26, 30, or 33 digital interrupt. #72

Open Llamero opened 4 years ago

Llamero commented 4 years ago

I am having a similar issue to https://github.com/duff2013/Snooze/issues/32 on a Teensy 3.6 where pins 26, 30, and 33 are unable to wake the device. I confirmed that these pins were functional by testing if they can detect that the pin was pulled low when not in hibernate. Here is the test code:

#include <Snooze.h>
// Load drivers
int interrupt_pins[] = {2,4,6,7,9,10,11,16,21,22,26,30,33};
SnoozeDigital digital;
SnoozeUSBSerial   usb;
Snoozelc5vBuffer  lc5vBuffer;
SnoozeBlock config_teensy36(usb, digital);

void setup() {
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);

  //Confirm that pins 26, 30, and 33 are functional - use pin 2 as a control
  pinMode(2, INPUT_PULLUP);
  pinMode(26, INPUT_PULLUP);
  pinMode(30, INPUT_PULLUP);
  pinMode(33, INPUT_PULLUP);

  //Set LED to flash as output
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWriteFast(LED_BUILTIN, HIGH);

  //Wake USB
  wakeUsb();

  //Configure interrupt pins
  for(int a=0; a<sizeof(interrupt_pins) / sizeof(interrupt_pins[a]); a++){
    digital.pinMode(interrupt_pins[a], INPUT_PULLUP, RISING);//pin, mode, type
    Serial.print("Loading pin ");
    Serial.println(interrupt_pins[a]);
    delay(100);
    digitalWriteFast(LED_BUILTIN, LOW);
    delay(100);
    digitalWriteFast(LED_BUILTIN, HIGH);
  }
}

void loop() {
    int who;
    who = Snooze.hibernate( config_teensy36 );// return module that woke processor
    digitalWriteFast(LED_BUILTIN, LOW);
    wakeUsb();
    while(!digitalRead(2) || !digitalRead(26) || !digitalRead(30) || !digitalRead(33)); //Confirm that pins work by holding them low
    Serial.println(who);
    digitalWriteFast(LED_BUILTIN, HIGH);
    delay(500);
}

void wakeUsb(){
    elapsedMillis time = 0;
    while (!Serial && time < 1000) {
        Serial.write(0x00);// print out a bunch of NULLS to serial monitor
        digitalWriteFast(LED_BUILTIN, HIGH);
        delay(30);
        digitalWriteFast(LED_BUILTIN, LOW);
        delay(30);
    }
    // normal delay for Arduino Serial Monitor
    delay(200);
}

Thank you for your help, and for supporting such a great library! -Ben Smith