Microcomputer having a watchdog timer

Abstract: A microcomputer comprises a central processing unit, a watchdog timer generating a watchdog timer processing request when an overflow occurs in the watchdog timer, and an interrupt controller processing as a non-maskable interrupt the watchdog timer processing request generated by the watch timer. The central processing unit generates a preset signal to the watchdog timer at a beginning of execution of another interrupt processing by the central processing unit, so as to preset the watchdog timer. The interrupt controller responds to the preset signal for cancelling the watchdog timer processing request generated by the watchdog timer in a period of time of retaining the watchdog timer processing request by the interrupt controller.

Description: Background of the Invention Field of the invention The present invention relates to a microcomputer, and more specifically to a microcomputer having a central processing unit, and a watchdog timer generating a non-maskable interrupt in response to an overflow of the timer. Description of related art Conventionally, many microcomputers include a central processing unit (often abbreviated to "CPU" in the specification), an interrupt controller (often abbreviated to "INTC" in the specification), and peripheral circuits such as an A/D converter and a serial transfer circuit, all of which are assembled in a single semiconductor substrate chip, comprise a watchdog timer (often abbreviated to "WDT" in the specification) generating a non-maskable interrupt in response to an overflow of the timer in order to elevate reliability of the whole of the microcomputer system. In the case of using the watchdog timer, a program for clearing (or presetting) a counter of the watchdog timer within each predetermined time period without exception is prepared, so that if the program executed without trouble, no overflow of the watchdog timer is generated. For example, at a time of program runaway, if the counter of the watchdog timer is not preset because of occurrence of anomaly even after the predetermined time period has elapsed, an overflow occurs in the watchdog timer. This overflow is detected as a non-maskable interrupt, and an abnormality of the system is notified to an external device, and an operation is branched to a previously programmed routine such as a reset routine for performing a processing for the anomaly occurrence. As mentioned above, the WDT (watchdog timer) interrupt cannot be masked by an EI flag or the like, differently from ordinary maskable interrupts. Therefore, when another interrupt processing routine is under execution, if the WDT interrupt occurs, the operation is branched to the WDT interrupt processing routine. Accordingly, when it is necessary to prepare a program which is generated and processed asynchronously from an execution condition of an internal program, similarly to an interrupt processing routine for processing an interrupt request from an external device, there is possibility that the counter of the watchdog timer cannot be preset within the predetermined time period. Therefore, in order to prevent the WDT interrupt from occurring because the situation is misunderstood as being the system abnormality, the WDT preset instruction is executed at a beginning of the interrupt processing routine. Also in the case that it is desired to complete an interrupt processing routine at a minimum time, as in an application system for detecting from an external terminal interrupt that the supply of an electric power to the system is stopped, and executing a saving of control data and change of port outputs, the WDT present instruction is executed at a beginning of the interrupt processing routine in order to prevent the time from being wasted because of the occurrence of the WDT interrupt. In order to make it possible to execute the WDT preset instruction at a beginning of the interrupt processing routine, the CPU does not receive an interrupt request from the interrupt controller without exception just after the operation is branched to the interrupt processing routine. Namely, an instruction at a heading address of the interrupt processing routine is surely executed. On the other hand, the interrupt controller performs receipt of interrupt processing requests and a priority level control, and notifies occurrence of interrupt request to the CPU. When a plurality of interrupt processing requests are conflicted with, this interrupt controller is configured to process a first occurred request and to retain late occurred request(s). Therefore, when an external terminal interrupt request occurs and is transferred from the interrupt controller to the CPU, if the WDT interrupt processing request occurs and is notified to the interrupt controller in a period in which the CPU is executing the branch processing going to the external terminal interrupt processing routine, the CPU first branches to the external terminal interrupt processing routine so as to execute the heading instruction thereof, and thereafter, branches to the WDT interrupt processing routine. Namely, although the watchdog timer presetting is executed at the beginning of the interrupt processing routine, if the overflow occurs in the watchdog timer, it is in certain case that during the execution of the external terminal interrupt processing, the operation is branched to the WDT interrupt processing routine by the WDT interrupt processing request notified to the CPU. In the conventional microcomputer, as seen from the above, when the WDT interrupt and another interrupt are conflicted with, even if the WDT presetting instruction is executed at a beginning of the first branched interrupt processing routine, the overflow occurs in the watchdog timer, and the operation is branched to the WDT interrupt processing routine by the WDT interrupt processing request notified to the CPU. Therefore, in the case in which it is desired to complete an interrupt processing routine at a minimum time, as in an application system for detecting from an external terminal interrupt that the supply of an electric power to the system is stopped, and executing a saving of control data and change of port outputs, if the watchdog timer is used, when the WDT interrupt processing routine performs the branch to the reset routine, the processing for the electric power-off is not executed. On the other hand, in the case that the WDT interrupt processing routine does not perform the branch to the reset routine and the operation is returned to the first branched interrupt processing routine after the WDT interrupt processing has been completed, since it is necessary to design the system by previously calculating the processing time of the WDT interrupt as a waste time, an additional circuit for maintaining the electric power supply to the microcomputer during a predetermined period of time after the power-off of the main electric power supply to the application system is required to have a larger maintaining electric power capacity. This is a cause of a cost-up. In "Microelectronics Journal, vol. 12, No. 2, March 81, Luton, GB, pp. 21-24, A.R. Wood" software techniques to check for hardware failure or software malfunction are disclosed. One of the methods disclosed is the use of a watchdog timer. The watchdog timer monitors the time required by the microprocessor to execute subroutines and interrupt routines and raises an alarm if the system program remains in a subroutine for more than a predetermined time. The timer is periodically reset by a flag signal from the microprocessor. The instructions generating the reset flag to reset the timer are located within the executive program between subroutine junctions. The hardware timer is set to have a time-out approximately 20 percent longer than the longest legal subroutine, the duration of which can be determined from the number of instructions and the processor instruction cycle time. Summary of the Invention Accordingly, it is an object of the present invention to provide a microcomputer which has overcome the above mentioned defect of the conventional one. Another object of the present invention is to provide a microcomputer having a watchdog timer and which does not branch to the WDT interrupt processing routine when the WDT interrupt request occurs in the course of execution of a first or previously branched interrupt processing routine. The above and other objects of the present invention are achieved in accordance with the present invention by a microcomputer comprising a central processing unit, a watchdog timer generating a processing request when an overflow occurs in the watchdog timer, an interrupt control circuit processing as a non-maskable interrupt the processing request generated by the watchdog timer, means for outputting a preset signal to the watchdog timer in response to execution of an instruction of the central processing unit, so as to preset the watchdog timer, characterized in that said interrupt control circuit (12) further comprises means responding to the preset signal for cancelling the processing request generated by the watchdog timer during a period of time that said interrupt control circuit retains the processing request. The above and other objects, features and advantages of the present invention will be apparent from the following description of preferred embodiments of the invention with reference to the accompanying drawings. Brief Description of the Drawings Figure 1 is a block diagram of an essential part of one embodiment of the microcomputer in accordance with the present invention; Figure 2 is a logic circuit diagram of an essential part of the interrupt controller incorporated in the microcomputer shown in Figure 1; and Figure 3 is a block diagram of an essential part of another embodiment of the microcomputer in accordance with the present invention. Description of the Preferred embodiments Referring to Figure 1, there is shown a block diagram of an essential part of one embodiment of the microcomputer in accordance with the present invention. The shown microcomputer is configured so that when a CPU (central processing unit) executes a WDT (watchdog timer) preset instruction, an interrupt controller (INTC) automatically cancels a WDT interrupt which has not yet been received by the CPU or is retained by the CPU. The shown microcomputer is generally designated by Reference Numeral 1, and is coupled through a bus 5 to a memory unit 2. The microcomputer 1 includes therein a CPU 10, a watchdog timer 11 and an interrupt controller 12, which are coupled through the bus 5 for a mutual data transfer between the CPU 10, the watchdog timer 11 and the interrupt controller 12. The CPU 10 includes therein a program counter, a program status word, an arithmetic and logic unit, an instruction decoder, various control registers, maskable interrupt disable/enable flags, etc., which are not shown in the drawing for simplification of the drawings since these elements are well known to persons skilled in the art. The CPU 10 performs various internal operation controls of the microcomputer 1 including control of execution of instructions including a preset instruction used only for the watchdog timer 11 and an interrupt processing control. The memory unit 2 includes a program memory and a data memory (both of which are not shown) for storing various types of data. The watchdog timer 11 is configured to start its count operation when the CPU 10 executes a WDT preset instruction after a resetting of the system and generates a WDTCLR (watchdog timer clear) signal 24. Thereafter, each time the WDT preset instruction is executed, the watchdog timer is preset. Here, the counting operation of the watchdog timer cannot be stopped by a method other than the inputting of system reset. If an overflow occurs in the watchdog timer before the WDT preset instruction is executed, the watchdog timer 11 generates a WDT interrupt processing request INTWDT 21, which is inputted to the interrupt controller 12. The interrupt controller 12 receives a maskable interrupt enable signal EI 26, and performs the receipt control and the priority level control of the processing request INTWDT 21 and other occurring interrupt requests, on the basis of the received maskable interrupt enable signal EI 26 and contents of internal control registers provided in the interrupt controller. As a result, when a condition for receiving the interrupt is satisfied, the interrupt controller 12 outputs an interrupt request signal INTREQ (INTRO) 22 to the CPU 10. If the CPU 10 receives the interrupt request signal INTREQ 22, the CPU stops a programmed processing being executed, and executes the interrupt processing. Namely, in order to be capable of restarting the stopped programmed processing, the CPU 10 saves information of the program counter and the program status word to a stack area of the memory unit 2. In addition, the CPU generates an interrupt acknowledge signal INTACK 23 to the interrupt controller 12, and receives through the bus 5 from the interrupt controller 12, vector information for the interrupt request having the highest priority level among the presently occurring interrupt requests. On the basis of the received vector information, the CPU 10 branches to a heading or beginning address of an interrupt processing routine previously set in the memory unit 2. Thereafter, the branched interrupt processing routine is executed. When the branched interrupt processing routine is completed, a return instruction IRET is executed, so that the program stopped because of the interrupt processing is restarted. For this purpose, the information of the program counter and the program status word saved in the stack area of the memory unit 2 is returned or restored. On the other hand, when the WDT preset instruction is executed by the CPU 10, the WDTCLR signal 24 is supplied to not only the watchdog timer but also the interrupt controller 12, and in response to the WDTCLR signal 24, the interrupt controller 12 cancels the WDT interrupt request internally held in the interrupt controller 12. With this arrangement, after the WDT preset instruction is executed, the operation will be never branched to the WDT interrupt routine until a next overflow occurs in the watchdog timer 11. Now, an internal operation of the interrupt controller 12 will be described with reference to the logic circuit diagram of Figure 2 illustrating the internal structure of the interrupt controller 12. For simplification of explanation, assume that the interrupt processing requests controlled by the interrupt controller 12 are four, namely three ordinary interrupt processing requests 25a, 25b and 25c, and the WDT interrupt processing request INTWDT 21. The interrupt controller 12 includes four interrupt request flags 30a, 30b, 30c and 30d for individually storing a non-maskable interrupt processing request 25a, the WDT interrupt processing request INTWDT 21, and maskable interrupt processing requests 25b and 25c, respectively, and a mask flags 31b and 31c for individually disabling and enabling the maskable interrupt processing requests 25b and 25c, respectively. Furthermore, the interrupt controller 12 includes a priority level control unit 33 for performing a priority level control between the interrupt processing requests 25a, 25b and 25c and the WDT interrupt processing request INTWDT 21, so as to select an interrupt processing request having the highest priority level, and a vector generation unit 34 for generating a vector information corresponding to a selected one of the interrupt processing requests 25a, 25b and 25c and the WDT interrupt processing request INTWDT 21. The generated vector information is outputted to the bus 5 through a controlled buffer 35 which is activated when the interrupt request acknowledge signal 23 is active. Specifically, the interrupt request flag 30a has a set input S connected to receive the interrupt processing request 25a, and a Q output connected to an input of a latch 331a of the priority level control unit 33. A selection signal 35a outputted from the latch 331a is connected to the vector generation unit 34 and one input of an AND gate 301a having an output connected to a reset input R of the flag 30a. The interrupt request flag 30d has a set input S connected to receive the interrupt processing request INTWDT 21, and a Q output connected to an input of a non-inverting input of an AND gate 332d of the priority level control unit 33. The AND gate 332d has an inverting input connected to the Q output of the flag 30a, and an output of the AND gate 332d is connected to an input of a latch 331d of the priority level control unit 33. A selection signal 35d outputted from the latch 331d is connected to the vector generation unit 34 and one input of an AND gate 301d having an output connected through an OR gate 302 to a reset input R of the flag 30d. The OR gate 302 receives the WDTCLR signal 24 at its other input. The interrupt request flag 30b has a set input S connected to receive the interrupt processing request 25b, and a Q output connected to an input of a non-inverting input of an AND gate 334b of the priority level control unit 33. The AND gate 334b has another non-inverting input connected to receive the EI signal 26 and an inverting input connected to the mask flag 31b. An output of the AND gate 334b is connected to a non-inverting input of an AND gate 332b. The AND gate 332b has an inverting input connected to an output of an OR gate 333d having a pair of inputs connected to the Q output of the flags 30a and 30d, respectively. An output of the AND gate 332b is connected to an input of a latch 331b of the priority level control unit 33. A selection signal 35b outputted from the latch 331b is connected to the vector generation unit 34 and one input of an AND gate 301b having an output connected to a reset input R of the flag 30b. The interrupt request flag 30c has a set input S connected to receive the interrupt processing request 25c, and a Q output connected to an input of a non-inverting input of an AND gate 334c of the priority level control unit 33. The AND gate 334c has another non-inverting input connected to receive the EI signal 26 and an inverting input connected to the mask flag 31c. An output of the AND gate 334c is connected to a non-inverting input of an AND gate 332c. The AND gate 332c has an inverting input connected to an output of an OR gate 333b having a pair of inputs connected to the output of the AND gate 334b and the output of the OR gate 333d, respectively. An output of the AND gate 332c is connected to an input of a latch 331c of the priority level control unit 33. A selection signal 35c outputted from the latch 331c is connected to the vector generation unit 34 and one input of an AND gate 301c having an output connected to a reset input R of the flag 30b. The output of the AND gate 334c and the output of the OR gate 333b are connected to a pair of inputs of an OR gate 333c, which in turn has an output generating the interrupt request signal INTRQ 22 to the CPU 10. The other input of each of the AND gates 301a, 301b, 301c and 301d is connected to receive the interrupt acknowledge signal 23. In addition, the internal latches 331a to 331d operate to latch their input not only when their input is activated to "1" but also when the WDTCLR signal 24 is activated to "1". In this example, by action of the logic circuit structure composed of the AND gates 332d, 332b and 332c and the OR gates 333d and 333b, the priority levels of the interrupt processing requests 25a, 25b and 25c and the WDT interrupt processing request INTWDT 21 are fixed. Namely, the order of the priority levels is (the interrupt processing request 25a) > (the WDT interrupt processing request INTWDT 21) > the interrupt processing request 25b) > (the interrupt processing request 25c). In addition, the maskable interrupt requests are in an acknowledge enable condition (namely, the EI signal 26 is active and the mask flags 31b and 31c are not set.). Firstly, operation will be explained on the case in which a plurality of processing requests concurrently occur. When the interrupt processing request INTWDT 21 and the interrupt processing request 25b concurrently occur, the interrupt request flags 30d and 30b are set to "1", and this is informed to the priority level control unit 33. As mentioned above, since (the WDT interrupt processing request INTWDT 21) > the interrupt processing request 25b), the selection signal 35d is activated to "1", which is supplied to the vector generation unit 34 and also fed back toward the interrupt request flag 30d. At the same time, the interrupt request signal INTRQ 22 is supplied to the CPU 10. At this time, all the other selection signals 35a, 35b and 35c are inactive, namely, "0". If the interrupt request signal INTRQ 22 is acknowledged by the CPU 10, the interrupt acknowledge signal 23 is supplied to the interrupt controller 12. In response to this active interrupt acknowledge signal 23, the active selection signal 35d is passed through its associated AND gate 301d and applied to the reset input R of the interrupt request flag 30d, so as to reset the Q output of the interrupt request flag 30d to "0". On the other hand, the vector generation unit 34 outputs a vector information corresponding to the interrupt request INTWDT 21, through the bus to the CPU, since the control buffer 35 is put in an activated condition by the interrupt acknowledge signal 23. Incidentally, the signal level of the selection signals 25a to 25d are ordinarily held in the internal latches 331a to 331d of the priority level control unit 33, after the interrupt request signal INTRQ 22 is generated until the interrupt acknowledge signal INTACK 24 is generated by the CPU 10. Therefore, the interrupt receiving processing for the interrupt processing request 25 is suspended or retained. Next, operation will be described on the case in which a plurality of interrupt requests occur at timings different from each other. Assuming that the interrupt processing request 25c first occurs, the interrupt request flag 30c is set to "1", which is informed to the priority level control unit 33. In the priority level control unit 33, the selection signal 35c is activated to "1" which is transferred to the vector generation unit 34 and toward the interrupt request flag 30c, and the interrupt request signal INTRQ 22 is outputted to the CPU 10. At this time, all the other selection signals 35a, 35b and 35d are inactive, namely, "0". Thereafter, if the INTWDT signal 21 is generated, the interrupt request flag 30d is set "1", which is informed to the priority order control unit 33. As mentioned above, the priority level relation is (the WDT interrupt processing request INTWDT 21) > the interrupt processing request 25c), but since the interrupt request 22 has been informed to the CPU 10, the selection signals 35a to 35d are maintained by the internal latches 331a to 331d until the interrupt acknowledge signal 23 is supplied to the interrupt controller 12 after the interrupt request 22 was acknowledged. Namely, the selection signals 35a to 35d remain unchanged. Accordingly, the interrupt acknowledge processing for the interrupt processing request INTWDT 21 is retained. In both of the above mentioned cases, an operation of cancelling the WDT interrupt when the WDT preset instruction is executed is as follows: When the WDT preset instruction is executed, the CPU outputs the WDTCLR signal 24 to the interrupt controller 12, so that the interrupt request flag 35d is reset to "0". Even during the hold period after the generation of the interrupt request INTRQ 22 until the receipt of the interrupt acknowledge signal INTACK 24, the internal latches 311a to 331d performs the latching operation again in response to the WDTCLR signal 24, so that the internal latches 311a to 331d are updated. As a result, the selection signal 35d is inactivated to "0", and therefore, the occurrence of the interrupt processing request INTWDT 21 is cancelled. Accordingly, the WDT interrupt processing is never executed by the CPU 10, and the receipt control and the priority level control for the interrupt processing requests 25a to 25c other than the interrupt processing request INTWDT 21 are performed. As mentioned above, the above mentioned embodiment is configured that when the CPU executes the WDT preset instruction, the interrupt controller automatically cancels the WDT interrupt request. Therefore, when the WDT interrupt request occurs concurrently with another interrupt request, if the WCT preset instruction is executed at a beginning of the previously branched interrupt processing routine, the operation is never branched to the WDT interrupt processing routine even if the overflow has already generated and the interrupt processing request has been informed. Referring to Figure 3, there is shown a block diagram of an essential part of another embodiment of the microcomputer in accordance with the present invention. The second embodiment is different from the first embodiment only in the method in which the WDT preset instruction to be executed by the CPU and the WDTCLR signal are generated. Therefore, elements similar to those shown in Figure 1 are given the same Reference Numerals and explanation thereof will be omitted. Differently from the first embodiment in which the WDT preset instruction is executed in the CPU 10 and the WDTCLR signal is generated by the CPU 10, a microcomputer 201 of the second embodiment is such that a CPU 110 writes a predetermined data into an internal control register 101 of an watchdog timer 111 by using a general instruction, and a content of the internal control register 101 is decoded by an internal decoder 112, which presets a watchdog timer counter 103. The decoder 112 also generates a WDTCLR signal 124. The watchdog timer counter 103 generates the WDT interrupt processing request INTWDT 121 when an overflow occurs in the watchdog timer counter 103. Thus, the CPU 110 is not required to have therein a circuit for executing an instruction for only the WDT preset instruction. Therefore, it is possible to control the watchdog timer 111 even by using the CPU of the microcomputer having an instruction set which does not include the instruction for only the WDT preset instruction. This is applicable to a custom LSI (microcomputer) in which a CPU block is made in common and a peripheral circuit including the watchdog timer is customized. In the above mentioned embodiment, the WDT interrupt request flag is located in the interrupt controller. However, a similar effect can be expected even if modification is made to the effect that a flag for storing a processing request is internally provided in the watchdog timer and an interrupt request signal held in the flag internally provided in the watchdog timer is transferred to the interrupt controller. This is called a so called level interrupt control. As seen form the above explanation, the microcomputer in accordance with the present invention is such that when the WDT interrupt request occurs in conflict with another interrupt request, if the WDT preset instruction is executed at a beginning of the previously branched interrupt processing routine, the operation is never branched to the WDT interrupt processing routine even if the overflow has already been generated and the interrupt processing request has been informed. Therefore, in an application system for detecting from an external terminal interrupt that the supply of an electric power to the system is stopped, and executing a saving of control data and change of port outputs, it is possible to avoid the inconvenience in which the processing for the electric power-off is not executed because the operation is branched to the reset routine when the WDT interrupt processing request occurs. Accordingly, an appropriate processing can be performed. In addition, in the case that when the WDT interrupt processing request occurs the operation is not branched to the reset routine, it is no longer necessary to design the system by previously calculating the processing time of the WDT interrupt as a waste time. Therefore, the interrupt processing routine of the external terminal interrupt can be completed with a minimum time. The invention has thus been shown and described with reference to the specific embodiments. However, it should be noted that the present invention is in no way limited to the details of the illustrated structures but changes and modifications may be made within the scope of the appended claims.

Claims: A microcomputer (1) comprising a central processing unit (10,110), a watchdog timer (11) generating a processing request (21) when an overflow occurs in said watchdog timer (11), an interrupt control circuit (12) processing as a non-maskable interrupt said processing request (21) generated by said watchdog timer (11), means for outputting a preset signal (24) to said watchdog timer (11) in response to execution of a predetermined instruction of said central processing unit (10,110), so as to preset said watchdog timer (11), characterized in that said interrupt control circuit (12) further comprising : means responding to said preset signal (24) for cancelling said processing request (21) generated by said watchdog timer (11) during a period of time that said interrupt control circuit (12) retains said processing request (21). A microcomputer claimed in Claim 1 wherein said watchdog timer (11) includes a watchdog timer counter (103) for generating said processing request (21) when the overflow occurs in said watchdog timer counter (103), an internal control register (101) written with a predetermined data by said central processing unit (10,110), an internal decoder (112) for decoding a content of said internal control register (101) for presetting said watchdog timer counter (103) when said internal decoder (112) decodes said predetermined data.

Inventors: KATAYOSE TSUYOSHI, KATAYOSE, TSUYOSHI, KATAYOSE, TSUYOSHI, C/O NEC CORPORATION
Applicants: NIPPON ELECTRIC CO, NEC CORPORATION
Application year: 1992
Main classification: G06F11
IPC codes: G06F11, G06F13, G06F9