Main Site Documentation

Once-a-second interrupt


#1

I’m thinking of setting the RTC alarm, and feed back on the pin to generate an interrupt once a second. The interrupt routine would set the RTC alarm to the next second. Is there an easier way to have a once-a-sec interrupt that doesn’t require me to loop and compare the time of day?


#2

NETMF has built in timers, see the ebook


#3

This is just one of the methods you could use:


public static void Main()
        {
            Timer t = new Timer(TimerCall, "hello", new TimeSpan(0,0,1), new TimeSpan(0,1,0) );

            Thread.Sleep(-1);
        }


        // only static because Main() is, this doesn't have to be static.
        public static void TimerCall(Object stateInfo)
        {
            Debug.Print(stateInfo.ToString() + " @ " + DateTime.Now.ToString("hh:mm:ss"));
        }

Outputs:

hello @ 05:24:16
hello @ 05:25:16


#4

Thanks for the example, Mark :slight_smile: