Summary of the invention
The objective of the invention is to overcome the deficiencies in the prior art, a kind of MCU truthlikeness inspection method and check circuit thereof are provided, can easily realize the truthlikeness inspection of MCU, improved reliability of products greatly, and improved efficient, reduced cost.
In order to achieve the above object, the technical solution used in the present invention is, a kind of MCU truthlikeness inspection method, and its step is as follows:
Step 1, truthlikeness scrutiny program begin;
The ADC of step 2, switching MCU detects mouth and becomes common IO state by the ADC detected state;
Step 3, export high level and keep a period of time;
Step 4, more common IO state is switched to the ADC detected state, read current AD value;
Step 5, judge that whether current AD value is in normal range;
Step 6, current AD value are in normal range, and then ADC detection mouthful function is normal, skips to step 8; Current AD value is not in normal range, and it is impaired that then ADC detects mouthful function, execution in step 7;
Step 7, enter the corresponding protection program;
Step 8, the next loop program of carrying out.
A kind of truthlikeness check circuit that utilizes described MCU truthlikeness inspection method is located on the PCB circuit board, and this circuit is made up of bleeder circuit, condenser network and MCU circuit successively.Bleeder circuit is made up of pull-up resistor R1 and pull down resistor R2, and condenser network is made up of the capacitor C 1 that plays pressure stabilization function, and the MCU circuit is by the abbreviation that has A/D converter ADC(Analog-to-Digital Converter) MCU that detects mouth forms.Pull-up resistor R1 one termination power VDD, VDD is a constant voltage source, another termination pull down resistor R2, pull down resistor R2 other end ground connection, the ADC of MCU detects mouth and is connected between pull-up resistor R1 and the pull down resistor R2, and capacitor C 1 one ends connect ADC interface, other end ground connection.
Compared with prior art, the invention has the beneficial effects as follows: the simple and efficient MCU truthlikeness is checked of the method energy, and under normal condition, can be used as testing circuits such as temperature sensor, pressure transducer at circuit based on the truthlikeness inspection method, when starting the truthlikeness scrutiny program as the truthlikeness check circuit, realized the purpose of two kinds of functions of a kind of circuit, reduce the use of components and parts, greatly reduced the cost of product design, improved reliability of products simultaneously.
Embodiment
Purport of the present invention is to overcome the deficiencies in the prior art, and a kind of MCU truthlikeness inspection method and testing circuit thereof are provided, and can check out whether the MCU detection mouth of household electrical appliance such as electromagnetic oven, soy bean milk making machine damages simply and easily, is beneficial to timely maintenance.
To use the ADC of MCU to detect a mouthful function under the normal condition, to guarantee that at first ADC detects the work that mouth itself can be safe and reliable, the method of Cai Yonging is generally speaking: common constant voltage source VDD of extra increase outside check circuit, because the voltage of constant voltage source is known, it should be certain detecting mouthful data that read by ADC, such as voltage source is 5V, ADC detects a mouthful value that reads also should be 5V, just represent that it is not damage that this ADC detects mouth, if but when detecting a value that mouth reads for other value, ADC detects mouthful a damage own, if detecting mouth itself damages, it just may be wrong detecting mouthful data that read by this so, and these data have not just had meaning, so the purpose of truthlikeness inspection will guarantee that it itself is not damage that ADC detects mouth.
Be elaborated with reference to accompanying drawing below in conjunction with embodiment, so that technical characterictic of the present invention and advantage are carried out more deep annotation.
Circuit theory diagrams of the present invention as shown in Figure 1, a kind of MCU truthlikeness inspection method, its step is as follows:
Step 1, truthlikeness scrutiny program begin;
The ADC of step 2, switching MCU detects mouth and becomes common IO state by the ADC detected state;
Step 3, export high level and keep a period of time;
Step 4, more common IO state is switched to the ADC detected state, read current AD value;
Step 5, judge that whether current AD value is in normal range;
Step 6, current AD value are in normal range, and then ADC detection mouthful function is normal, skips to step 8; Current AD value is not in normal range, and it is impaired that then ADC detects mouthful function, execution in step 7;
Step 7, enter the corresponding protection program;
Step 8, the next loop program of carrying out.
A kind of truthlikeness check circuit that utilizes described truthlikeness inspection method is located on the PCB circuit board, and this circuit is made up of bleeder circuit, condenser network and MCU circuit successively.Bleeder circuit is made up of pull-up resistor R1 and pull down resistor R2, and condenser network is made up of the capacitor C 1 that plays pressure stabilization function, and the MCU circuit is by the abbreviation that has A/D converter ADC(Analog-to-Digital Converter) MCU that detects mouth forms.Pull-up resistor R1 one termination power VDD, VDD is a constant voltage source, another termination pull down resistor R2, pull down resistor R2 other end ground connection, the ADC of MCU detects mouth and is connected between pull-up resistor R1 and the pull down resistor R2, and capacitor C 1 one ends connect ADC interface, other end ground connection.
When operate as normal, because the dividing potential drop effect of resistance R 1 and R2, the voltage that obtains at the ADC of MCU detection mouth is:
If but export a fixing level for the voltage detecting mouth of MCU
A period of time,
Be high level or low level,
Level will become VDD or GND, change in a short period of time then by ADC and detect a mouthful inspection peripheral circuit voltage, because the voltage at capacitor C 1 two ends can not suddenly change fixed voltage
Can not change at once
, by checking fixed voltage
Intensity of variation in the set time just can judge that this MCU detects mouth and whether occurs damaging, if to be the level with output just now identical or change very little for the voltage that is checked through, the ADC detection mouth that MCU is described is normal, if change a lot, the ADC detection mouth that MCU is described just might be impaired, and the data that collect from peripheral circuit are exactly insecure like this.
The peripheral circuit that bleeder circuit and condenser network are formed also be used in other purposes, just finishing the truthlikeness inspection in very short time, change R1 into temperature sensor or pressure transducer, then is temperature or pressure check circuit, not needing increases power module in addition, and has effectively reduced cost.
Made clear and complete description although how the present invention carries out the truthlikeness inspection by instantiation to truthlikeness inspection method and circuit thereof, but the present invention is not limited only to described embodiment, and to reach same or similar effect be contingent and all be included in the present invention by simple reprogramming or circuit structure.