Hi:
I would like to use the RTC with the FEZ Raptor and I cannot get the syntax right. The code below compiles and executes, but the device never goes to sleep, nor does the interrupt fire. Any suggestions are greatly appreciated.
The debug shows:
Using mainboard GHI Electronics FEZRaptor version 1.0
Program Started
Before hibernate…01/04/2014 00:00:00
After hibernate…01/04/2014 00:00:00
Running 4.2
Imports GT = Gadgeteer
Imports GTM = Gadgeteer.Modules
Imports Gadgeteer.Modules.GHIElectronics
' needed for RTC
Imports Microsoft.SPOT.Hardware
Imports Microsoft.SPOT
Imports System
Imports GHI.Premium.Hardware
Imports GHI.Premium.Hardware.LowLevel
Namespace GadgeteerApp1
Partial Public Class Program
Public Sub ProgramStarted()
Debug.Print("Program Started")
For i As Integer = 0 To 10
Gadgeteer.Program.Mainboard.SetDebugLED(False)
Thread.Sleep(200)
Gadgeteer.Program.Mainboard.SetDebugLED(True)
Thread.Sleep(200)
Next
Dim timestart As New DateTime(2014, 1, 3)
RealTimeClock.SetTime(timestart)
RealTimeClock.SetAlarm(RealTimeClock.GetTime().AddSeconds(10))
Dim LDR As New InterruptPort(Cpu.Pin.GPIO_Pin0, True, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow)
AddHandler LDR.OnInterrupt, AddressOf LDR_OnInterrupt
Debug.Print("Before hibernate..." & RealTimeClock.GetTime.ToLocalTime.ToString)
Power.Hibernate(Power.WakeUpInterrupt.RTCAlarm)
Debug.Print("After hibernate..." & RealTimeClock.GetTime.ToLocalTime.ToString)
End Sub
Private Sub LDR_OnInterrupt(data1 As UInteger, data2 As UInteger, time As Date)
Gadgeteer.Program.Mainboard.SetDebugLED(True)
Debug.Print("After interrupt..." & RealTimeClock.GetTime.ToLocalTime.ToString)
End Sub
End Class
End NamespaceImports GT = Gadgeteer
Imports GTM = Gadgeteer.Modules
Imports Gadgeteer.Modules.GHIElectronics
' needed for RTC
Imports Microsoft.SPOT.Hardware
Imports Microsoft.SPOT
Imports System
Imports GHI.Premium.Hardware
Imports GHI.Premium.Hardware.LowLevel
Namespace GadgeteerApp1
Partial Public Class Program
Public Sub ProgramStarted()
Debug.Print("Program Started")
For i As Integer = 0 To 10
Gadgeteer.Program.Mainboard.SetDebugLED(False)
Thread.Sleep(200)
Gadgeteer.Program.Mainboard.SetDebugLED(True)
Thread.Sleep(200)
Next
Dim timestart As New DateTime(2014, 1, 3)
RealTimeClock.SetTime(timestart)
RealTimeClock.SetAlarm(RealTimeClock.GetTime().AddSeconds(10))
Dim LDR As New InterruptPort(Cpu.Pin.GPIO_Pin0, True, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow)
AddHandler LDR.OnInterrupt, AddressOf LDR_OnInterrupt
Debug.Print("Before hibernate..." & RealTimeClock.GetTime.ToLocalTime.ToString)
Power.Hibernate(Power.WakeUpInterrupt.RTCAlarm)
Debug.Print("After hibernate..." & RealTimeClock.GetTime.ToLocalTime.ToString)
End Sub
Private Sub LDR_OnInterrupt(data1 As UInteger, data2 As UInteger, time As Date)
Gadgeteer.Program.Mainboard.SetDebugLED(True)
Debug.Print("After interrupt..." & RealTimeClock.GetTime.ToLocalTime.ToString)
End Sub
End Class
End Namespace
Versions used:
Attaching deployed file.
Assembly: GTM.GHIElectronics.Display_HD44780 (4.2.102.0) Attaching deployed file.
Assembly: Microsoft.VisualBasic (1.0.0.0) Attaching deployed file.
Assembly: Gadgeteer (2.42.0.0) Attaching deployed file.
Assembly: GTM.GHIElectronics.UsbClientDP (4.2.102.0) Attaching deployed file.
Assembly: GadgeteerApp1 (1.0.0.0) Attaching deployed file.
Assembly: GHIElectronics.Gadgeteer.FEZRaptor (4.2.102.0) Attaching deployed file.
Assembly: GHI.Premium.IO (4.2.11.1) Attaching deployed file.
Assembly: Microsoft.SPOT.Net (4.2.0.0) Attaching deployed file.
Assembly: GHI.Premium.Hardware (4.2.11.1) Attaching deployed file.
Assembly: GHI.Premium.System (4.2.11.1) Resolving.