![](http://datasheet.mmic.net.cn/120000/MB90242A_datasheet_3559106/MB90242A_66.png)
2.1 CPU
61
Program Access Address Errors with Internal RAM and Internal I/O Areas
The F2MC-16F core treats access to internal RAM or areas defined as internal I/O as the equivalent of
the software interrupt instruction 'INT 10.' This means that after the contents of the A, DPR, DTB,
ADB, PCB, PC and PS registers are saved to the system stack, the I flag is set to '0' and the S flag to '1'
and the program branches to the vector indicated by interrupt number 10. The value of register PC that
is placed in the stack will be the address to which program access was attempted resulting in the excep-
tional condition. For this reason, recovery using the RETI and RETIQ instructions is possible but mean-
ingless since another exception will occur.
Fig. 2.1.40 Program Access Address Error
Stack Area Errors Due to Stack Area Check Functions
The F2MC-16F core has stack area check function, which can detect conditions where the current stack
pointer moves outside the area defined by the stack upper/lower limit register. Exception processing as
a result of this condition is called a stack area error.
After the stack check function is set to 'enable' status, any time the current stack pointer moves outside
of the area defined by the stack upper limit register (SPCU) and stack lower limit register (SPCL), the
contents of the A, DPR, DTB, ADB, PCB, PC, and PS registers will be saved to the area 000174H to
00017FH, after which the I flag will be set to '0', the stack check function will stop, and the program will
branch to the vector indicated by interrupt number 255. The value of the PC register, saved to address
000176H, will be the address containing the instruction following the instruction that contained the
stack access responsible for the exception.
The user is warned that this function is primarily intended for debugging, and therefore it is not possible
to return to the original program by using the RETI and RETIQ instructions.
Separate stack upper limit (SPCU) registers and stack lower limit (SPCL) registers are provided for the
user stack pointer and the system stack pointer. The MOVW SPCU, #imm16/MOVW SPCL, #imm16
instructions can be used for the user stack area settings when the S flag is '0' and for the system stack
area settings when the S flag is '1.'
Figure 2.1.41 shows the flow of the stack check function, and Figure 2.1.42 shows the saving of regis-
ters when a stack area error occurs.
Instruction execution
Exception processing
-Stack processing
-Branch to vector of
Execute exception
Memory space
Execution begins here
Internal RAM area
processing program
interrupt number 10
MOV A, #F0FFH
JMPP 000100H
MOV A, #0FFH
MOV, 5000H, A
FF8012H
FF8010H
000100H