Use of WKUP input after Power.Shutdown

This should be documented, i ran into the same scenario just now. I was 90% sure it needed a pull resistor anyway, but this confirms it.

GitHub issues is our friend here

Where does

Power.Shutdown(true, DateTime.MaxValue);

work from? only from main thread main method?
because everywhere else I get a System.InvalidOperation

We have only tested it with a working RTC. I know your code shouldn’t need RTC but can you please try to enable RTC first?

Did you use PA0 anywhere before calling Shutdown?

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);

            ldr = gpio.OpenPin(SC20100.GpioPin.PE3);

            wkupThread = new Thread(PollWkup);

            while (true)
                for (int i = 0; i < 10; i++)

        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");

Because we check PA0 before switch this pin to different function (shutdown mode), that is reason get the exception, not related to thread.

We added an issue to see if we need to check or not.

For now, you can not call shutdown gpio if PA0 is used.

Easy, just Dispose the pin before calling Shutdown. You don’t need this pin because wakeup from shutdown is similar to reset.

Ha :laughing:, 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 :stuck_out_tongue:
This would work if the button was toggle button

1 Like

That is expected. You need a pull up or pull down on the pin.

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.


Maybe you should add a small delay, or wait untill you see a raising edge before you call the shutdown function.

1 Like

Two heads are better then one. :smiley: Never would’ve thought of that. Works perfectly.

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.

Where do you see that?

In the shutdown section, second paragraph.

What is exactly connected to the pin? And how do you set it high and low?

I test it with MMA8452Q and MCP23008 circuits where I can set the interrupt polarity. I have verified the functionality of the settings.

I did more tests. When the pin goes from low to high never wake up, the opposite always works. I used an external pull down resistor. Can anyone verify this? If you use the button beware of debouncing.

We will test. Please confirm you are using preview 3