]> oss.titaniummirror.com Git - rgblamp.git/commitdiff
Add debug pin
authorR. Steve McKown <rsmckown@gmail.com>
Tue, 6 Dec 2011 18:38:34 +0000 (11:38 -0700)
committerR. Steve McKown <rsmckown@gmail.com>
Tue, 6 Dec 2011 18:38:34 +0000 (11:38 -0700)
* Debug on pin 1 of DIP18 package, RA2.
* Set pin high when processing in the loop.  Low during wait or sleep.

At 4 MHz, we see that processing within the loop is at most 12 ms, and
we have a loop period constraint of 32 ms.  We could run at 2 MHz too...

main.c

diff --git a/main.c b/main.c
index e00cdbc49a8bb096143bf59d49912a381fdd14b9..4f36d146b1133f58aa7e32e07ddd4c05f9fc5831 100644 (file)
--- a/main.c
+++ b/main.c
@@ -66,6 +66,16 @@ const static int min_fade_steps[4] =           { 64, 32, 16,  8 };
 const static int range_fade_steps[4] =         {  1,  1,  1,  1 };
 #endif
 
+#define dbgpin_init() \
+do { \
+  /* Set RA2 as output low */ \
+  PORTA &= ~0x04; \
+  TRISA &= ~0x04; \
+} while (0)
+
+#define dbgpin_high() PORTA |= 0x04;
+#define dbgpin_low()  PORTA &= ~0x04;
+
 int main(void)
 {
     led_t red = INIT_LED;
@@ -80,11 +90,13 @@ int main(void)
     unused_init();
     buttons_init();
     rgb_init();
+    dbgpin_init();
 
     reset_steps();
     if (buttons_on())
       rgb_on();
 
+    dbgpin_high();
     while (1) {
         unsigned char buttons = buttons_read();
 
@@ -140,10 +152,14 @@ int main(void)
               wht.increment = (neww - wht.value) / fade_steps;
               wht.remainder = neww - (wht.value + wht.increment * fade_steps);
             }
+            dbgpin_low();
             __delay_ms(STEP_SIZE); /* step should be start to start... */
+            dbgpin_high();
         } else {
             rgb_off();
+            dbgpin_low();
             buttons_sleep();
+            dbgpin_high();
             reset_steps();
             rgb_on();
             red.value = 0;