G120- SleepLevel.Off - RTC and GPIO wakeup problems

I am trying to develop a logger using G120. I needed to use “SleepLevel.Off” and wake up using RTC time alarm and GPIO interrupts.

I manage to get it to wake up using RTC alarm after “SleepLevel.Off”

My code

public static void Set_wakeup_alarm_and_sleep(int Next_wakeup_in_seconds)
                PowerState.WakeupEvents |= HardwareEvent.OEMReserved2;
                PowerState.Sleep(SleepLevel.Off, HardwareEvent.OEMReserved2);
            catch { error_code = 2; error_dipc = "Alarm and sleep error"; }

Then I executed this function before executing above “Set_wakeup_alarm_and_sleep(int Next_wakeup_in_seconds)” function hoping that I have successfully manage to assign an interrupt functions.

  public static void set_wakeup_options()
            InterruptPort usb_pwr_connector = new InterruptPort(G120.P0_27, true, Port.ResistorMode.PullDown,Port.InterruptMode.InterruptEdgeBoth);
            InterruptPort bluethooth_pair_ok = new InterruptPort(G120.P0_28, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);
            usb_pwr_connector.OnInterrupt +=usb_pwr_connector_OnInterrupt;
            bluethooth_pair_ok.OnInterrupt +=bluethooth_pair_ok_OnInterrupt;

The system still wake up from RTC alarm but not from the GPIO interrupt.
I know it’s a cold start every time when it wake up but I can manage that.

CAN any one help!
see the picture if any one interested in our design.

Kind Regards,

Hi @ niranp welcome to the forum.

Sleep.Off does not work with interrupts currently. I’m not sure if this is a hardware or software limitation. If you haven’t already seen it you may be interested in this thread here where various sleep states were discussed and measured.


I think all this is still relevant on the current release.

Your design looks good. Thanks for sharing.

Hi hagster,
Thanks for the thread…

I think we need a old fashioned interrupt service handler for .net micro framework. which we can manipulate :frowning:

I have added a task to the task tracker for this as it would be really useful if it could be fixed.

@ niranp - What version of the SDK are you using?

@ John -

Its 4.3. I did update the G120 using GHI boot-loader to 4.3 as well.

@ niranp - I meant for our SDK. Are you on the latest 2014 R5?

@ John -

I have this installed but not sure how to test whether I am using this in my project or not.

[quote]NETMF 4.3 SDK

2014 R5

Released October 2014

Built with NETMF SDK 4.3 QFE1



  • Firmware
  • Loader


  • None.


  • The loader cannot be updated on Windows 8.



  • Firmware
  • Loader
    Can you also see my references are correct as well.

Do I need to have these references in as well?
Microsoft.SPOT.Graphics =
Microsoft.SPOT.Hardware =

Please note that the SD card,Threads, RTC, Coms are working fine.

Please Help…

I think its like project properties.

PROJECT…(name of the project) properties…then see what version of NETMF you are using

Then on the right to find the specific versions go to
solution explorer…references…then find the Gadgeteer(click it)…then find the version in the properties box(tell us all the numbers)

Also do it for ghi.hardware…properties(tell us the versions)

I think this is what they want, or atleast will help them

So yes, you’re running the GHI 2014 R5 SDK. An equally important point is to confirm you have the right firmware on your device, fire up FezConfig and test (paste the results back in a reply here)

@ Brett -
Thanks for the confirmation.

I did update the firmware using “FezConfig”. please see the picture.

FezConfig’s About window says the following…

[quote]NETMF v4.3:
EMX: Firmware, Loader
G120: Firmware, Loader
G400: Firmware, Loader
Cerb-Family: Firmware, Loader
FEZ Hydra: Firmware, Loader[/quote]

Does my code and my approach checks-out?

@ John -

Does my code and my approach checks-out?

show us tinybooter too ! From the “check device for update” output on the “connection” page when the app first opens

@ Brett -

[quote]Loader (TinyBooter) version information: on this computer. on this device.

The Loader (TinyBooter) is up to date. <<<

Firmware (TinyCLR) version information: on this computer. on this device.

The Firmware (TinyCLR) is up to date. <<<
Please wait for the device to reboot… Done.[/quote]

The boot loader seems
But does it matter when it’s only extincting the application code?

Yes it can be a problem if they don’t match. Yours is all correct and in sync to SDK 2014 R5.

@ niranp - It looks like the G120 processor does not support waking from interrupts when using SleepLevel.Off.

@ John -
@ John -
I tried with SleepLevel.Off, SleepLevel.Off, SleepLevel.Sleep and SleepLevel.DeepSleep same result.

What you are saying is when using RTC alarms interrupts the GPIO interrupts can not be used. Isn’t this implemented in software ISR.
I know that “LPC17x.” hardware supports this(from the data sheet UM10360 page 129 last paragraph) just not included in the .net porting.

I wish you put that in the module’s data sheet. I did expect such a basic and important function is not ported.

I am too far in to the development process and its not possible to turn back now.

Can you give me a workaround?
Is it possible to set to restart the G120 device when GPIO or any interrupts triggered? Do not need to execute an function.
Can I do this by accessing CPU registry?

I select this module for an low power field logger that need to sleep and it needs to wake up from pin interrupts. Sleep power consumption is some what acceptable for the performance and I know its the hardware limitation but the above problem is not an hardware limitation.

@ niranp - it seems John is right.

See page 61 of the user manual.

No mention of interrupts sadly.

I think the supported low power states are:-
Sleep. - automatic when idle
DeepSleep. -
PowerDown. - not implimented.
DeepPowerDown - off . RTC wake only

You could use the register class or RLP to trigger the PowerDown mode and see what that does. There is an app note with some example C code on the nxp site.

I’ve just noticed you are using the wrong user manual. The correct on is UM10470.

Also you can see the experiments that I did here https://www.ghielectronics.com/community/forum/topic?id=13119&page=1. This was on an older firmware version that didn’t support any low power modes and also the way RLP is handled has changed a bit since then.