Hi All. I'm having an odd problem with MPLAB-ICD (16F877). I seem to be somehow latching up PORTC, and I can't figure out why ... perhaps someone can shed some light on it ... Here's the scoop: if I download a HI-TECH PIC C program like: main() { #if 1 int counter; TRISC = 0x00; while (1) PORTC = (counter++) >> 8; #else /* complex program goes here, also writes to all 8 bits of PORTC */ #endif } everything in this trivial program works as expected -- the LEDs reflect the counter's top byte properly. However, if I then change the #if 1 above to #if 0 and recompile the program, something weird happens: At the end of the programming operation, and _before_ I choose Debug->Run in MPLAB, PORTC:0 starts glowing very faintly. There's no ac signal or waveform on PORTC:0 -- it's just a 1.75V output on PORTC:0. The complex program runs, but PORTC:0 continues to glow faintly and and PORTC:1 remains off, even though the complex program writes to all 8 bits of PORTC. What's also strange is that the complex program's first chore is to set TRISC to 0x00, yet when I watch it in a Watch window, it's been set to 0x03. If I step through the program, I see that it's trying to clear all of TRISC, yet only the upper 6 bits are cleared. If I then change back to #if 0, recompile and re-program, the PORTC problem remains. Only if I remove power from the ICD, re-apply power, re-establish connections, reset and run, does the problem go away. In other words, just the act of programming the part with the complex program via the ICD latches up PORTC:0..1, and only powering it down and re-programming it with another, much simpler program will fix it. If I don't use the ICD but rather program the 16F877 with a PICSTART Plus, both programs (#if 0 and #if 1) work fine. So the chip and the ICD "demo board" appear to be just fine. I recognize that there may be something in the more complex program that is unintentionally changing TRISC. But what I don't understand is what could possibly be happening that effectively locks up PORTC such that only a POR will clear it. Any suggestions? Thanks! -- ______________________________________ Andrew E. Kalman, Ph.D. aek@pumpkininc.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.