Circuit for detecting a fault state in a clock signal for microprocessor electronic devices

Abstract: A circuit (2) for generation of a reset signal in an electronic device (1) of the type comprising a microprocessor (3) interlocked with a circuit generating a clock signal and memories of both the volatile type (4) and the non-volatile type (5) is capable of detecting a stop in the oscillation of said clock signal and generating a logical signal coupled with the reset input of the microprocessor (3).

Description: Field of application The present invention relates to a circuit for detecting irregularities in a clock signal in electronic microprocessor devices. The present invention applies in particular but not exclusively to a microcontroller device comprising a microcontroller, non-volatile memories (ROM, EPROM, EEPROM or FLASH EEPROM) and volatile memories (RAM) as well as input and output communication gates (I/O) and the following description is given with reference to this field of application only for the purpose of simplifying discussion thereof. At present microcontrollers are amply used in devices requiring an intelligent electronic control simple and low in cost. For example they are used in the automobile field, automatic controls for industrial machine tools, safety devices, or in the new generation of electrical household appliances. To reach the high degree of reliability required in these devices there is a trend towards equipping the microcontrollers with circuits designed to prevent or correct malfunctions in the devices or in the peripheral circuits connected thereto. These malfunctions can occur during normal use of the microcontroller or following wrong use thereof, e.g. when the correct timings for the signals applied at its inputs are not respected. Prior art A typical circuit of this type inserted in many microcontrollers of the new generation is a circuit known to those skilled in the art as a "watchdog timer". This circuit was conceived to meet either hardware or software problems which can occur during operation of devices equipped with a microprocessor and its use was subsequently extended to the field of microcontrollers. The operating principle of said circuit is quite simple. The heart of the circuit is a counter whose internal register is increased to a frequency equal to the timing (clock) signal of the microcontroller or a submultiple of said frequency. When the contents of the register reach the highest value the circuit generates a hardware reset signal which reinitialises the microcontroller. By means of a special software instruction it is possible for a programme to periodically zero the contents of the internal register of the counter. The programme executed by the microcontroller calls for periodic zeroing to ensure correct operation of the entire system. Contrariwise, if there occurs either a software or a hardware irregularity and normal programme flow is interrupted, the register is no longer zeroed and the reset signal indicating malfunctioning reaches the microcontroller and reinitialises the system. Generally the reset signal, which is generated in the microcontroller by the circuit just described, is also transferred to the exterior through a special terminal present in the microcontroller. It is thus possible to also hold the peripheral circuits interfaced with the microcontroller in reset state. A known solution is disclosed in the US patent No. 4,633,097 relating to a clock monitor circuit for producing an output indication of the presence of an input clocking signal. Although advantageous in some ways, the known solutions exhibit a serious shortcoming described below. If following a failure in the circuit generating the clock signal said signal is interrupted, even the watchdog circuit counter is in turn stopped, preventing correct operation of the latter circuit. The microcontroller without the clock signal stops in a random unpredictable state. There can thus occur irregular situations in the microcontroller and also in the circuits interfaced therewith through the input and output communication gates (I/O). The technical problem underlying the present invention is to conceive a circuit capable of detecting irregularities in the clock signal and having structural and functional characteristics increasing the level of reliability of the microcontroller in which it is integrated and overcoming the limitations and shortcomings indicated above with reference to the prior art. Summary of the invention The solution idea underlying the present invention is to monitor the clock signal applied to the microcontroller and, if any irregularity is detected, generate a reset signal which would hold the microcontroller in a safe state. The reset signal is held until the clock signal generating circuit resumes normal operation. The technical problem is solved by a circuit of the type set forth in independent claim 1. In this manner it is avoided that in case of failure in the clock signal generating circuit the microcontroller and the peripheral circuits interfaced therewith are found in irregular and unpredictable situations. The characteristics and advantages of the circuit in accordance with the present invention are set forth in the description of an embodiment thereof given below by way of non-limiting example with reference to the annexed drawings. Brief description of the drawings FIG. 1 shows a schematic view of the essential parts of a microcontroller incorporating a detector circuit provided in accordance with the present invention for clock signal irregularities, FIG. 2 shows an electrical diagram of an embodiment of the irregularity detection circuit inserted in the microcontroller of FIG. 1, and FIG. 3 shows diagramatically the behaviour in time of a group of electrical signals present in the circuit of FIG. 2. Detailed description With reference to the figures reference number 1 indicates as a whole and diagramatically an electronic device with said microcontroller comprising in a single semiconductor chip a microprocessor 3, a ROM matrix 5, a RAM matrix 4 and input and output communication gates 6. These circuits 3, 4, 5 and 6 communicate with each other through a group of electrical connections 7 known as data and address busses with which they are interfaced. The non-volatile memory matrix 5 can be the electrically programmable and erasable type (EEPROM) or the read only type (ROM) and is used for memorising the sequence of instructions for the microprocessor 3. The volatile memory RAM 4 serves to temporarily store the data to be processed during execution of the programme. Through the input and output communication gates 6, which are also interfaced with the bus 7, the microcontroller 3 can exchange data with the external devices. Another block interfaced with the bus and indicated in the figures by 9 is a so-called "watchdog timer". As seen above, this circuit generates on one of its outputs a logical signal which reaches a first input 13 of a NAND logical gate 8. A second input 12 of said gate receives a reset signal coming from outside the microcontroller while a third input 11 is connected to the output of a circuit block 2. The output 10 of the NAND logical gate 8 is connected to the reset input of the microprocessor 3 and to the outside of the microcontroller through a special terminal indicated in the figures by RST_OUT. In this manner, if at least one of the three inputs of the NAND gate 8 has low logic level the microprocessor is reset. The circuit block 2 has an input 14 connected to the terminal CK of the microprocessor and on which is applied the clock signal. Said block 2 incorporates a circuit designed to detect irregularities in the clock signal. One embodiment of the circuit block 2 is shown in detail in FIG. 2. The input 14 of said block is connected to the control terminals of a first complementary pair of MOS transistors indicated by M1 and M2 and, through an inverting gate 15, to the control terminals of two other MOS transistors indicated by M5 and M6. Each pair of transistors is connected in series between a positive pole of the supply voltage generator Vcc and a negative pole of said generator, i.e. to the circuit ground. In particular, the source terminal of the transistor M1 is connected to the positive pole of the power supply generator Vcc while its drain terminal is connected to the drain terminal of the transistor M2. The source terminal of the transistor M2 is connected to the circuit ground. Similarly the source terminal of the transistor M5 is connected to the positive pole of the power supply generator Vcc while its drain terminal is connected to the drain terminal of the transistor M6. The source terminal of the transistor M6 is connected to the circuit ground. The drain terminals of the first pair of transistors M1 and M2 are connected together in the circuit node A and are also connected to a terminal of a first capacitor C1, to the drain terminal of a transistor M3 and to a first input of an AND logical gate 16. The second terminal of the first capacitor C1 is connected to the circuit ground. The drain terminals of the second pair of transistors M5 and M6 are connected together in the circuit node indicated by B and are also connected to a terminal of a second capacitor C2, to the drain terminal of a transistor M4 and to a second input of the logical gate 16. The second terminal of the second capacitor C2 is connected to the circuit ground. The control terminals and the source terminals of the two transistors M3 and M4 are both connected to the power supply line Vcc. The output terminal of the logical gate 16 constitutes the output terminal 11 of the circuit block 2. Operation of the circuit of FIG. 2 is now described. The clock signal present at the input 14 of the circuit, typically a square-wave signal, takes into conduction the transistors M1 and M2 alternately. Consequently the circuit node A to which is also connected a terminal of the capacitor C1 is taken through the conduction resistances Ron1 and Ron2 of the two transistors M1 and M2 to the power supply voltage Vcc and to ground alternately. In this manner the capacitor C1 is charged and discharged alternately through the two resistances Ron1 and Ron2. By dimensioning the transistors M1 and M2 in such a manner that the transistor M2 has a conduction resistance Ron2 much greater than that Ronl of the transistor M1, in rated operation the capacitor C1 is charged at the power supply voltage Vcc and keeps high the logic level of an input of the logical gate 16. The input 14 of the circuit is also connected through an inverting gate 15 to the control terminals of the second pair of transistors M5 and M6. The function of these two transistors is similar to that of the two transistors M1 and M2 and is to keep the capacitor C2 charged at the power supply voltage Vcc and hence hold a second input of the logical gate 16 at a high logic level. The two transistors M5 and M6 are dimensioned in such a manner that the internal resistance Ron5 of the transistor M5 is much greater than that Ron6 of the transistor M6. The output of the logical gate 16 which is type AND is thus held at a high logic level during normal operation of the circuit. If the clock signal present on the input 14 of the circuit stops at a high or low logic level, one of the two transistors M2 or M6 remains in conduction state and discharges the capacitor to which its drain terminal is connected. If one of the two capacitors C1 or C2 is discharged, taking one of the two inputs of the logical gate 16 to a low logic level, the output of said gate changes state and passes from high logic level to low logic level. This logic signal is transferred through a second logical gate indicated by 8 in FIG. 1 to the reset input 10 of the microprocessor 3. In this manner the microprocessor is held in the reset state until the clock signal is again enabled. The two transistors M3 and M4 whose control and source terminals are connected together act as diodes and consequently conduct if the voltage on the drain terminal exceeds the voltage on the other two terminals by a certain threshold value, typically less than one volt. The function of these transistors is to rapidly discharge the two capacitors C1 and C2 in case of an unexpected supply voltage failure so as to immediately reset the microprocessor. In this embodiment the transistors M2 and M6 are n-channel MOS transistors while the transistors M1, M3, M4 and M5 are p-channel MOS transistors. A basic factor which intervenes in the operation of this circuit is the physical size of the transistors M1, M2, M5 and M6 in the integrated circuit. An example of sizing by which the desired characteristics are achieved is shown in the following table. M1,M5 M2,M6 W/L 55/4 6/550 Ron low high where W indicates the width of the transistor channel, L indicates the length of the channel and Ron indicates the resistance of the transistor in conduction state. Indeed, the dimensional ratio between the width W and length L of the channel of a transistor is one of the main factors determining the internal resistance in the conduction state. FIG. 3 shows the behaviour in time of a group of electrical signals present in the circuit of FIG. 2. In particular it may be seen that at the instant t0 when the clock signal CK fails the voltage on the circuit node A begins to fall following discharge of the capacitor C1. When this voltage falls below a certain threshold value Vs the signal RST present at the output of the logical gate 8 passes from low logic level to high logic level to reset the microprocessor 3. The figure also shows the level of the power supply voltage Vcc from the moment the circuit is energized. The reset signal generation method in accordance with the present invention is now described. As set forth in the above description the method in accordance with the present invention requires that the reset signal be applied to the microprocessor 3 as a logical function among three signals, a first logical reset signal EXT_RST coming from outside the device, a second logical signal coming from the output 14 of the power-on reset circuit 9 and a third logical signal coming from the circuit 2 and capable of detecting a stop in the oscillation of the clock signal applied to the microprocessor 3. Specifically the logical function is carried out by a NAND logical gate 8 whose output 10 is connected to the reset input RST of the microprocessor 3. In this manner if at least one of the three inputs of the NAND gate 8 is at low logic level the microprocessor is reset. Therefore if the clock signal stops at a certain logic level, high or low, the microprocessor 3 is held in reset state until said signal resumes oscillating, overcoming the problems of the known art discussed above.

Claims: Circuit (2) for detecting irregularities in a clock signal for an electronic device (1) containing a microprocessor (3), having an input terminal (14) and an output terminal (11), for generating a reset signal for the microprocessor (3), characterised in that it comprises a first input stage comprising a first complementary pair of transistors (M1,M2) connected between a positive pole of the supply voltage generator (Vcc) and a negative pole of said generator, the control terminals of the first transistor pair being both connected to said input terminal (14) and the intermediate circuit node (A) between the transistors of the first pair being connected to a first input of a logic gate (16) having an output terminal connected to the output terminal (11) of the circuit, a first capacitive element (C1) connected between the intermediate circuit node (A) between the transistors (M1,M2) of the first pair and a first potential reference, a second input stage comprising a second complementary pair of transistors (M5,M6) connected between the positive pole and the negative pole of said generator and the control terminals of the second pair being connected both to said input terminal (14) through an inverting gate (15) and the intermediate circuit node (B) between the transistors of the second pair being connected to a second input of said logic gate (16), and a second capacitive element (C2) connected between the intermediate circuit node (B) between the transistors of the second pair and a second terminal connected to a second potential reference. Circuit in accordance with claim 1, characterised in that said first and second transistor pairs are each made up of an n-channel MOS transistor and a p-channel MOS transistor. Circuit in accordance with claim 2, characterised in that the p-channel MOS transistors of said first and second pairs have conduction resistances lower than the conduction resistances of the n-channel transistors. Circuit in accordance with claim 1, characterised in that said logic gate (16) is an AND type logic gate having at least two input terminals and one output terminal. Circuit in accordance with claim 1, characterised in that said first potential reference coincides with said second potential reference. Circuit in accordance with claim 1, characterised in that the intermediate circuit node (A) between the transistors of the first pair is connected through a first junction element (M3) to said positive pole of the supply voltage generator (Vcc) and the intermediate circuit node (B) between the transistors of the second pair is connected through a second junction element (M4) to said positive pole of the supply voltage generator (Vcc). Circuit in accordance with claim 6, characterised in that said first and second junction elements (M3,M4) are junction elements of the p-n type provided each by means of a p-channel MOS transistor. Microcontroller (1) of the type comprising at least one microprocessor (3) interlocked with a circuit which is a generator of at least one oscillating periodic clock signal and characterised in that it comprises a circuit (2) according to claim 1 for generating a reset signal for the microprocessor (3) and having an input terminal (14) coupled with an output of the clock signal generator and an output terminal (11) coupled with the reset input (10) of the microprocessor (3) and being capable of detecting a stop in the oscillation of said clock signal.

Inventors: MORONI ANGELO, SCARRA FLAVIO, TADDEO ALBERTO, MORONI, ANGELO, SCARRA', FLAVIO, TADDEO, ALBERTO
Applicants: ST MICROELECTRONICS SRL, STMICROELECTRONICS S.R.L.
Application year: 1994
Main classification: G06F11
IPC codes: G06F11, G06F1, H03K5