[En-Nut-Discussion] AVR: IDLE_HEARTBEAT_BIT

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Fri Feb 20 20:39:58 CET 2009


Hello,

for me /arch/avr/os/nutinit.c looks like IDLE_HEARTBEAT_BIT is toggled each
time the idle Thread is entered. However to see what processing time is
left. I think it would be more usefull, if the bit is switched on with
entering sleep and switched off when leaving. 

Appended code implements a switch on/switch off, save on byte and some
perhaps some commands. 

Any comments?

Thanks
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: arch/avr/os/nutinit.c
===================================================================
--- arch/avr/os/nutinit.c	(Revision 1033)
+++ arch/avr/os/nutinit.c	(Arbeitskopie)
@@ -468,8 +468,9 @@
 #if defined(__GNUC__) && defined(__AVR_ENHANCED__)
     uint8_t sleep_mode;
 #endif
+
 #ifdef IDLE_HEARTBEAT_BIT
-    uint8_t beat = 0;
+    sbi(IDLE_HEARTBEAT_DDR, IDLE_HEARTBEAT_BIT);
 #endif
 
     /* Initialize system timers. */
@@ -490,14 +491,7 @@
         NutThreadDestroy();
 
 #ifdef IDLE_HEARTBEAT_BIT
-        if ((beat = !beat) == 0) {
-            //UDR = '*';
-            cbi(IDLE_HEARTBEAT_PORT, IDLE_HEARTBEAT_BIT);
-        }
-        else {
             sbi(IDLE_HEARTBEAT_PORT, IDLE_HEARTBEAT_BIT);
-        }
-        sbi(IDLE_HEARTBEAT_DDR, IDLE_HEARTBEAT_BIT);
 #endif
 
 #if defined(__GNUC__) && defined(__AVR_ENHANCED__)
@@ -527,6 +521,9 @@
                 sbi(ADCSR, ADEN); // re-enable ADC
             }
 #endif
+#ifdef IDLE_HEARTBEAT_BIT
+            cbi(IDLE_HEARTBEAT_PORT, IDLE_HEARTBEAT_BIT);
+#endif
             set_sleep_mode(sleep_mode);
         }
 #endif


More information about the En-Nut-Discussion mailing list