Technical information

AN2216/D
20 MC9S12DP256 Software Development Using Metrowerk’s Codewarrior MOTOROLA
NOTE: Whenever any new functions are added to the source, a new linker generated
header file must be generated, i.e. both passes must be executed.
NOTE: When code is added to a function, it may no longer fit into its allocated section.
If this happens, both build passes must be executed to generate a new include
file.
Appendix A: Flash Memory Protection
The protected areas of each Flash block are controlled by four bytes of Flash
memory residing in the fixed page memory area from $FF0A
$FF0D During
the microcontroller reset sequence, each of the four banked Flash Protection
Registers (FPROT) is loaded from values programmed into these memory
locations. As shown in Figure 20, location $FF0A controls protection for block
three, $FF0B controls protection for block two, $FF0C controls protection for
block one and $FF0D controls protection for block zero. The values loaded into
each FPROT register determine whether the entire block or just subsections
are protected from being accidentally erased or programmed. As mentioned
previously, each 64K block can have two protected areas. One of these areas,
known as the lower protected block, grows from the middle of the 64K block
upward. The other, known as the upper protected block, grows from the top of
the 64K block downward. In general, the upper protected area of Flash block
zero is used to hold bootloader code since it contains the reset and interrupt
vectors. The lower protected area of block zero and the protected areas of the
other Flash blocks can be used for critical parameters that would not change
when program firmware was updated.
The FPOPEN bit in each FPROT register determines whether the the entire
Flash block or subsections of it can be programmed or erased. When the
FPOPEN bit is erased (1) the remainder of the bits in the register determine the
state of protection and the size of each protected block. In its programmed state
(0) the entire Flash block is protected and the state of the remaining bits within
the FPROT register is irrelevant.