WATCHDOG TIMER CIRCUIT SUITED FOR USE IN MICROCOMPUTER

Abstract: A watchdog timer circuit employed in a microcomputer is disclosed. The watchdog timer circuit detects the occurrence of a program abnormal termination or an infinite loop opera­ tion and includes a capacitor, a charging circuit charging the capacitor when a predetermined instruction is executed a discharging circuit discharging the capacitor when other in­ structions are executed, a detection circuit detecting the vol­ tage across the capacitor and producing a detection signal when the voltage across the capacitor becomes smaller than a reference voltage, and a reset circuit resets the microcompu­ ter to its initial state in response to the detection circuit. When the program abnormal termination or the infinite loop opera­ tion occurs, the predetermined instruction is not executed for a long period of time. The capacitor continues to be dis­ charged. As a result, the detection signal is produced. The microcomputer is thereby reset to its initial state.

Description: BACKGROUND OF THE INVENTION The present invention relates to a timer circuit, and more particularly to a watchdog timer circuit suited for use in a microcomputer to detect abnormal program execution such as abnormal termination of the program and infinite-loop operation. In an information processing equipment such as a microcomputer, there sometimes occurs a program abnormal termination or an operation within an infinite-loop. In order to detect such abnormal program execution, a watchdog time circuit is employed. A prior art watchdog timer circuit is constituted by a counter having a reset funtion and counting a clock signal. This counter is reset cyclically by a program. The reset operation of the counter by the program is carried out within a time when the count value of the counter does not overflow. Accordingly, so long as the program is executed normally, the overflow signal is not obtained from the counter. On the other hand, when the program is abnormally executed, the counter is not reset, so that the counter produces the overflow signal. The overflow signal brings a program counter into an initial condition. The information processing equipment is thereby returned to a normal operation state. However, the counter requires a large number of bits construction even in a microcomputer. For this reason, a semiconductor chip is made large in area and a large power is consumed in a one-chip microcomputer equipped with the prior art watchdog timer. A watchdog timer circuit according to the preamble of claim 1 is disclosed in JP-A-60-84 644. In this circuit a capacitor is utilized which is charged by a first transistor controlled by a clock signal and is charged by a second transistor controlled by a clear signal. In this construction the first transistor is switched in a cycle determined by the clock signal irrespective of the state of the second transistor. This means that temporary both transistors are in conductive state or the transistors are temporarily in non-conductive state. In the first case a DC current flows through the transistors resulting in an increase in power consumption. In the second case the capacitor is brought into a floating state resulting in that electrical charges stored in the capacitor may produce a reset signal erroneously. It is therefore an object of the invention to provide a watchdog timer circuit which has a simple construction and which is suitable for being incorporated into a microcomputer as a single semiconductor chip and which has a reduced power consumption. This object is achieved by a watchdog timer circuit as defined in claim 1; claim 2 is related to a further development of the invention. In a microcomputer, the discharging capacitor is charged periodically by a program before the voltage thereacross reaches the detecting level of the detecting means. Accordingly, when the program is executed normally, the control signal is not generated. On the other hand, if there occurs the abnormal program execution such as the program abnormal termination and the operation in the infinite loop, the capacitor continues discharging without being charged. As a result, the voltage is reduced below a predetermined level and the control signal is generated, so that a program counter is reset into an initial condition, for example. The microcomputer is thereby returned to a normal operation state to execute the program normally. The time constant of the discharging means is selected such that the voltage across the capacitor does not take a value below the predetermined level within the interval between the charging periodes upon the normal operation, so that the generation of the control signal represents the abnormal operation. BRIEF DESCRIPTION OF THE DRAWINGS The above and other objects, advantages and features of the present invention will be more apparent from the following description taken in conjunction with the accompanying drawings, in which Fig. 1 is a circuit block diagram according to one embodiment of the present invention; Fig. 2 is a timing chart for representing an operation of the circuit shown in Fig. 1; Fig. 3 is a circuit block diagram according to another embodiment of the present invention; Fig. 4 is a timing chart for representing an operation of the circuit shown in Fig. 3; Fig. 5 is a circuit diagram according to still another embodiment of the present invention; and Fig. 6 is a timing chart for representing an operation of the circuit shown in Fig. 5. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT Fig. 1 shows a microcomputer equipped with a watchdog timer circuit according to one embodiment of the present invention. A read-only memory (called hereinafter as an "ROM") 1 stores a plurality of instructions for controlling an operation sequence according to a program, the addresses thereof being designated in order by a program counter 3. The instructions read out of the ROM 4 are supplied to an instruction decoder 5 through an internal bus 12. The decoder 5 decodes the instructions and supplies the decoded result to a timing generator 6. The generator 6 generates predetermined timing signals to attain the instruction processing. A random access memory (called hereinafter as an "RAM") 8 stores data to be processed or the processed data, and its addresses are supplied by an address decoder 7 in response to a set of address signals supplied via the internal bus 12. An arithmetic logic unit (called hereinafter as an "ALU") 9 performs a logical operation and supplies its result to an accumulator 10. The data in the accumulator 10 is supplied to the RAM 8 or the ALU 9 through the internal bus 12. An input/output port 11 is coupled bidirectionally to the internal bus 12, so that the data of an instrument to be controlled (not shown) is transferred to the internal bus 12 or the data on the internal bus 12 is transferred to the instrument to be controlled. The above-described circuit block is same as that of a prior art microcomputer, but the microcomputer shown in Fig. 1 includes a new watchdog timer circuit 100. This timer circuit 100 has a capacitor C₁, P-channel and N-channel MOS (Metal Oxide Semiconductor) transistors Q₁ and Q₂, a comparator 1, a reference voltage source 2, and a one-shot pulse generator 10. The transistor Q₁ is connected between a node N and a power potential V DD supply terminal. The transistor Q₂ and the capacitor C₁ are connected in parallel between the node N and a ground potential point. The node N is connected to an inverting input terminal of the comparator 1 whose non-inverting input terminal is supplied with a reference voltage V₀ from the voltage source 2. The output of the comparator 1 is supplied to the pulse generator 13 whose one-shot pulse output is in turn supplied to a reset terminal R of the program counter 3 as a reset pulse RS. The transistors Q₁ and Q₂ are controlled by a signal IDD. When the signal IDD takes a low level, the transistor Q₁ is turned ON to charge the capacitor C₁. When the signal IDD takes a high level, the transistor Q₂ is turned ON to discharge the capacitor C₁. This signal IDD is produced from the instruction decoder 5 and therefore takes the low level in response to a particular instruction read-out from the ROM 4. It is convenient to employ an "NOOP" (or "NOP") instruction as this particular instruction. The NOOP instruction is frequently used in a sequence of programs, and the execution of the NOOP instruction provides no change in signal conditions which are obtained by the instruction that has been executed just before the NOOP instruction. In Fig. 2, the timing chart representative of the signal IDD, the voltage V N at the node N, the output voltage V C of the comparator 1 and the reset pulse PS is shown. When the program counter 3 designates the address of the ROM 4 in which the NOOP instruction is stored, the decoder 5 produces the low level signal IDD. The transistor Q₁ is thereby turned ON to charge the capacitor C₁. Since the transistor Q₁ has a relatively large current capability, the capacitor C₁ is charged to about V DD level during the execution period of the NOOP instruction. The count value of the program counter 3 advances thereafter by one, so that the instruction other than the NOOP instruction is executed. The signal IDD is inverted into the high level to turn the transistors Q₁ and Q₂ OFF and ON, respectively. The capacitor C₁ is thereby discharged. The discharge of the capacitor C₁ continues until the count value of the program counter 3 advances and the next NOOP instruction is executed, but the current capability of the transistor Q₂ is designed to be considerably small, so that the capacitor C₁ is discharged slowly. The execution of the next NOOP instruction charges the capacitor C₁ to the V DD level, and after the end of that instruction, the capacitor C₁ is discharged. Thus, the capacitor C₁ is charged every time when the NOOP instruction is executed, and is discharged when other instructions are executed. Therefore, the voltage across the capacitor C₁ is represented by V N in Fig. 2. The NOOP instruction is executed within a time when the voltage V N does not become smaller than the reference voltage V₀. In other words, the time constant of the capacitor C₁ and the conductive resistance of the transistor Q₂ is selected such that the voltage V N does not become smaller than the reference voltage V₀ within an interval between the NOOP instructions upon the normal operation. Accordingly, so long as the program is executed normally, the voltage V N does not take a value smaller than the reference voltage V₀. The output V C of the comparator 1 receiving the voltages V N and V₀ holds therefore the low level, and the reset pulse RS is not produced. On the other hand, if the program abnormal terminal or the operation in the infinite loop occurs, the charging operation of the capacitor C₁ is not carried out as shown by dotted lines in Fig. 2. The capacitor C₁ continues to be discharge, so that the voltage V N thereacross becomes smaller than the reference voltage V₀. The comparator 1 inverts its output V C from the low level to the high level. The occurrence of the program abnormal termination and the operation in the infinite loop is thus detected. The pulse generator 13 generates the reset pulse RS of a one-shot shape in response to the change in the output V C from the low level to the high level. The reset pulse RS is supplied to the reset terminal R of the program counter 3 to bring the counter 3 into the initial value, all zero, for example. The microcomputer shown in Fig. 1 is thereby returned to the initial state of the program from the abnormal terminal or the infinit loop operation. When the reset pulse RS disappears, the program counter 3 starts to count, so that the program is executed. At a time when the NOOP instruction is executed, the capacitor C₁ is charged to the V DD level, and the output V C of the comparator 1 is inverted to the low level. As described above, by charging the capacitor C₁ periodically (this cycle period is not fixed, but changed more or less in accordance with the program as shown in Fig. 2) by a predetermined instruction ("NOOP" or "NOP" instruction in this embodiment) and by detecting the voltage thereacross, the program abnormal termination and the infinite loop operation are detected and the system is returned to a normal condition. Moreover, the number of the circuit elements is decreased more remarkably than the prior art circuit, so that the area occupied on a semiconductor chip is reduced and the power consumption becomes very small. Incidently, the capacitor C₁ requires a relatively large capacitance, and therefore it is connected to one-chip microcomputer as an externally provided component. Many microcomputers further include a power-on clear function using a capacitor, this function resetting internal circuits into the initial conditions in response to the fact that the voltage across the capacitor is zero just when the power is ON. According to the present invention, the capacitor used for the power-on clear function can be also used for the watchdog timer circuit. Such a watchdog timer circuit 200 is shown in Fig. 3 as another embodiment of the present invention. In Fig. 3, the same-constituents as those shown in Fig. 1 are denoted by the same references. The microcomputer shown in Fig. 3 includes a power-on clear terminal 20, and a capacitor C₂ is connected between the terminal 20 and the ground point. The transistors Q₁ and Q₂ respond to the signal IDD and control the charging and discharging of the capacitor C₂ as also mentioned in Fig. 1. A P-channel MOS transistor Q₃ is connected in parallel to the transistor Q₁ and supplied at its gate with a signal CC which is an inverted signal of an output V S of a Schmitt-trigger circuit 21. The voltage at the terminal 20, i.e. the voltage V₂₀ across the capacitor C₂, is supplied to the Schmitt-trigger circuit 21, and the output V S thereof is supplied to an all-clear circuit 22. Upon the power switching-on, the voltage V₂₀ across the capacitor C₂ is zero as shown in Fig, 4, and therefore the Schmitt-trigger circuit 21 produces the high level output V S . The all-clear circuit 22 thus generates an all-clear signal AC having a predetermined pulse width. This signal AC is supplied to the program counter 2 and the input/output port 11, and in some cases further supplied to the address decoder 7 and the accumulator 10 to reset these circuits into an initial state. Since the signal V S is in the high level, the signal CC takes the low level. The transistor Q₃ is thereby turned ON to charge the capacitor C₂. When the signal AC disappears, the program counter 2 starts to count and the program is executed. As described in Fig. 1, the transistor Q₂ is turned ON when the instruction other than the NOOP instruction is executed, but the transistor Q₃ has current capability that is considerably larger than the transistor Q₂, so that the capacitor C₂ maintains to be charged. When the charging of the capacitor C₂ advances to a level that is equal to a high threshold level V TH of the Schmitt-trigger circuit 21, the circuit 21 produces the low level output V S to turn the transistor Q₃ OFF. The transistor Q₂ discharges the capacitor C₂, but the Schmitt-trigger circuit 21 takes its low threshold level V TL , so that the output V S holds the low level. When the NOOP instruction in the program is executed, the transistor Q₁ is turned ON to charge the capacitor C₂ to the V DD level. The transistor Q₂ discharges the capacitor C₂ after the end of the NOOP instruction. The program is composed such that the NOOP instruction is executed within a time when the voltage V₂₀ across the capacitor C₂ does not become smaller than the low threshold level V TL of the Schmitt-trigger circuit 21. Therefore, so long as the program is executed normally, the Schmitt-trigger circuit 21 holds its low level output V S . When the program abnormal termination or the infinite loop operation occurs, the charging to the capacitor C₁ represented by dotted lines in Fig. 4 is not carried out, so that the transistor Q₂ discharges the capacitor C₂ to the level that is smaller than the low threshold voltage V TL of the Schmitt-trigger circuit 21. The circuit 21 thereby produces the high level output V S and the all-clear signal AC is generated. The program counter 3 and other circuits are thus returned to their initial state, so that the program is again executed from the first instruction. In this embodiment, the capacitor C₂ which is provided previously for the power-on clear function is also used for the watchdog time circuit 200. The initial charging of the capacitor C₂ can be carried out by the transistor Q₁ in place of the transistor Q₃, and another circuit may be employed in place of the Schmitt-trigger circuit 21 to detect the voltage across the capacitor C₂. Such a watchdog timer circuit 300 is shown in Fig. 5 as still another embodiment of the present invention. It is noted that only the watchdog timer circuit 300 and the all-clear circuit 32 are shown in Fig. 5 and other circuit blocks shown in Fig. 3 are omitted. In Fig. 5, the signal IDD is supplied to the gate of the transistor Q₂ and one input terminal of an NAND circuit 37. The output of the NAND circuit 37 is supplied via an inverter 38 to the gate of the transistor Q₁. The terminal 20 is connected via two inverters 30 and 31 to the reset terminals R of D-type flip-flop circuits (called hereinafter as "D-FFs") 33 and 34. When the output V R takes the low level, the D-FFs 33 and 34 are reset. The data terminal D of the D-FF 33 is connected to the power voltage (V DD ) terminal, and the output terminal Q thereof is connected to the data terminal D of the D-FF 34. The all-clear signal AC is produced by an inverter 35 supplied with an output of the D-FF 34. The signal AC is also supplied to the set terminal S of an S-R flip-flop circuit (called hereinafter as an "S-R FF") 36. The clock terminals  of the D-FFs 33 and 34 are supplied with a clock signal CLK. The reset terminal R of the S-R FF 36 is supplied with a signal PC₃ from the third bit of the program counter 3 (Fig. 3). The inverted output Q of the S-R FF 36 is supplied to the other input terminal of the NAND circuit 37. Fig. 6 shows a timing chart of the circuit shown in Fig. 5. Upon the power switching-on, the charge in the capacitor C₂ is zero, and therefore the output V R of the inverter 31 takes a low level to reset the D-FFs 33 and 34. The all-clear signal AC takes the high level to bring the program counter 3 and other circuits (Fig. 3) into the initial states. The S-R FF 36 is set and hence its inverted output V F takes the low level. The output V Q of the inverter 38 therefore takes the low level to turn the transistor Q₁ ON. The capacitor C₂ is thereby charged. When the charging level exceeds the threshold level V T of the inverter 30, the signal V R is inverted into the high level. The D-FFs 33 and 34 are released from their reset states and thus shifts the data level, i.e. the high level, at the data terminal D of the D-FF 33 in synchronism with the clock signal CLK. The all-clear signal AC is thereby inverted into the low level, so that the program counter 3 (Fig. 3) starts to operate to execute the program. The instruction decoder 5 (Fig. 3) produces the high level signal IDD to turn the transistor Q₂ ON, but since the transistor Q₁ is maintained in the ON state by the S-R FF 36 and has the current capability that is considerably larger than the transistor Q₂, the capacitor C₂ is charged to a level that is smaller a little than the V DD level. The count value of the address counter 3 (Fig. 3) advances and then the high level appears at the third bit of the counter 3. The signal PC₃ thereby takes the high level to reset the S-R FF 36. As a result, the transistor Q₁ is turned OFF and the capacitor C₂ is discharged slowly by the transistor Q₂. When the NOOP instruction in the program is executed, the signal IDD takes the low level. The transistor Q₁ is thereby turned ON to charge the capacitor C₂ to the V DD level. In response to the end of the NOOP instruction, the transistor Q₂ discharges the capacitor C₂. When the program abnormal termination or the infinite loop operation occurs, the charging of the capacitor C₂ is stopped, so that the voltage V₂₀ across the capacitor C₂ becomes smaller than the threshold level V T of the inverter 30. As a result, the signal V R takes the low level to reset the D-FFs 33 and 34. The all-clear signal AC is thereby inverted to the high level. The program counter 3 and other circuits (Fig. 3) are reset to their initial states, and the S-R FF 36 is set to turn the transistor Q₁ ON. The signal V R is inverted to the high level immediately to release the D-FFs 33 and 34 from the reset states. The above-mentioned circuit operation is thereafter carried out. Also in this embodiment, the program abnormal termination and the infinite loop operation are detected by using the capacitor for the power-on clear function, and the returning to the normal operation from the abnormal conditions is carried out by utilizing the all-clear circuit. As described above, the present invention provides a watchdog timer circuit having a simplified circuit construction and a reduced power consumption. Moreover, the design of the time constant in the watchdog timer circuit facilitates the program composition, and the capacitor used for a power-on clear function is also used for the watchdog timer circuit.

Claims: A watchdog timer circuit for a microcomputer including a program counter (3) for designating an address of a program memory (4) into which an instruction to be executed is stored and an instruction decoder (5) for decoding an instruction from said program memory (4), said time circuit comprising a capacitor (C1,C2), a first transistor (Q1) coupled to said capacitor for, when conductive, charging said capacitor, a second transistor (Q2) coupled to said capacitor for, when conductive, discharging said capacitor, and means (1,2,13;21,22;30-35) coupled to said capacitor for detecting a voltage relative to electrical charges stored in said capacitor and for generating a reset signal (Rs;AC) for bringing said program counter (3) into an initial state when said capacitor continues to be discharged over a predetermined period of time, characterized in that said instruction decoder (5) produces a control signal (IDD) which takes a first logic level when a predetermined instruction is decoded and a second logic level when other instructions are decoded, that said first transistor (Q1) is in a conductive state while said control signal (IDD) is taking said first logic level and in a non-conductive state while said control signal (IDD) is taking said second logic level, and that said second transistor (Q2) is in a conductive state while said control signal (IDD) is taking said second logic level and in a non-conductive state while said control signal (IDD) is taking said first logic level. The watchdog timer circuit as claimed in claim 1, characterized in that said means (30-35) includes a detector (30,31) detecting the voltage across said capacitor (C2) to produce a detection signal (VR) taking a first state when the voltage across said capacitor is smaller than a predetermined voltage and a second state when the voltage across said capacitor is equal to or larger than said predetermined voltage, a reset signal generator (32-35) generating said reset signal (AC) in response to said first state of said detection signal (VR) and stopping generation of said reset signal (AC) when receiving a predetermined number of clock pulses (CLK) after said detection signal (VR) is changed from said first state to said second state, signal holding means (36) for holding said reset signal (AC) until said program counter (3) reaches a predetermined count value, said holding means (36) informing, by its output signal (VF), that said reset signal (AC) is being held, and a gate circuit (37,38) for making said first transistor (Q1) conductive in response to not only said first logic level of said control signal (IDD) but also said output signal (VF) of said signal holding means (31).

Inventors: YAZAWA, AKIRA
Applicants: NEC CORPORATION
Application year: 1986
Main classification: G06F11
IPC codes: H03K17, G06F11, G06F1, H03K5