From ad6305c1dcd38ee6e1365481ee8920b3d2e07dfc Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Tue, 6 Dec 2011 11:38:34 -0700 Subject: [PATCH] Add debug pin * 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/main.c b/main.c index e00cdbc..4f36d14 100644 --- 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; -- 2.39.2