On Tue, 18 Dec 2001 09:48:49 +0100, Christian Dorner wrote: >Hi! > > >> I have a very strange thing happending with my PIC. >> I mounted it in a proto-board and recorded a simple programa. >> At first it doesn't work. >> Waiting aprox. 1 minute, it beguins to work (sometimes). >> Sometimes, when I touch GND, it works again. Sometimes, not. >> It works when it wants... This sounds suspiciously like an oscillator start-up problem. You may want to try temporarily switching to an RC clock setup. [Don't forget to change the CONFIG seting in your code :=3D) ]=20 If your circuit works reliably with the RC clock, you may want to try a different crystal or larger caps. (IIRC you are using 15pF caps.) I think 20-30pF are more commonly used with 4 MHz crystals. 15pF may be a little too low a value. > >I can remember at the beginning of my PIC expirience i had a similar >problem. In my case i could solve it with a better startup routine like >this: > > org 0x0000 > > clrf PCLATH > clrf INTCON > clrf STATUS > goto start ; Jump to Program entry point > >It seems that the PIC sometimes starts up with unexepted values in some >registers. If this is happening, the PIC is not getting reset properly. I'd suggest very carefully checking power and ground, the oscillator, and the MCLR pin. >If your program don't use interrupts then add a RETFIE at offset >0x0004 to let the program countinue even when a unexepted interrupt = occures. If you're not using interrupts, an 'unexpected' interrupt can only occur if something has inadvertently set the GIE bit. I'd suggest finding out how this is happening. Some code, somewhere, under some condition is setting the GIE bit. BTW, even though this should never be necessary, a RETURN would be preferable to RETFIE since it would both ignore the interrupt and leave the GIE bit off. (Just my $.02, folks, if I'm talkin' through my hat here, flame away.) Regards, Bob -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads