No awakening after hibernation with Rhino

if I run the hibernation test from the Low Power Wiki (GHI Electronics – Where Hardware Meets Software) Rhino never awakes.
Why?

which test? there are several examples.

If you are using alarm to wake up then first read the real time clock and make sure it is running.

Now I see:
The statement
Debug.Print(“Good Morning”);
makes no sense, because the connection via USB is lost, if device is in hibernation: So the Rhino awakes, but has no mouth to say “Good Morning”…

You can see the messages by using MFDeploy tool

Good idea! But how to?

Open MFDeploy and click connect :slight_smile: That simple

Thanks GUS
perhaps you make a hint in the beginners guide:

using System;
using System.Threading;
using Microsoft.SPOT;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.Hardware.LowLevel;
 
using GHIElectronics.NETMF.FEZ;
public class Program
{
    public static void Main()
    {
        //blink LED
        FEZ_Components.LED led = new FEZ_Components.LED(FEZ_Pin.Digital.LED);
        led.StartBlinking(100, 100);
        //set to any random but valid time
        RealTimeClock.SetTime( new DateTime(2010, 1, 1, 1, 1, 1));
        while (true)
        {
            Thread.Sleep(4000);//blink LED for 3 seconds
            Debug.Print("Going to sleep for 5 seconds!");
            RealTimeClock.SetAlarm(RealTimeClock.GetTime().AddSeconds(5));
            //Debug.Print("Time: " + RealTimeClock.GetTime());
            // sleep for 10 seconds
            Power.Hibernate(Power.WakeUpInterrupt.RTCAlarm);
            Thread.Sleep(4000);
            //this you see only in the MFDeply.exe after hitting F5
            Debug.Print("Good Morning!");
        }
    }
}

The guide needs major updates :slight_smile: It has been a while and many things have changed. I am waiting till NEMTF4.2 is out before updating it.

For now, you can help by updating the wiki if you like http://wiki.tinyclr.com/index.php?title=Low_Power

[quote]For now, you can help by updating the wiki[/quote]I did.

Ok. let’s go to the next (the 3rd) example: [italic]awake by LDR-Button via Input glitch.[/italic]
If I hit the LDR-button nothing happens.

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.Hardware.LowLevel;

using GHIElectronics.NETMF.FEZ;
public class Program
{
    public static void Main()
    {
        //blink LED
        FEZ_Components.LED led = new FEZ_Components.LED(FEZ_Pin.Digital.LED);
        led.StartBlinking(100, 100);
        //setup the interrupt pin with glitch filter enableled
        InterruptPort LDR = new InterruptPort((Cpu.Pin)0, true,
                                    Port.ResistorMode.PullUp,
                                    Port.InterruptMode.InterruptEdgeLow);
        while (true)
        {
            Debug.Print("blink blink");
            Thread.Sleep(3000);//blink LED for 3 seconds
            // sleep
            Power.Hibernate(Power.WakeUpInterrupt.InterruptInputs);
            //we get here when we wakeup           
        }
    }
}

The example has pin0 for some reason! You need to update it with the correct pin you are using

Ok let’s take the interrupt-example: (just to be shure, that LDR is PIN0)
if I hit the LDR-Button in the first 3 seconds, I get the result: [italic]LDR-Button pressed![/italic]
After Hibernation nothing happens.

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.Hardware.LowLevel;

using GHIElectronics.NETMF.FEZ;
public class Program
{
    public static void Main()
    {
        //blink LED
        FEZ_Components.LED led = new FEZ_Components.LED(FEZ_Pin.Digital.LED);
        led.StartBlinking(100, 100);
        //setup the interrupt pin
        InterruptPort LDR = new InterruptPort((Cpu.Pin)0, false,
                                   Port.ResistorMode.PullUp,
                                   Port.InterruptMode.InterruptEdgeLow);
        LDR.OnInterrupt += new NativeEventHandler(LDR_OnInterrupt);

        while (true)
        {
            Thread.Sleep(3000);//blink LED for 3 seconds
            // sleep
            Power.Hibernate(Power.WakeUpInterrupt.InterruptInputs);
            //we get here when we wakeup
        }
    }

    static void LDR_OnInterrupt(uint data1, uint data2, DateTime time)
    {
        Debug.Print("LDR-Button pressed!");
    }
}

So it is working in the first example but now you have a problem with the second one?
Try to deploy the program without debugging (CTRL+F5).
Look at the LED it should blink when you press the button.
Seeing messages over USB or while debugging will be a bit hard and can cause problems because the USB is getting connected and disconnected…

[quote]Look at the LED it should blink when you press the button.[/quote]only if it is not in hibernate. afterwards it stops blinking and then the btn has no effect.

We tried it on a Rhino with firmware V 4.1.6.0 and it works…
It does NOT work if you are connected to visual studio debugging because the USB connection resets. Deploy the program, disconnect from VS and then reset the board. Does it work when it reboots as expected?

I guess the wiki must be updated. No low power with USB connected

I’m affraid it [italic]never [/italic]works (at least on my Rhino-bord and MF 4.1.6.0)
[ol]if I power Rhino up via USB with MODE=1 LDR-Btn has no effect (=no blinking)

If I set the MODE=0 (Debug to COM) the LDR-Btn has still no effect.
if I power Rhino with external supply: 270 mA, but in hibernation 306 mA and no LDR-effect
If I do the same with MODE=0: same case no effect, current increase.[/ol]
btw your [List] functions in this forum have only blank indications (no numbers, no signs)

Note: Glitch filter is required for hibernation wake-up. In the interrupt example you are using it is disabled. Or am I mistake? Won’t be the first time… :slight_smile:

I think you are right, but as far as I understand it is necessary, that there is an interrupthandler (from glitch or a self written one). So here is my testcode (with such handler). Perhaps I misunderstood something (would also not be the first time :frowning: )

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.Hardware.LowLevel;

using GHIElectronics.NETMF.FEZ;
public class Program
{
    public static void Main()
    {
        //blink LED
        FEZ_Components.LED led = new FEZ_Components.LED(FEZ_Pin.Digital.LED);
        led.StartBlinking(100, 100);
        //setup the interrupt pin
        InterruptPort LDR = new InterruptPort((Cpu.Pin)0, false,
                                   Port.ResistorMode.PullUp,
                                   Port.InterruptMode.InterruptEdgeLow);
        LDR.OnInterrupt += new NativeEventHandler(LDR_OnInterrupt);
        Debug.Print("Blink Blink");
        while (true)
        {
            Thread.Sleep(3000);//blink LED for 3 seconds
            // sleep
            Power.Hibernate(Power.WakeUpInterrupt.InterruptInputs);
            //we get here when we wakeup
        }
    }

    static void LDR_OnInterrupt(uint data1, uint data2, DateTime time)
    {
        Debug.Print("LDR-Button pressed!");
    }
}