Snooze digital.pinMode problem

Status
Not open for further replies.

sigdev

New member
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);
}
}
}
 
This seems similar to hibernate problem here: https://forum.pjrc.com/threads/48359-Updating-Bounce-Objects-After-Wakeup-from-Snooze?p=162526&viewfull=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:
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.
 
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.
 
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?

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?
 
Status
Not open for further replies.
Back
Top