using System; using System.IO.Ports; using System.Text; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.IO; using Microsoft.SPOT.Hardware; using GHI.IO.Storage; using GHI.Processor; namespace NXP752 { public class Program { public static void Main() { // Timeout 5 seconds int timeout = 1000 * 5; // Enable Watchdog GHI.Processor.Watchdog.Enable(timeout); // Start a time counter reset thread WDTCounterReset = new Thread(WDTCounterResetLoop); WDTCounterReset.Start(); Register RSTC_SR = new Register(0xFFFFFE04); uint count = RSTC_SR.Value; Debug.Print("RSTC_SR= " + count); SerialPort UART = new SerialPort("COM1", 115200); //int counter = 0; UART.Open(); // create a string string counter_string = "RSTC_SR: " + count.ToString() + "\r\n"; // convert the string to bytes byte[] buffer = Encoding.UTF8.GetBytes(counter_string); // send the bytes on the serial port UART.Write(buffer, 0, buffer.Length); // increment the counter; //counter++; //wait... Thread.Sleep(100); UART.Close(); } //end main static Thread WDTCounterReset; static void WDTCounterResetLoop() { while (true) { // reset time counter every 3 seconds Thread.Sleep(3000); //Watchdog.ResetCounter(); } } } }