63
5.3
Operation
5.3.1
Checking Application Program Execution Area
As shown in figure 5.3, when the counter underflows, the WDT sets the UDF bit to 1 and issues a
UDF interrupt. Since the TCNT initial value cannot be changed, a UDF interrupt is issued at
regular intervals until reset. UDF interrupt vector addresses are H'000C to H'000D. The UDF
interrupt routine can monitor the PC in the stack area to check whether application program was
executed in the defined area. Figure 5.4 shows memory contents in this status.
H'FF
H'00
Set value
TCSR and
TCNT write
UDF
interrupt
UDF
interrupt
UDF
interrupt
Time
TCNT value
Figure 5.3 WDT Operation
IRQ requests are masked from the UDF interrupt acceptance until RTE instruction completion.
Here, the IRQ requests include external
IRQ
pin inputs. The WDT sets the HLT bit to 1 when the
counter value underflows again between the UDF interrupt acceptance and RTE instruction
completion. The WDT sets the HLT bit to 1 also when 1 is written to the EWE bit between the
UDF interrupt acceptance and RTE instruction completion.
Figure 5.4 shows an example of checking the application execution area by using the UDF
interrupt routine. In this example, addresses H'1000 to H'1FFF are defined as a correct application
area. When a UDF interrupt is issued immediately after the MOV instruction is executed, the stack
contents that can be referred to from the UDF interrupt routine are as shown on the right in figure
5.4. The PC marked by *1 points to the address marked by *2. The UDF interrupt routine checks
whether this PC is in the defined area. If it is not in the defined area, the application program may
have run out of control or the application program may have been executed in an undefined area.