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

Thread: Snooze digital.pinMode problem

  1. #1
    Junior Member
    Join Date
    Jan 2018
    Posts
    2

    Snooze digital.pinMode problem

    I encounter a problem when using the digital.pinMode of the Snooze library: it doesn't matter whatever type of interrupt I used (FALLING, RISING, CHANGE), the firing always occur as CHANGE (i.e. occurs at both FALLING and RISING). I am using Teensy LC (I also tried it on Teensy 3.1, same problem encountered). Is there anything I have missed out?


    #include <Snooze.h>

    SnoozeDigital digital;
    SnoozeTimer timer;

    SnoozeBlock config_teensyLC(digital, timer);

    int test_pin_1 = 6;
    int test_pin_2 = 9;

    void setup() {

    pinMode(LED_BUILTIN, OUTPUT);

    digital.pinMode(test_pin_1, INPUT_PULLUP, FALLING);//pin, mode, type
    digital.pinMode(test_pin_2, INPUT_PULLUP, FALLING);//pin, mode, type

    timer.setTimer(5000);// milliseconds
    }

    void loop() {
    int who;

    who = Snooze.hibernate( config_teensyLC );

    if (who == test_pin_1) {
    for (int i = 0; i < 3; i++) {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(200);
    digitalWrite(LED_BUILTIN, LOW);
    delay(200);
    }
    }

    if (who == test_pin_2) {
    for (int i = 0; i < 6; i++) {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(200);
    digitalWrite(LED_BUILTIN, LOW);
    delay(200);
    }
    }

    if (who == 36) {
    for (int i = 0; i < 8; i++) {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(200);
    digitalWrite(LED_BUILTIN, LOW);
    delay(200);
    }
    }
    }

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    6,850
    This seems similar to hibernate problem here: https://forum.pjrc.com/threads/48359...l=1#post162526

    Seemed to make it work >> try using sleep instead of hibernate

    something about INPUT_PULLUP - does it work with External pull-up instead:
    Quote Originally Posted by duff View Post
    So I can confirm that using this type of switch in this type of configuration produces the LOW -> HIGH pin wakeup problem described. I tried enabling the glitch filter thinking some transients might be at play but it still had the same problem. Are you willing to change how you connect that switch? With the teensy pin configured as an INPUT connected to the switch's middle pin and the switch's outer pins connected to gnd and 3.3V receptively it works for me. Configure the pin wakeup type to CHANGE also.

  3. #3
    Junior Member
    Join Date
    Jan 2018
    Posts
    2
    It is not a edge triggering glitch problem. I used a clean square wave the problem still appear.

    The external pull-up method does not work.

    However, the problem does not appear when using sleep mode! But I need to use hibernate mode for low power application... Is this a problem in the library or the chip level problem?

    Thanks.

  4. #4
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    909
    Quote Originally Posted by sigdev View Post
    It is not a edge triggering glitch problem. I used a clean square wave the problem still appear.
    Why are you using pull-ups if you have square wave generator, just use INPUT?

    Quote Originally Posted by sigdev View Post
    However, the problem does not appear when using sleep mode! But I need to use hibernate mode for low power application... Is this a problem in the library or the chip level problem?
    What type switch, button, etc... are you using so I can test, I have fry's electronics nearby. Did you try it with "deepSleep" yet? I'm wondering if in hibernate the pull-ups are so weak there is a noise problem? I'll have to put it on the scope to see, what hibernate does is put the internal regulator in a low power state and if you measure the voltage on the Teensy 3.3v pin it reads ~2.8V from what I remember.

    Also what version of Snooze do you have?

Posting Permissions

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