PDA

View Full Version : PIC 18F242 not starting



manxman
- 10th March 2007, 09:05
My circuit uses an 18F252 with 20MHz low profile crystal and 33nF capacitors for the clock. Power comes from a 7V bench supply, through a standard 7805 regulator and a MAX232 is used for serial to a PC. There are 100nF power line decoupling capacitors scattered on the board. My problem is that, on switch on, the PIC fails to start about 7 times out of 10. Also, the program often stops and the PIC re-starts at random. The same thing happens when the PIC sends instructions to a DAC.

Has anyone any experience of this problem and a suggested solution?

Melanie
- 10th March 2007, 09:28
Some suggestions...

1. I assume 33pF and not nF!!! Even 33pF seems a bit large for a 20MHz xtal, whilst 33nF should be enough to kill your Oscillator dead!!

2. 7v into a 7805 Regulator is really 'marginal'. What's the 5v rail like under the worst case load conditions?

3. PIC Restarting could be noise on the MCLR pin or the volts dropping to the Brown-Out setting (see point 2 above). The Brown-Out setting I believe is software adjustable, it may be set too high.

4. If you can... get a 18F2520 just to debug your board... it has two features... (a) you can run on internal oscillator (but not at 20MHz) and (b) you can run on internal MCLR. Those two features can help to identify if you have external Oscillator or MCLR problems.

5. Very very early 18F24x's and 18F25x's (I'm talking some three years back) had heaps of problems as they were very fussy as to noise. A bad board design could kill the whole project. Make sure you haven't got one of those.

mister_e
- 10th March 2007, 20:41
Would be nice to see some schematic and config fuses.

manxman
- 13th March 2007, 18:38
Thanks Melanie and Mister E for your kind advice - that was extremely helpful, as I will explain:

The crystal capacitors were actually 33 pF (!) but I changed them to 22pF and this improved the starting, but there was still a random re-start problem. On my board the DAC's control lines (Clock, Latch Enable & Data) are connected to PortB.7, PortB.6 and PortB.5, respectively, and I found that when the PIC sent controls to the Latch Enable pin the PIC froze. The problem was due to the fact that the Low Voltage Programming (LVP) fuse was set as Enabled in the MElabs programmer configuration, and of course these 3 pins on Port B are used for programming! The solution was to change the LVP fuse to Disable, and then the DAC and the PIC worked perfectly.

Thanks you guys!

Evolution
- 14th March 2007, 04:17
My circuit uses an 18F252 with 20MHz low profile crystal and 33nF capacitors for the clock. Power comes from a 7V bench supply, through a standard 7805 regulator and a MAX232 is used for serial to a PC. There are 100nF power line decoupling capacitors scattered on the board. My problem is that, on switch on, the PIC fails to start about 7 times out of 10. Also, the program often stops and the PIC re-starts at random. The same thing happens when the PIC sends instructions to a DAC.

Has anyone any experience of this problem and a suggested solution?

have you set you program option to hs oscillator??????????

manxman
- 14th March 2007, 17:00
Yes, the program has a header line defining this oscillator frequency. The problem is solved as described before.