PIC microcontroller FAQ

Publisher:SereneHarmonyLatest update time:2012-12-18 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. How to choose the crystal in the PIC microcontroller oscillation circuit?

For a high-reliability system design, the choice of crystal is very important, especially for systems with sleep wake-up (often using low voltage for low power consumption). This is because the low supply voltage reduces the excitation power provided to the crystal, causing the crystal to start oscillating very slowly or not at all. This phenomenon is not particularly obvious during power-on reset, because the circuit has enough disturbance at power-on, and it is easy to establish oscillation. During sleep wake-up, the circuit disturbance is much smaller than that at power-on, and it becomes very difficult to start oscillation. In the oscillation circuit, the crystal cannot be over-driven (easy to oscillate to high harmonics) or under-driven (not easy to start oscillation). The selection of crystal must at least consider: resonant frequency, load capacitance, excitation power, temperature characteristics, and long-term stability.

2. How to determine whether the crystal oscillator in the circuit is overdriven?

Resistor RS is often used to prevent crystal oscillators from being overdriven. Overdriving a crystal oscillator will gradually wear out and reduce the contact plating of the crystal oscillator, which will cause the frequency to rise. An oscilloscope can be used to detect the OSC output pin. If a very clear sine wave is detected, and the upper and lower limits of the sine wave meet the clock input requirements, the crystal oscillator is not overdriven; on the contrary, if the peaks and troughs of the sine waveform are flattened, making the waveform square, the crystal oscillator is overdriven. At this time, resistor RS is needed to prevent the crystal oscillator from being overdriven. The easiest way to determine the value of resistor RS is to connect a 5k or 10k fine-tuning resistor in series, starting from 0 and slowly increasing it until the sine wave is no longer flattened. This method can find the closest resistor RS value.

3. How to choose capacitors C1 and C2 in the crystal oscillator circuit?

(1) Because each crystal oscillator has its own characteristics, it is best to select external components according to the values ​​provided by the manufacturer.

(2) Within the permissible range, the lower the C1 and C2 values, the better. A larger C value is beneficial to the stability of the oscillator, but it will increase the start-up time.

(3) The value of C2 should be greater than the value of C1. This will speed up the crystal oscillator start-up when power is turned on.

4. What are the characteristics of the I/O pins of the PIC series microcontrollers?

Any I/O pin of the PIC series microcontroller has a strong load capacity (at least 25mA of current can be provided or injected). Therefore, in some occasions, these pins can be used as a controllable power supply. For example, in some low-power designs, it is hoped that some peripheral devices will not consume power or consume as little power as possible when the system is on standby.

At this time, you can consider that the power supply of these devices is provided by an I/O pin. When working, the MCU outputs a high level (close to VDD) on this pin, and it is absolutely no problem to carry a load of several mA. If you want to enter low power mode

The MCU outputs a low level (close to 0) on this pin, and the controlled device will not consume power without power.

Display circuits, signal modulation circuits, etc. are very suitable for this type of control.

5. Why can't the system work properly when it is disturbed by external magnetic and electric fields?

If there is no filter circuit in the main control circuit, the chip you use should be connected to a circuit at the /MCLR end that can filter out the narrow pulses on the port. The low level width added to /MCLR should be greater than 2US to reset the system, and a low level less than 2US will interfere with the normal operation of the system.

6. When using a PIC chip with A/D, how can the accuracy of A/D conversion be improved?

(1) Ensure that the clock of your system is appropriate. If you turn off/on the A/D module, you should wait for a period of time, which is the sampling time; if you change the input channel, you also need to wait for this period of time and the final TAD (TAD is the time required to complete each bit of A/D conversion). TAD can be selected in ADCON0 (ADCS1, ADCS0), and it should be between 2US-6US. If TAD is too small, it will not be completely converted at the end of the conversion process; if TAD is too long, the voltage on the sampling capacitor will drop before all conversions are completed. For specific details on the selection of this time, please refer to the relevant data sheet or application formula.

(2) Usually, if the resistance of the analog signal input is too high (greater than 10Kohms), the sampling current will decrease, thus affecting the conversion accuracy. If the input signal cannot change quickly, it is recommended to use a 0.1UF capacitor at the input channel port.

It will change the sampling voltage of the analog channel. Due to the current supply, the internal holding capacitor is 51.2PF.

(3) If not all A/D channels are used up, it is best to use AN0 less, because its next pin is close to OSC1, which will affect the A/D conversion.

(4) Finally, in the system, if the chip frequency is low, the A/D conversion clock is preferably the chip oscillation. This will greatly reduce the impact of digital conversion noise. At the same time, in the system, after the A/D conversion starts and enters the SLEEP state, the RC oscillation inside the chip must be selected as the A/D conversion clock signal. This method will improve the accuracy of the conversion. [page]

7. Can the RC oscillator on the A/D chip of PIC16C7XX be used for a counter?

The function of the RC oscillator inside the 16C71A/D converter is to allow a clock source to perform A/D conversion when the MCU is in sleep mode (the main oscillator is stopped at this time). This RC oscillator cannot be used by other circuits due to its internal design limitations. The typical value of the internal RC oscillator clock frequency of the A/D converter is 250K, but it will vary considerably with the ambient temperature, operating voltage, product batch number, etc. The clock source of the timer can be selected from the internal oscillation frequency or the external pulse input signal. If you can choose the latter, it will be convenient to achieve a high main frequency of the MCU and a low clock overflow rate. Otherwise, there seems to be no other trick except using software to count and divide. Another option is to use other types of MCUs, which have at least another TIMER1 inside, because TIMER1 can have an independent crystal as the reference for the clock oscillation, and you can easily choose a low-frequency crystal to complete your design.

8. Why can't the security bit be burned to "Secret" when using PICSTAR-PLUS to program 16CE625-04/P?

When using PICSTAR-PLUS to program the chip, the program code is placed in the computer's RAM. Each time you write a program, you download the data to the programmer through the serial port for programming, so errors may occur. I don't doubt that you have a problem with your operation, but please note that PICSTAR-PLUS is a programmer for development purposes and is not recommended for mass production. You can calculate that the error probability is 1%, so it seems that you are using it for mass production. To ensure reliable programming, I recommend that you use the PICKIT programmer produced by Gaoqi Company.

9. Why does the PIC microcontroller sometimes work normally when powered on, but cannot wake up after entering sleep mode?

(What are the things to pay attention to when selecting crystals in PIC microcontroller applications?)

For a high-reliability system design, the choice of crystal is very important. In the oscillation circuit, the crystal should be neither over-driven (easy to oscillate to high harmonics) nor under-driven (difficult to oscillate). Especially in the design of a system with sleep wake-up (often using low voltage for low power consumption), if you just use a crystal, your system may have problems. This is because the low power supply voltage reduces the excitation power provided to the crystal, causing the crystal to oscillate very slowly or not at all. This phenomenon is not particularly obvious during power-on reset,

The reason is that when the circuit is powered on, there is enough disturbance, so it is easy to establish oscillation. When waking up from sleep mode, the disturbance of the circuit is much smaller than when powered on, so it is very difficult to start oscillation.

Some people have commented on why the PIC microcontroller has such high requirements for crystals? It seems that using 51 has never been so troublesome. You can use whatever you can get your hands on, and there is no problem. Wait a minute, the premise of this comparison is not the same. Also, when sleeping, has anyone seen the 51 series not need a reset but only rely on internal or external events to wake up? If you don't need such advanced design technology, PIC can also let you use whatever crystal you can get.

A simple way to evaluate whether the oscillation circuit is working at the best point is to use an oscilloscope to view the waveform on the OSC2 pin (the capacitance connected to the oscilloscope must be considered!). The best case scenario is to see a very clean and beautiful sine wave without any waveform distortion, and at full amplitude (close to VCC and GND). The selection of the crystal must at least consider: resonant frequency, load capacitance, excitation power, temperature characteristics, and long-term stability.

12. How to identify the temperature level of the PIC microcontroller model?

Take 16C54-04X/P as an example:

X = None, commercial grade, temperature range is 0-70°C;

X = I, industrial grade, -40-85℃;

X = E, automotive grade, -40-125℃;

For example: PIC16C54C-04/P commercial grade PIC16C54C-04I/P industrial grade PIC16C54C-04E/P automotive grade.

13. Do the various interrupts of PIC microcontrollers have different priorities?

The mid-range PIC microcontroller has only one interrupt entry, and the hardware does not prioritize it, but the priority can be determined by software query: the first query is the first action, and the priority is high. The high-end 17 and 18 series, including the upcoming 16-bit dsPIC, have hardware priority for interrupts.

14. What do the suffixes A/B/C stand for in the PIC microcontroller model?

In the PIC microcontroller model, the suffix A/B/C indicates that the chip production process is different. From A to C, the process is constantly updated. The diameter of the silicon wafer disk (wafer) becomes larger, the line width becomes narrower, and the line spacing becomes denser. More chips can be made on the same disk, thereby reducing production costs. From a functional point of view, the three are the same. Of course, the new version of the chip will correct some problems existing in the existing version, and the function will be expanded. In terms of performance indicators, there are some differences among the three. One obvious manifestation is the tolerance range of the power supply voltage. The thinner the production line width, the lower the voltage that can be tolerated. For example, the maximum power supply voltage indicator of PIC16C57 is 6V, while the indicator of 57C is 5.5V. In most cases, the new version of the chip can directly replace the old version. From the current problems found, the main problem is the crystal oscillator circuit. The reason is that the gain of the reverse amplifier inside the oscillator circuit of the new version of the chip is much higher than that of the old one. If the crystal is not selected reasonably, it may oscillate to high-order harmonics. . Some customers also pointed out that the anti-interference performance of the new version of the chip is not as good as the old version.

In fact, the technical indicators we published did not sacrifice anything in this aspect, but due to the process, we reduced the margin. Please be careful not to think that the PIC chip has strong anti-interference ability and not consider the necessary anti-interference measures when designing the circuit.

Reference address:PIC microcontroller FAQ

Previous article:What are the characteristics and advantages of PIC microcontrollers?
Next article:PIC microcontroller assembly instructions

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号