To learn the design of single-chip microcomputer, you must first understand these problems about crystal oscillators!

When I first learned about the 51 single-chip microcomputer, there were always a lot of questions about the crystal oscillator. In fact, the crystal oscillator is like the heart of a human being, and it is the pulse of the blood. After understanding the crystal oscillator problem of the single-chip microcomputer, other problems of the 51 single-chip microcomputer can be easily solved...


The problems related to the crystal oscillator of the 51 single-chip microcomputer are summed up together, and I hope it will be helpful to the children's shoes of the 51.


1. Why do 51 microcontrollers love to use 11.0592MHZ crystal oscillators?


One: Because it can be accurately divided into the clock frequency, it is related to the common baud rate of the UART (Universal Asynchronous Receiver/Transmitter). Especially with higher baud rates (19600, 19200), no matter how outlandish the values, these crystals are accurate and are often used.


Second: the reason for using the 11.0592 crystal oscillator is caused by the timer of the 51 single-chip microcomputer. When using the timer of the 51 single-chip microcomputer as the baud rate generator, if a 11.0592Mhz crystal oscillator is used, the values ​​that need to be set by the timer are all integers according to the formula; if a 12Mhz crystal oscillator is used, the baud rate is biased. For example, 9600, use the timer to take 0XFD, the actual baud rate is 10000, and the general baud rate deviation is about 4%. The error rate of the multiple is 8.51%, and the data will definitely be wrong. This is the reason why everyone likes to use 11.0592MHz crystal oscillator in serial communication. When the baud rate is doubled, the maximum can reach 57600, and the error rate is 0.00%. With 12MHz, the highest is 4800, and there is a 0.16% error rate, but it is within the allowable range, so it does not matter much.


2. Why is the crystal oscillator required to be next to the MCU when designing the 51 MCU system PCB?


The reasons are as follows: the crystal oscillator generates mechanical vibration of a fixed frequency through electrical excitation, and the vibration will generate current feedback to the circuit. After the circuit receives the feedback, the signal is amplified, and the amplified electrical signal is used to stimulate the mechanical vibration of the crystal oscillator again. The current generated by the vibration is fed back to the circuit, and so on. When the excitation electrical signal in the circuit and the nominal frequency of the crystal oscillator are the same, the circuit can output a sine wave with a strong signal and a stable frequency. The shaping circuit turns the sine wave into a square wave and sends it to the digital circuit for its use.


The problem is that the crystal oscillator has a limited output capability, it only outputs electrical energy in milliwatts. Inside the IC (integrated circuit), the signal can be amplified several hundred times or even a thousand times by an amplifier before it can be used normally.


The crystal oscillator and the IC are generally connected by a copper wire. This wire can be regarded as a section of wire or several sections of wire. The wire will generate current when cutting the magnetic line of force. The longer the wire, the stronger the current generated. In reality, magnetic lines of force are not common, but electromagnetic waves are everywhere, such as wireless broadcast transmission, TV tower transmission, mobile phone communication and so on. The connection between the crystal oscillator and the IC becomes a receiving antenna. The longer it is, the stronger the received signal and the stronger the electrical energy generated, until the received electrical signal strength exceeds or is close to the signal strength generated by the crystal oscillator. , the output of the amplifier circuit in the IC will no longer be a square wave with a fixed frequency, but a messy signal, which will cause the digital circuit to fail to work synchronously.


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


3. Analysis of the reasons why the crystal oscillator of the single-chip microcomputer circuit does not vibrate


It is a common phenomenon that the crystal oscillator of the single-chip microcomputer does not oscillate, so what are the reasons for the crystal oscillator not to oscillate?


① PCB board wiring error; ② There is a problem with the quality of the single-chip microcomputer; ③ There is a problem with the quality of the crystal oscillator; ④ The load capacitor or matching capacitor does not match the crystal oscillator or the quality of the capacitor is faulty; The trace is too long; ⑦ There is a trace between the two feet of the crystal oscillator; ⑧ The influence of the peripheral circuit.


Solution, it is recommended to troubleshoot one by one as follows:


① The possibility of circuit error is excluded, so it can be compared with the recommended circuit of the corresponding type of single-chip microcomputer. ② Eliminate the possibility of bad peripheral components, because the peripheral components are nothing more than resistors and capacitors, it is easy to identify whether they are good products. ③ Eliminate the possibility that the crystal oscillator is a stop-oscillation product, because it will not only try one or two crystal oscillators. ④Try to change the capacitors at both ends of the crystal, maybe the crystal oscillator can start to vibrate. Please refer to the instruction manual of the crystal oscillator for the size of the capacitor. ⑤ The traces of the crystal oscillator circuit should be as short as possible and as close to the IC as possible during PCB wiring, and avoid routing between the two feet of the crystal oscillator.


4. How is the value of the capacitor obtained when the 51 single-chip microcomputer clock circuit uses a 12MHZ crystal oscillator? Take the internal clock circuit to illustrate it!


In fact, no one can explain how to choose the value of these two capacitors, because 22pF is too small. This can only be said that it has something to do with the characteristics of the internal oscillator circuit itself. It is used in combination to correct the waveform. No one has gone to the depths of why it is such a large value.


5. What happens to the asymmetry of the two trimming capacitors in the single-chip crystal oscillator circuit? How much difference will the frequency change? The frequency gradually becomes smaller) The crystal oscillator is new!


The asymmetry of the capacitor will not cause the frequency drift. The frequency drift may be caused by the unstable capacity of the capacitor of the crystal oscillator. It can be replaced and tried. It is not difficult to replace two capacitors, or the stability of the crystal oscillator is too poor. , or there is a problem with the method of measurement.


6. Questions about the crystal oscillator and speed of the single-chip microcomputer. Isn't the cycle of executing an instruction determined by the crystal oscillator? So, for example, 51 single-chip microcomputer and MSP430, connect 51 to a high-speed crystal oscillator, and 430 to a low-speed one. Is the 51 running faster? Is the speed of the single-chip microcomputer only related to the crystal oscillator? The key is whether the single-chip microcomputer can support such a large crystal oscillator?


The speed of each microcontroller is limited by the transition speed of internal logic gates. The two chips use the same crystal oscillator, such as 12M. Because AVR is a RISC instruction set, it is faster than 51 at the same external crystal frequency.


For example, 51 can connect to 40M at the fastest, and AVR is a 16M crystal oscillator.


Most of STC89C52 use 12MHz crystal oscillator, but because its 12 clock cycles are only one machine cycle, it is equivalent to its main frequency is only 1MHz.


MSP430 adopts RISC simplified instruction set, if 430 single-chip microcomputer adopts internal DCO oscillation, the main frequency can reach 21MHz. A single instruction can be executed in a single clock cycle, and the same crystal oscillator is 12 times faster than the 51.


For a 51, give it a higher crystal and the speed will be faster. But it is different for advanced microcontrollers. There are generally frequency control registers inside the advanced single-chip microcomputer. Therefore, simply adding a crystal oscillator may reach the limit of the single-chip microcomputer, resulting in runaway.


7. Excuse me: Is there any way to determine whether a certain single-chip microcomputer can work normally under a certain size of crystal oscillator?


It is not suitable for the crystal oscillator to be too high. I am afraid that the upper limit of the crystal oscillator cannot be measured. It can only be determined according to the requirements of other microcontrollers. Generally, the upper limit of STC series microcontrollers is 35M or 40M, and the stc is only written on it. For example, STC11F16XE 35I-LQFP44G Among them, 35I is an industrial-grade chip with a crystal oscillator of up to 35M.


What kind of problems will occur when the upper limit is exceeded, I have not tested it. Generally, the crystal oscillator chooses 12M. If the STC 1T command is selected, it is equivalent to a crystal oscillator of 12*12=144M. If it is used for serial communication, it is recommended to use 11.0592M or 22.184M. The most important thing for choosing a crystal oscillator is to refer to other people's instructions.


8. Can 4 AT89C51 MCUs use a 12M crystal oscillator to make them all work normally? One uses the internal clock mode, and the other three use the external mode... The four can use the internal mode (connect all 4 MCUs in parallel) on a crystal)?


Yes, one of them is normally connected to the crystal oscillator, and his XTAL2 output is connected to the other three XTAL1 inputs.


9. The relationship between the running speed of the single-chip microcomputer and the size of the crystal oscillator, if the maximum operating frequency of the single-chip microcomputer is 40M, can the crystal oscillator choose 24M or higher, but not more than 40M, so will the running speed of the single-chip microcomputer increase greatly? Long-term at this operating frequency Is there any adverse effect on the single-chip microcomputer? What is the principle of the single-chip microcomputer for the selection of the crystal oscillator?


Of course, it has an impact. The faster the working speed of the single-chip microcomputer, the greater the power consumption, and the more severe the interference. In short, the maximum can run 40M, and there is no problem with running no more than 40M, but it is only for related technologies (such as The selection of PCB design components, etc.) will be much higher.


10. The 12MHZ crystal oscillator is often used in the reset circuit of the 89c51 microcontroller. In fact, it is slightly smaller than 12MHZ in the market. Why?


Answer: When serial communication is required, 11.0582MHZ is generally used, so that the baud rate is easy to calculate.


It is easy to calculate with the duty cycle of 12MHZ.


11. The crystal oscillator of the single-chip microcomputer does not vibrate when it is powered on, but it starts to vibrate when the crystal oscillator is touched by hand. Why? How to judge whether the crystal oscillator of the single-chip microcomputer starts to vibrate?


See if the capacitor matched with the crystal oscillator is soldered, is there any error in the value?


The easiest is to use an oscilloscope, and you can also see if the power supply is normal.


12. How to judge whether the external crystal oscillator of the single-chip microcomputer has started to vibrate? The STC89C52 single-chip microcomputer was originally good and then failed, and a crystal oscillator was replaced. But after a few hours it doesn't work again, what's going on. There is also how to judge whether the crystal oscillator is oscillating?


① Try to replace a single chip first, if the problem still exists, then rule out the single chip; ② It may be caused by virtual welding, you should pay attention to this; The vibration is not as smooth as the AT89S52. In fact, for STC89C52, you can directly look at pin 30 (ALE), connect a light, and you can see it when it starts vibrating.


13. How to choose the size of the capacitor connected to the crystal oscillator of the 51 single-chip microcomputer? Is the larger the crystal oscillator, the larger the capacitance value? It is generally used. Some people say that the commonly used range is 15-33pf. How to choose the best effect? ​​For example, if a 6M and 12M crystal oscillator are used respectively, how much capacitance is more suitable?


15-33pf can be used. Generally, 15P and 30P crystal oscillators are used, and the size has little effect. Commonly used 4M and 12M and 11.0592M and 20M and 24M use 30P. There is a corresponding shaping circuit inside the microcontroller, so don't worry.


14. Can the external crystal oscillator vibrate for a blank microcontroller without a program?


For single-chip microcomputers without internal crystal oscillators, the external crystal oscillators can start to vibrate. For example, traditional MS51 series single-chip microcomputers with internal crystal oscillators, the external crystal oscillators will not start to oscillate. The external crystal oscillators need to be configured before they can start to vibrate. Use internal crystal oscillator, such as silicon lab series C8051F020 microcontroller.


15. Why does the at89c52 P1.0 output 2.5v voltage, the microcontroller does not seem to be working, and the crystal oscillator waveform is an irregular sine wave? Output 2.5v voltage, X5045 for watchdog, what's going on?


Remove the watchdog and make it into the smallest system temporarily, which only has power supply, 8952, crystal oscillator and two capacitors of about 30P.


①Set the P1.0 port to 1, and test whether the voltage of the port is above 2.5V;


②Set the P1.0 port to 0, and test whether the voltage of the change port is about 0V.


If it is, it is OK. Otherwise, it is necessary to look at the power supply voltage, crystal oscillator, and 8952. The power supply voltage is 5+, -0.25V, and the ripple must be small


16. Make max232 download microcontroller, the working voltage is normal, do you need to add a crystal oscillator?


Of course, it must be added. If there is no external crystal oscillator, then the clock circuit of the single-chip microcomputer will be gone, resulting in the serial port of the single-chip microcomputer being unable to carry out data transmission, and finally the downloader will not be able to download the program.


17. If the 89c52 MCU uses an external crystal oscillator, how should it be set?


The two pins of the crystal oscillator are each connected to a 20~30pf capacitor and then connected to XTAL1 and XTAL2 of the microcontroller respectively. The other ends of the two capacitors can be connected in parallel and then grounded, and no settings are required.


Eighteen, the principle of crystal oscillator, how to generate sinusoidal signal, in detail, from the circuit analysis?


The crystal can be equivalent to an inductance, which forms an oscillation circuit with the capacitance inside. The energy slowly flows from the inductance to the capacitance, and then from the capacitance to the inductance, and the oscillation is formed again and 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.


Nineteen, now use 52 single chip microcomputer to make a traffic light circuit. The requirement is red light, green light 30s, yellow light 3s. cyclic change. So how to choose an external crystal oscillator? How much is a single instruction cycle more appropriate? What is the function of the two external capacitors in the figure? What is the appropriate size?


If you choose a crystal oscillator, the two capacitance values ​​can be selected: 30 plus or minus about 10PF (frequency between 0~33MHZ);


If you choose a ceramic crystal oscillator, the capacitance value can be selected: 40 plus or minus about 10PF (frequency is 1.2~12MHZ) The oscillator should be as close to the capacitor as possible. The instruction cycle can be calculated, this is a formula!


20. The crystal frequency of the 89c52 single-chip microcomputer is only 12 megabytes, which is too small. How can I change the frequency of the large crystal oscillator?


External 18.432 or 24MHz crystal oscillator. Or change the 4T W77E58 microcontroller, which is equivalent to 3 times the operating frequency. Or change the 1T DS89C4XX microcontroller, which is equivalent to increasing the operating frequency by 8 times! Using the 1T STC12C5A60S2 microcontroller also has the same effect.


21. The single-chip microcomputer can't work normally, the crystal oscillator problem? How to check whether the crystal oscillator is normal or not? In addition, I see that the crystal oscillator is very close to the two small capacitors, and almost no pins are cut (that is, how long it takes to buy it). How long) is plugged in, does this also matter?


Use a multimeter to measure the two pins of the single-chip microcomputer connected to the crystal oscillator. In the normal start-up state, the voltage is probably slightly lower than 1/2 of the power supply voltage. If one or all of the pins are the power supply voltage or zero, it means that the vibration is not started. The longer the pin is, it will generally not have any effect. In contrast, the grounding is more critical. The ground terminals of the two resonant capacitors should be as close as possible to the power supply ground of the microcontroller.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325744244&siteId=291194637