WathchDog

Dependencies:   mbed WDT

Revision:
9:6c267eecb235
Parent:
8:0c5a091410cf
diff -r 0c5a091410cf -r 6c267eecb235 main.cpp
--- a/main.cpp	Thu Sep 12 05:42:04 2019 +0000
+++ b/main.cpp	Thu Sep 12 06:28:57 2019 +0000
@@ -69,6 +69,12 @@
 unsigned char buf485[2048];
 int cnt485;
 
+// 20190912 K.Hirasawa 
+// WDT&Count de Taisaku
+// Fleeze ha WDT de taisakuzumi.
+// RS485 no kaisenn nigittamama monndai nara CountOver de Reset.
+int cntOver;
+
 int main()
 {
     float sum1,sum2,sum3,sum4;
@@ -80,6 +86,7 @@
     pc.printf("\n--Initial Start--\r\n");
 
     WDT wdgTimer;
+    cntOver = 0;
     
     wdgTimer.Configure(10);
 
@@ -194,7 +201,14 @@
 
 //        wdg.kick(); // IWDGをリセット
 //        if (jmp != 0) wdgTimer.Service();
+
+        cntOver += 1; // 1s ni ikkai CountUp
         wdgTimer.Service();
+        
+        if (cntOver > 60) {
+            wdgTimer.Configure(1);
+            while(1) {;}    
+        }
     }
 }
 
@@ -206,13 +220,15 @@
 //    int i;
     
     if (rslen()) {
-        
         chr = rsgetc();
         buf485[cnt485++] = chr;
         buf485[cnt485] = '\0';
         if (chr == '?') cnt485 = 0;
         
         if (chr == 0x0a) {
+            // 20190912 K.Hirasawa
+            cntOver = 0; // Jyusin ari!        
+        
 //        pc.printf("CR\r\n");
             
             if( ('C' == buf485[0]) ) {