Maker Pro
Maker Pro

My MCU circuit can't start by itself

sabahan

Jul 14, 2013
31
Joined
Jul 14, 2013
Messages
31
I made a circuit that transmit two set of numbers to another MCU circuit,but the circuit can't start by itself,it will start when I uses a probe fro the oscilloscope to test of the legs of the crystal,once the probe is remove,it can hold for few second and it die,I uses 16MHz crystal with two 22pF capacitor tie to ground,is the load capacitance of the crystal not suitable for the MCU?I try to search in the datasheet what crystal to use but I found nothing,it only show what model crystal it uses to test the MCU,I can't find the datasheet of the crystal
MCU used is PIC16F877A
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
The datasheet (figure 14-1) hints at a possible requirement for a series resistor for certain types of quartz.
It also states that you need to consult the quartz manufacturer's datasheet for the correct choice of capacitors.
One sign of wrong capacitances is that the scope probe starts the oscillator. This is possibly due to the additional capacitance of the probe tip. Try increasing the capacitances from 22pF to e.g. 33pF.
 

Arouse1973

Adam
Dec 18, 2013
5,178
Joined
Dec 18, 2013
Messages
5,178
A couple of other things to try. A parallel resistor of 1M across the crystal induces more noise which helps the oscillator to start. Sometimes you need to have slightly different value capacitors to get it to start and as Harald mentioned this is what the scope probe is doing.

But it could be a connection issue and your scope probe is actually being used as the capacitor because the one on the PCB is not connected. The other thing is to check you are using the correct mode for the speed of crystal.

That is to check if you are in HS or XT or LS mode. But at 16 MHz it will be HS mode (high gain), this mode has a higher gain setting for the internal amplifier that's part of the oscillator which means more noise and better start-up.

Make sure your connections are very short and use good quality capacitors like COG/NPO.

Adam
 

gorgon

Jun 6, 2011
603
Joined
Jun 6, 2011
Messages
603
The oscillator circuit in the PIC already has a parallel resistor inbuilt. Are you sure the capacitors are 22pF? For the 16MHz crystal, the rated capacitor range is 15-33pF. As said, you should use HS mode for this frequency.

Try some different values of the load capacitors to try out. In the datasheet there is listed a crystal from Epson as an example, I suppose CA-301 16.000M-C should be a correct type. This is listed with a load capacitance of 18pF.
 

sabahan

Jul 14, 2013
31
Joined
Jul 14, 2013
Messages
31
I don't know why but when I change the crystal to a 4MHz frequency,its works,but it doesn't work with 8,16 or 20MHz crystal,I have try 10,15,20,22,30,33,47 and 56 pF capacitor,and yes,I am sure the capacitor is a 22pF capacitor,I used a angilent LCR meter to measure it and it give a 27pF reading,the extra 5 is due to the capacitance of the lead of the meter
 

Arouse1973

Adam
Dec 18, 2013
5,178
Joined
Dec 18, 2013
Messages
5,178
Can you supply the source code maybe someone on here might spot something.
Adam
 

sabahan

Jul 14, 2013
31
Joined
Jul 14, 2013
Messages
31
I don't think is necessary ,in my code ,after declaring the variable and setting the input and output port,my first task is just to make PORTA.0 goes on for a second then off,it was tested with a MSO oscilloscope ,but the pin just stay silent,the code will be remove on the final version,it task is just to verify that the MCU has started normally ,PORT A had been define as output,I'm using Picbasic Pro version 3
 

Arouse1973

Adam
Dec 18, 2013
5,178
Joined
Dec 18, 2013
Messages
5,178
It's all the config bits that might be worth looking at, as it seems strange it works on a 4MHz crystal and that's all.
Adam
 

sabahan

Jul 14, 2013
31
Joined
Jul 14, 2013
Messages
31
I'm oversea now,have no access to the code,but the start few line is as follow
Define osc 4 '4 MHz crystal for oscillator
trisa = 0 'Porta are all output
Trisb = 0 'Portb are all output
PORTA.0 = 1 'Turn on PORTA.0
pause 1000 'Wait one second
PORTA.0 = 0 'Turn off PORTA.0
.
.
.
.




The first line will be replace with 16 if a 16mhz crystal is used
 

sabahan

Jul 14, 2013
31
Joined
Jul 14, 2013
Messages
31
5V from a LM7805,with 10 and 100uF and a 100nF capacitor of the input and 10 and 0.1uF capacitor on the output
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Are you using the high speed crystal (HS) config setting? This sounds like what it would do if you were using XT instead.

Bob
 
Top