Den 2007-09-10 23:51:21 skrev Herbert Graf : > On Mon, 2007-09-10 at 22:54 +0200, Morgan Olsson wrote: >> (Reposting with [PIC] tag, sorry) >> >> I seem to have missed one detail that is important in some circumstances... >> >> When using ICD(2) or Real-ICE... >> >> Where does it say that i have to set the PGC and PGD pins as outputs low? > > I don't know about RealICE (I would expect, being a full ICE, you > wouldn't have to do anything to accomodate the ICE in your code). With > regards to the ICD2, there are no requirements to set the PGC and PGD > pins as output, I always leave them as default (inputs). > >> Or, that we must not enable PortB internal pullups? > > Don't know about this one, I wouldn't expect PortB internal pullups to > be a problem, they are weak pullups and I would expect an ICD2 to easily > be able to pull those pins down. TTYL I thought so too, and have worked with that assumtion before. Also last month using CCS compiler + MPLAB + ICD2, I believe we had no problems with that. Then we have converted the project to Microchip C18 in order to use Real-ICE to catch bugs. Well, of course we made lots of beginners error; there was some errors in our code for interrupt initially, etc... Also it seem there is an interrupt bug (see another current thread). But still we had PortB interrupt-on-change shooting with high frequency, sucking up a lot of CPU. The RB4 and RB5 pins we drive from an incremental were stable (not toggling), and i also scoped RB7 and RB6 to be stable. ICD2 / Real-ICE is connected to our PIC18F66J15 ICD pins as per recommendation; nothing else connected to PGD and PGC (RB7 and RB6). Real-ICE have been always connected.... but then i unplugged Real-ICE, and the erratic portB interrupt-on-change disappeared !! I checked the voltage on RB7 and RB6 (PGD and PGC) : -It was 600mV on both with Real-ICE connected, PIC running. PortB internal pullup is enabled, so with nothing connected the inputs were truly logic high. RB7 and RB6 configured as inputs. But with Real-ICE connected the voltage levels vere 0,6V and apparently that is about where the pin input buffer trig level is! We use VDD = VDDCORE = 2,5V (from external regulator) If we exchange Real-ICE to ICD2 instead, the voltage is higher, slightly above 1 Volt, and that is apparently above the pin buffer switch point, as we then get no false interrupts on PortB interrupt-on-change. So apparently neither Real ICE nor ICD2 make the pin voltage levels appropriate if we enable PortB internal pullups. On this very setup, it happens that with ICD2 the voltage is high enough not to cause trouble, but using Real-ICE the voltage is close to the pin input buffer tripping point, so it is easily disturbed by interference probably from the close-by switching regulator. (I can also change the interrupt frequency by moving my fingers on the PIC... So one method would be to not use the PortB internal pullups, so ICD2 / Real-ICE can hold the pin low enough, and use external pullups for the pins that need it. (But I think it is bad design to leave the ICD pins on the PIC floating as I believe there is a (small) chance that noise may cause the PIC to go into program or debug mode by accident) So I propose to instead make the pins outputs, and we have set them as outputs, low. That works splendid so far. I was afraid that debug would not work if we hold them low, but we can debug alright with Real-ICE in this setup, and the signal levels are probed by oscilloscope to switch between GND and VDD fully OK. PIC = PIC18F66J15 10MHz Xtal, x4 PLL, VDD = VDDCORE = 2,5V (from external regulator) ICD pins RB6 and RB7 are set as outputs low early in initialisation and then never touched by our program. -- Morgan Olsson -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist