MOTOROLA
9-12
EXCEPTION PROCESSING
CPU16
REFERENCE MANUAL
Example — Dynamic Memory Sizing
clrb
set xk = 0
tbxk
ldx
ldd
nop
aix
bra
#$0000
0,x
xk:ix initialized to address $00000
access memory location
nop in case a bus error is pending
increment pointer to next word address.
loop
#2
loop
*
*
*
*
*
*
*
*
*
*
*
*
berr_ex
When xk:ik is incremented past the highest available memory
address, a BERR exception occurs; after exception processing,
the CPU16 executes the exception handler at location berr_ex.
berr_ex – BERR Exception Handler for Dynamic Memory Sizing
This routine computes the address of the last word of memory,
then stores the bank number at a location called “bank” and the
word address within the bank at a location called “address”.
It assumes that ek is properly initialized.
aix
txkb
stab
stx
#–2
compute LWA of memory
bank
address
store bank number
store address
Exception processing for bus error exceptions follows the standard exception process-
ing sequence. However, two special cases of bus error, called double bus faults, can
abort exception processing.
BERR assertion is not detected until an instruction is complete. The BERR latch is
cleared by the first instruction of the BERR exception handler. Double bus fault occurs
in two ways:
1. When bus error exception processing begins and a second BERR is detected
before the first instruction of the BERR exception handler is executed.
2. When one or more bus errors occur before the first instruction after a RESET
exception is executed.
Multiple bus errors within a single instruction which can generate multiple bus cycles,
such as read-modify-write instructions (refer to
SECTION 8 INSTRUCTION TIMING
for more information), will cause a single bus error exception after the instruction has
executed.
Immediately after assertion of a second BERR, the CPU16 ceases instruction pro-
cessing and asserts the IMB HALT signal. The CPU16 will remain in this state until a
RESET occurs.
9.7.1.3 Breakpoint Exception (BKPT)
BKPT is caused by internal assertion of the IMB BKPT signal or by external assertion
of the microcontroller BKPT pin. BKPT assertions do not force immediate exception
processing. They are synchronized with normal bus cycles and latched into the
CPU16 at the end of the bus cycle in which they are asserted.
F
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
.