Hello,
I am doing some experiments with shutdown and restart using the WKUP input.
The device I am using is a FEZ Feather with firmware V 2.1.0.2000.
To shut down, the device calls
Power.Shutdown(true, DateTime.MaxValue);
It appears that sometimes the device restarts on a raising edge and sometimes it works on a falling edge. I don’t see the logic in how this exactly works…
Previously the same pin was used with a button like this:
button = gpio.OpenPin(SC20100.GpioPin.PA0);
button.SetDriveMode(GpioPinDriveMode.InputPullDown);
Can this have something to do with the behavior?
Thanks for that reply.
The problem seemed to be that since the internal pulldown cannot be used, the pin was floating. That explains the strange behavior.
Now I added an external pulldown resistor and it works fine!
Yes, im trying to use PA0 as an ON/OFF button. Once the code runs PA0 should run Shutdown and once its shutdown it should by design Wakeup (restart).
This works with LDR button but not when i use PA0.
Btw i don’t have any more interrupts available. All 16 are used as buttons.
This is not a big issue atm, i can just shutdown every 5 minutes of inactivity (not pressing any of the buttons) and PA0 will then work as expected.
But i need to know if the button will be labeled ON/OFF on the membrane keyboard or just ON.
class Program
{
static GpioController gpio;
static GpioPin led;
static GpioPin ldr;
static Thread wkupThread;
static void Main()
{
gpio = GpioController.GetDefault();
led = gpio.OpenPin(SC20100.GpioPin.PA6);
led.SetDriveMode(GpioPinDriveMode.Output);
ldr = gpio.OpenPin(SC20100.GpioPin.PE3);
ldr.SetDriveMode(GpioPinDriveMode.InputPullUp);
wkupThread = new Thread(PollWkup);
wkupThread.Start();
while (true)
{
for (int i = 0; i < 10; i++)
{
led.Write(GpioPinValue.High);
Thread.Sleep(500);
led.Write(GpioPinValue.Low);
Thread.Sleep(500);
}
}
}
static void PollWkup()
{
while (true)
{
Debug.WriteLine("poll wkup");
if (ldr.Read() == GpioPinValue.Low)
{
Debug.WriteLine("ldr low");
Power.Shutdown(true, DateTime.MaxValue);
}
else {
Debug.WriteLine("ldr high");
}
Thread.Sleep(100);
}
}
}
Ha , works, but at the same time it doesn’t because when the button is pressed it goes to sleep and as soon as i release it it wakes up
This would work if the button was toggle button
Yeah i have it, that’s not the issue. You cannot un-press it with your finger fast enough so that it doesn’t trigger a second change therefore waking up the system.
I’m not sure if I’m fully following this thread, so forgive me if my answer is something completely unrelated.
You cannot un-press it with your finger fast enough so that it doesn’t trigger a second change therefore waking up the system.
This sounds like a bouncing problem. Can you try adding a 100nf capacitor between the pin and gnd?
For anyone wondering why, here is described how that works.
The documentation for Power.Shutdown writes the following:
The false argument configures the system to wake up when the WKUP pin goes from high to low.
Make the argument true to wake up when WKUP goes high.
Is this statement true?
If the argument is false, the system does not wake up. When the argument is true, sometimes it doesn’t wake up when the pin goes to high, when it goes to low wake up always.
I have the PA0 pin reserved in the application only for wake up.
I tested with both pull up and pull down resistor with the same result.