Summary of 40 MCU crystal oscillator problems and solutions

Publisher:reaper2009Latest update time:2017-11-13 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Analysis of the reasons why the microcontroller crystal oscillator does not oscillate

It is a common phenomenon that the microcontroller crystal oscillator does not oscillate. What are the reasons for the crystal oscillator not oscillating?
(1) PCB board wiring error;
(2) Microcontroller quality problem;
(3) Crystal oscillator quality problem;
(4) Load capacitor or matching capacitor does not match the crystal oscillator or capacitor quality problem;
(5) PCB board is damp, resulting in impedance mismatch and failure to oscillate;
(6) The crystal oscillator circuit wiring is too long;
(7) There is a wiring between the two pins of the crystal oscillator;
(8) The influence of the peripheral circuit.

Solution, it is recommended to eliminate the faults one by one according to the following methods:

(1) Eliminate the possibility of circuit error, so you can compare with the recommended circuit of the corresponding model of microcontroller.
(2) Eliminate the possibility of defective peripheral components, because peripheral parts are nothing more than resistors and capacitors, you can easily identify whether they are good products.
(3) Eliminate the possibility that the crystal oscillator is a stopped product, because you will not have tried only one or two crystal oscillators.
(4) Try to change the capacitors at both ends of the crystal. Maybe the crystal oscillator can start oscillating. For the size of the capacitor, please refer to the instructions for use of the crystal oscillator.
(5) When wiring the PCB, the traces of the crystal oscillator circuit should be as short as possible and as close to the IC as possible. Avoid traces between the two pins of the crystal oscillator.


2. What happens if the two fine-tuning capacitors in the microcontroller crystal oscillator circuit are asymmetrical? How will the frequency change if the difference is too large? When I was testing the receiving module of the wireless mouse, I found that its frequency always changed slowly (that is, I kept holding the probe and found that the frequency slowly decreased). The crystal oscillator is new!
Answer: Capacitor asymmetry will not cause frequency drift. The frequency drift you mentioned may be caused by the unstable capacity of the crystal oscillator capacitor. You can try to change it. It is not difficult to change the two capacitors. Otherwise, the stability of your crystal oscillator is too poor, or your measurement method is wrong.


3. When the 51 microcontroller clock circuit uses a 12MHZ crystal oscillator, how is the value of the capacitor obtained? Let's use the internal clock circuit to explain!
Answer: In fact, no one can explain clearly how to choose the value of these two capacitors, because 22pF is too small.
This can only be said to be related to the characteristics of the internal oscillation circuit itself. It is used in combination to correct the waveform. No one has gone into the details of why it has such a large value.


4. Why is the crystal oscillator required to be close to the IC, and the microcontroller crystal oscillator does not oscillate?
Answer: The reasons are as follows:
The crystal oscillator generates mechanical vibrations of a fixed frequency through electrical excitation, and the vibration will generate current feedback to the circuit. After receiving the feedback, the circuit amplifies the signal and uses the amplified electrical signal to excite the mechanical vibration of the crystal oscillator again. The crystal oscillator then feeds back the current generated by the vibration to the circuit, and so on. When the excitation electrical signal in the circuit is the same as the nominal frequency of the crystal oscillator, the circuit can output a strong signal and a stable frequency sine wave. The shaping circuit then converts the sine wave into a square wave and sends it to the digital circuit for use.

The problem is that the output capacity of the crystal oscillator is limited. It only outputs electrical energy in milliwatts. Inside the IC (integrated circuit), this signal must be amplified hundreds or even thousands of times by an amplifier before it can be used normally.

The crystal oscillator and IC are usually connected by copper wires. This wire can be regarded as a section of wire or several sections of wire. When the wire cuts the magnetic lines, it will generate current. The longer the wire, the stronger the current generated.

In reality, magnetic lines are not common, but electromagnetic waves are everywhere, such as: wireless broadcast transmission, TV tower transmission, mobile phone communication, etc. The connection between the crystal oscillator and the IC becomes a receiving antenna. The longer it is, the stronger the received signal is, and the stronger the electric energy generated is. Until the strength of the received electric signal exceeds or approaches the signal strength generated by the crystal oscillator, the output of the amplifier circuit in the IC will no longer be a square wave of fixed frequency, but a messy signal, causing the digital circuit to fail to work synchronously and make mistakes.

Therefore, when drawing a PCB (circuit board), the closer the crystal oscillator is to its amplifier circuit (IC pin), the better.


5. Questions about the crystal oscillator and speed of the microcontroller. Isn’t the cycle of executing an instruction determined by the crystal oscillator? For example, if you connect a high-speed crystal to a 51 microcontroller and a low-speed one to a 430 microcontroller, will the 51 run faster? Is the speed of a microcontroller only related to the crystal? The key is whether the microcontroller can support such a large crystal? Am I right?

Answer: The speed of each microcontroller is controlled by the internal logic gate level jump speed.
You are right. For a 51, if you use a higher crystal, the speed will be faster.
But it is different for advanced microcontrollers. Advanced microcontrollers generally have frequency control registers inside, so simply adding a crystal may reach the limit of the microcontroller and cause it to run away.


6. The relationship between the running speed of the microcontroller and the size of the crystal oscillator. If the highest operating frequency of the microcontroller is 40M, can the crystal oscillator be selected as 24M or higher, but not more than 40M? Will the running speed of the microcontroller be greatly increased? Will the long-term operation at this frequency have any adverse effects on the microcontroller? What is the principle of the microcontroller's selection of crystal oscillators? Thank you!
Answer: Of course there is an impact. The faster the microcontroller works, the greater the power consumption and the more interference it will suffer. In short, there is no problem with running at a maximum of 40M or less, but the related technologies (such as the selection of PCB design components, etc.) will be much higher.


7. May I ask: Is there any way to determine whether a certain microcontroller can work normally under a certain size of crystal oscillator?
Answer: The crystal oscillator is like the heart of the microcontroller.

It is not appropriate to choose a crystal oscillator that is too high. I am afraid that the specific upper limit of the crystal oscillator cannot be measured. It can only be measured according to the requirements of other microcontrollers. Generally, the upper limit of the STC series microcontroller is 35M or 40M. STC has it written on it, such as STC11F16XE 35I-LQFP44G, 35I is an industrial-grade chip with a maximum crystal of 35M.

What kind of problems will occur if the upper limit is exceeded? I have not tested it. Generally, 12M is more commonly used for crystal oscillators. If the STC 1T instruction is selected, it is equivalent to a 12*12=144M crystal oscillator. If it is used for serial communication, it is recommended to use 11.0592M or 22.184M. The most important thing to choose a crystal oscillator is to refer to the instructions of others.


8. Can 4 AT89C51 microcontrollers use a 12M crystal oscillator to make them all work normally? One uses the internal clock method, and the other three use the external method... Then can I use the internal method for all four (connect all 4 microcontrollers in parallel to one crystal oscillator)?
Answer: Yes, one of them is normally connected to the crystal oscillator, and its XTAL2 output is connected to the XTAL1 input of the other three.


9. Can the 4MHz crystal of AT89C51 microcontroller be started?
Answer: Of course, take a look at the datasheet. I estimate that 1M is OK.
Some microcontrollers such as 2051 may be OK.
Some Taiwanese and Japanese microcontrollers can reach 32.768kHz.


10. The reset circuit of 89c51 microcontroller often uses 12MHZ crystal oscillator, but in fact, the market is slightly less than 12MHZ. Why? Urgent
answer: When serial communication is required, 11.0582MHZ is generally used, so that the baud rate can be calculated.
The working cycle of 12MHZ is easy to calculate.


11. The crystal oscillator of the microcontroller does not oscillate when powered on, but it oscillates when touched by hand. Why?
Answer: Check whether the capacitors of the crystal oscillator are soldered and whether the values ​​are wrong?


12. How to judge whether the crystal oscillator of the microcontroller is oscillating? Urgent!!
Answer: The simplest way is to use an oscilloscope. In addition, you can check whether the power supply is normal.


13. How to judge whether the external crystal oscillator of the microcontroller is oscillating? My STC89C52 microcontroller was fine at first, but then it stopped working. I changed the crystal oscillator and it worked. But it stopped working again after a few hours. What's going on? And how to judge whether the crystal oscillator is oscillating?
Answer: First point: try to change a microcontroller first. If the problem still exists, exclude the microcontroller;
second point: it may be caused by cold soldering, so pay attention to this;
third point: I have encountered similar problems with STC89C52. I changed the crystal oscillator and it was OK. It seems that the STC oscillation is not as smooth as the AT89S52.
In fact, for STC89C52, you can directly look at the 30th pin (ALE), connect a light, and you can see the oscillation immediately.


14. I use the msp430 microcontroller, but the two external crystal oscillators always cannot oscillate, so it is useless. What is the reason? The line connection is correct, and there is no external capacitor connected to 32768HZ. The 8M crystal oscillator is connected to a 56PF capacitor.
Answer: Try connecting the 32.768K crystal oscillator to two 30P capacitors, and also change the capacitor of the 8M crystal oscillator to 30P.


15. How long does it take for the counter TAR to increase once for the 8MHz crystal oscillator of the MSP430 microcontroller?
Answer: The crystal oscillator frequency of the MSP430 microcontroller can be set by yourself. Whether to use an external crystal oscillator or an internal oscillator as the clock source, as well as the selection of MCLK, SMCLK, ACLK, whether to divide the frequency, etc., all have an impact. I have forgotten it now, but you can look at the document to see which one of mclk, smclk, and ACLK the counter uses, and when judging whether to divide the frequency setting, generally at 1Mhz TAR is 1us, so 8M is 1/8us, you can calculate it yourself.


16. If the MSP430 microcontroller does not initialize the crystal oscillator, what does the microcontroller use as the clock? What is the approximate frequency of the DCO?
Answer: Internal DCO. The default frequency of DCO in different series is different. Please refer to the manual. The 4 series seems to be 1M.


17. Can the external crystal oscillator start the blank microcontroller without a program?
Answer: For microcontrollers without internal crystal oscillators, the external crystal oscillator can start the oscillation. For example, for microcontrollers with internal crystal oscillators in the traditional MS51 series microcontrollers, the external crystal oscillator will not start the oscillation. The external crystal oscillator needs to be configured before it can start the oscillation. If the external crystal oscillator is not configured and the internal crystal oscillator is still used, such as the silicon lab series c8051f** microcontroller


18. The dspic30f6014 microcontroller can burn the program but cannot run it. The crystal oscillator does not start oscillating (it has been replaced but it does not work), the reset voltage is measured to be 5V, the power supply is normal, (it is a mature product, this situation only occurs occasionally)
Answer: 01. Re-examine the parts used in the oscillation circuit (crystal oscillator and capacitor) and the PCB layout near the crystal oscillator
02. Check whether the configuration bits are correct
03. You can also consult FAE


19. Why does at89c52 P1.0 output 2.5V voltage, and the microcontroller does not seem to work. Is it possible that the crystal oscillator waveform is an irregular sine wave? The circuit board did not achieve the expected effect, and the light-emitting diode was always on. It seems that it is still a problem with the microcontroller. P1.0 outputs 2.5V voltage, and the watchdog uses X5045. I don’t know why I have been looking for it for several days.

Answer: Remove the watchdog and temporarily make it a minimum system, which only has power supply, 8952, crystal oscillator and two 30P capacitors.
1. Set the P1.0 port to 1 and test whether the voltage of the port is above 2.5V;
2. Set the P1.0 port to 0 and test whether the voltage of the port is about 0V.
If yes, it is OK, otherwise you need to check the power supply voltage, crystal oscillator, and 8952. The power supply voltage is 5+, -0.25V, and the ripple must be small.


20. Will the microcontroller have any impact on the working state when testing the crystal oscillator voltage?
My 51 microcontroller is connected to two light-emitting diodes from the P2 port. Normally, only one is on. After I plugged in the power supply, both of them were on. So I measured the crystal oscillator voltage, but my black test lead was grounded. When the red test lead touched the crystal oscillator pin, one of the two light-emitting diodes would go out, and when it was released, both would be on.
Every time I just plugged in the power supply, the two crystal oscillator pins were 1.9V and 1.5v respectively, but after a while, the two pins became 5.4V and 0.02V respectively.
Answer: There will be a little impact, which will affect the frequency, and in severe cases, it will cause the crystal oscillator to stop oscillating. Because once you add a multimeter, it is equivalent to adding a part of the capacitor, resistor, inductor, etc. in parallel or in series to the oscillation circuit, which affects the state of the original circuit.


21. When making a max232 download microcontroller, the working voltage is normal. Do you need to add an external crystal oscillator? Answer
: Of course, if there is no external crystal oscillator, the clock circuit of the microcontroller will be gone, resulting in the microcontroller serial port being unable to transmit data, and ultimately your download device will not be able to download programs.


22. What is the effect of the static operating point on the crystal oscillation?
Answer: A crystal oscillator with a high Q value is not sensitive to the choice of amplifier, but it is easy to produce frequency drift (or even damage) when overdriven. Environmental factors that affect the operation of the oscillator include: electromagnetic interference (EMI), mechanical vibration and shock.


23. I use an external 4M crystal oscillator plus two 30pf ceramic capacitors. The frequency is normal when measured with an oscilloscope, but the peak-to-peak value of some boards is about 6V, and that of others is about 3V. The board functions normally, but I am afraid that the voltage is low and unstable. I don’t know if there is any basis or relevant information for crystal oscillator testing. Thank you very much!!!
Answer: It doesn’t matter. The difference in peak-to-peak value is caused by the discrete parameters of the capacitor and crystal oscillator. As long as it works normally, it’s fine. There are amplification processes in the microcontroller, and they are all amplified and expanded into square waves for use. It doesn’t matter how high the peak-to-peak value is.
You should check your high voltage. The general working voltage of pic is 5V. How can the oscillator have such a high voltage? I usually use a resistor in series at the input end of the CPU crystal oscillator.


24. I use an external 4M crystal oscillator plus two 30pf ceramic capacitors. The frequency is normal when measured with an oscilloscope, but the peak-to-peak value of some boards is about 6V, and some is about 3V. The board functions normally, but I am afraid that the voltage is low and unstable. I don’t know if there is any basis or relevant information for crystal oscillator testing. Thank you very much!!!
Answer: It doesn’t matter. The difference in peak-to-peak value is caused by the discrete parameters of capacitors and crystal oscillators. As long as it works normally, it’s fine. There are amplification processes in the microcontroller, and they are all amplified and expanded into square waves for use. It doesn’t matter how high the peak-to-peak value is.
You should check your high voltage. The general working voltage of pic is 5V. How can the oscillator have such a high voltage?
I usually use a resistor in series at the input end of the CPU crystal oscillator.


25. How should the active crystal oscillator of pic microcontroller AD sampling program be selected?
If the on-chip oscillator is used, is it necessary to connect an external resonator?
If I connect an external active crystal oscillator, which frequency is better? I heard that 4MHz is not ideal. Is it okay to connect an external 20MHz? How do I choose this?
A: Using the internal oscillator does not require an external resonator.
If your microcontroller only performs AD acquisition and conversion, then you do not need a very high frequency, and the internal 4Mhz oscillator is sufficient.
But if you need to do other tasks with strict timing requirements, such as bus communication, you should consider using an external oscillator, because the error of the internal oscillator is too large (even after calibration, there is still a 1% error). The size of the crystal oscillator depends on the work requirements. The higher the frequency, the greater the power consumption of the microcontroller. But if you only do AD, 4M is enough.


26. Hello everyone. I would like to ask a question about the PIC microcontroller: the crystal oscillator frequency is different. Are the delay functions in the compiler's own library the same? For example, are the crystal oscillator 20MHZ delayus(1) and 5MHZ delayus(1) both 1us?
Answer: They should be the same.
Because the frequencies are different, your settings are different when compiling, so the required multiples are naturally calculated when compiling, and the parameters are different.
But there may be a little difference because the frequency cannot be divided exactly.


27. How to write a 1ms benchmark delay function in C language for a 24M crystal oscillator connected to the microcontroller?
Answer: Timer T0 Working mode 1 Crystal oscillator frequency 24MHz
Timer maximum timing time (us): 32768
Timer minimum timing time (us): 0.5
[1ms precise timing C51 code]
void T0_init(void) //Timer initialization
{
TMOD |= 0x01;
TH0 = 0xf8; //Set the timer count initial value, timing 1000us
TL0 = 0x33;
IE |= 0x82; //Open the general interrupt
TR0 = 1; //Start the timer
}
void T0_intservice(void) interrupt 1 //Timer interrupt service
{
TH0 = 0xf8; //Reload the initial value of the timer count
TL0 = 0x33;
//Other processing programs can be inserted here without affecting the timer operation
}


28. Can a 24M crystal oscillator of a single-chip microcomputer measure a 20MHZ signal?
Answer: It depends on the single-chip microcomputer. Some single-chip microcomputers need more than two machine cycles to execute an instruction. Then it is definitely impossible to measure a 20MHZ signal.


29. Which is better, using the crystal oscillator circuit of a single-chip microcomputer to generate a signal or using a 555 timer to generate a signal?
Answer: Generally speaking, the stability of a crystal oscillator is better than that of an RC oscillator.


30. What circuit can make a 32768 crystal oscillator generate a 32768 square wave signal?
Answer: Using a NOR gate, the task of oscillation and square wave shaping can also be completed. The circuit is shown in the illustration.
The crystal oscillator in the figure was originally 38000Hz. If it is changed to 32768Hz, it can also work normally.


31. How does the crystal oscillator generate a sinusoidal signal? Please explain in detail from the circuit aspect.
Answer: The crystal can be equivalent to an inductor, which forms an oscillation circuit with the capacitor inside. The energy slowly flows from the inductor to the capacitor, and then from the capacitor to the inductor, and the oscillation is formed over and over again. The positive half cycle is the charging and discharging process of the capacitor, and the negative half cycle is the charging and discharging process of the inductor.


32. Which pins of the 11.0952 crystal oscillator and the microcontroller should be connected to work? Which pins of the microcontroller should the power supply and 18B20 be connected to? RT, how should the microcontroller be connected to the experimental board? How should the 1602 LCD liquid crystal be connected to the microcontroller? Every time it is connected from the simulation, there is only backlight and black dots, but the burned program is not displayed.
Answer: The crystal oscillator is connected to the microcontroller x1 (or XTAL1) and x2 (or XTAL2) pins.
The power supply is connected to the VCC and GND of the microcontroller.
The 18b20 power pin is connected to the power supply, and the data line in the middle can be any io port of the microcontroller. The specific control is completed by the program. The
1602 data line is connected to the microcontroller io (such as the P1 port of the 51 microcontroller), and the other control lines rw, reset, cs, etc. can be connected to any io port of the microcontroller.
If the program cannot run after burning, and the program is correct, you have to see how the program defines these pins and connect the position of the microcontroller according to the program definition.


33. I am now going to use a 52 microcontroller to make a traffic light circuit. The requirements are red light, green light 30s, yellow light 3s. Cycle change. So how to choose an external crystal oscillator? What is the appropriate single instruction cycle? What is the role of the two external capacitors in the figure? What is the appropriate size?
Answer: If you choose a crystal oscillator, the two capacitor values ​​can be selected: 30 plus or minus 10PF (frequency between 0~33MHZ);
if you choose a ceramic crystal oscillator, the capacitor value can be selected: 40 plus or minus 10PF (frequency between 1.2~12MHZ). The oscillator should be as close to the capacitor as possible. The instruction cycle can be calculated, and there is a formula for this!


34. What will happen if the 89c52 microcontroller is not connected to a crystal oscillator?
Answer: The microcontroller does not work and the program cannot be burned in. . . . 35.


If the 89c52 microcontroller uses an external crystal oscillator, how should it be set?
Answer: Connect a 20~30pf capacitor to each of the two pins of the crystal oscillator and then connect them to the XTAL1 and XTAL2 of the microcontroller respectively. Connect the other ends of the two capacitors in parallel and then ground them. No further settings are required.


36. The crystal oscillator frequency of the 89c52 microcontroller is only 12MHz, which is too small. How can the crystal oscillator frequency be increased?
Answer: Use an external 18.432 or 24MHz crystal oscillator. Or change to a 4T W77E58 microcontroller, which is equivalent to increasing the operating frequency by 3 times. Or change to a 1T DS89C4XX microcontroller, which is equivalent to increasing the operating frequency by 8 times! Is that enough? Using a 1T STC12C5A** microcontroller also has this effect.


37. Regarding the operating frequency of the microcontroller, how do you choose the crystal oscillator?
Answer:
1. The machine operating frequency of the most basic microcontroller is: crystal oscillator frequency ÷ 12
2. The machine operating frequency of some microcontrollers (more advanced ones) is: crystal oscillator frequency ÷ 2 (or 6, etc.)
3. Taking assembly language as an example, the time required for a microcontroller to execute an instruction is 1~2 machine cycles (machine cycle = 1÷machine operating frequency)

4. For example:
an ordinary microcontroller crystal oscillator is 12MHz, and its machine operating frequency is 12MHz÷12 = 1MHz.
Its machine cycle = 1÷1MHz = 0.000001 seconds (that is, 10 to the negative sixth power)
The "MOV" instruction requires one machine cycle to complete, which means that it takes 10 to the negative sixth power seconds to execute this instruction, such a long time.


38. How to choose the size of the capacitor connected to the crystal oscillator of the 51 microcontroller? Is the larger the crystal oscillator, the larger the capacitance value should be? What size is generally used? Some people say that the commonly used range is from 15-33pf. How to choose the best effect? ​​For example, if I use a 6M and a 12M crystal oscillator respectively, what capacitor is more suitable?

Answer: 15-33pf is fine. We usually use 15P and 30P. The size of the crystal oscillator has little effect. We often use 4M and 12M, as well as 11.0592M and 20M 24M. We all use 30P. The microcontroller has a corresponding shaping circuit inside. We don't have to worry about it.


39. What will happen if I connect a 2200pF capacitor to a 51 microcontroller 12M crystal oscillator? The circuit diagram seems to be 22pF, but I don't have 22pF... Will it not work properly if I connect 2200pF?

Answer: No, the crystal will not work. 15-33p is a reasonable range. You can try it, it will not damage the microcontroller.


40. The microcontroller cannot work properly. Is it a crystal oscillator problem? How to check whether the crystal oscillator is normal or not? In addition, I saw that the crystal oscillator should be very close to the two small capacitors. I almost didn't cut the pins (just the length I bought them) and plugged them in. Does this have anything to do with it?

Answer: Use a multimeter to measure the two pins of the microcontroller connected to the crystal oscillator. Under normal oscillation, the voltage is about 1/2 of the power supply voltage. If one or all of the pins are at the power supply voltage or zero, it means that there is no oscillation. Which pin is longer generally does not have any effect. In comparison, grounding is more critical. The grounding ends of the two resonant capacitors should be as close to the power ground of the microcontroller as possible.

Reference address:Summary of 40 MCU crystal oscillator problems and solutions

Previous article:The eight most important steps to learn microcontrollers
Next article:7 design principles of single chip microcomputer hardware system

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号