Checking The Procedure For Writing To Eeprom - Hitachi H8/3152 Hardware Manual

Single-chip microcomputer h8/3150 series
Table of Contents

Advertisement

5.3.2

Checking the Procedure for Writing to EEPROM

The WDT issues an EWE interrupt when 1 is written to the EWE bit. The EWE interrupt is
accepted at the end of the instruction following the instruction in which 1 is written to the EWE
bit. Figure 5.5 shows the timing of the EWE interrupt. EWE interrupt vector addresses are H'000A
to H'000B. The EWE interrupt routine can monitor the instructions in the area pointed to by the
PC stored in the stack, to check whether or not the EEPMOV instruction was executed by the
correct procedure and with correct data, that is, the routine can check whether EEPROM was
correctly written to. Figure 5.6 shows memory contents at this time.
MOV fetch
EWE interrupt
MOV.W
#4000,R0
MOV.B
R0H,@TCSR
MOV.B
R0L,@ECR
EEPMOV
Figure 5.5 Timing for EWE Interrupt Acceptance by EWE Write
IRQ requests are masked from the EWE interrupt acceptance until EEPMOV instruction
completion. Here, the IRQ requests include external IRQ pin inputs. When a TCNT underflow and
a write to EWE occur at the same time, an exception by the EWE interrupt is processed, then an
exception by the TCNT underflow is processed. The WDT sets the UDF bit to 1 and issues a UDF
interrupt when the counter value underflows in the EWE interrupt routine. The WDT sets the HLT
bit is set to 1 when 1 is written to the EWE bit again between the EWE interrupt acceptance and
EEPMOV instruction completion.
Figure 5.6 shows an example of checking the EEPROM writing operation by using the EWE
interrupt routine. In the program shown on the left in figure 5.6, an EWE interrupt is issued
between the MOV instruction to ECR and the EEPMOV instruction. At this time, the stack
contents that can be referred to from the EWE interrupt routine are as shown on the right in figure
5.6. The PC marked by *1 points to the start address marked by *2 of the EEPMOV instruction.
The EWE interrupt routine checks whether the instructions before and after this PC are correct. If
they are not correct, EEPROM will be incorrectly written to due to the invalid procedure. The
EWE interrupt routine also checks whether the R4 to R6 contents used for the EEPMOV
EWE write
MOV fetch
;Writes 1 to the EWE bit.
ECR write
EWE interrupt routine
EEPMOV
RTE
65

Advertisement

Table of Contents
loading

Table of Contents