PEmicro's flash programming software PROG12Z now supports the Freescale MC9S12XE family of microcontrollers.
The MC9S12XE family of microcontrollers comes with unique flash
memory called D-Flash that can be allocated for Emulated EEPROM (EEE)
which mimics the small sector size and endurance of real eeprom. Before
you can program the D-Flash or EEE, the D-Flash must be configured with
the "Full Partition" command PROG12Z. This article discusses
how to program the D-Flash of MC9S12XE100 using PROG12Z. The P-Flash does not support the allocation of EEE and therefore does not require partitioning.
Overview
The size of the D-Flash on the MC9S12XE can be up to 32KB or 128
sectors of 256 bytes each. You can allocate up to 4KB or 16 pages of
256 bytes each to be used for EEE. Please see Freescale application
note AN3490 for a more detailed overview of the EEE implementation.
There are two parameters that control how the software
configures the memory: DFPART and ERPART.
DFPART = Number of D-Flash sectors reserved as User D-flash (128 total)
ERPART = Number of pages reserved for EEE (16 total)
The two parameters are required to meet two size conditions to be valid:
1. (128-DFPART) / ERPART >= 8
2. (128-DFPART) >= 12 if ERPART==1
The following table shows how the flash memory can be allocated
towards D-Flash and EEE. The arrows indicate that any number in that
range is a valid amount of sectors for D-Flash. DFPART and ERPART are
in hexadecimal notation.

Programming
Open Prog12z and connect to the target board. After entering
background mode, the software will prompt you for an
algorithm. There are two seperate algorithms for D-Flash and EEE. The
D-Flash algorithm is
"Freescale_9S12XEP100_1x16xmax16k_max32k_Linear_User_Dflash.12P". The
EEE algorithm is "Freescale_9S12XEP100_1x16xmax2k_max4K_EEPROM_linear_1k_page.12P".
Lets choose the algorithm for D-Flash. After selecting your S19 file and before programming, execute the Full
Partition (FP) command. The software will prompt you to enter a value in hexadecimal that is the combination of DFPART and ERPART parameters.
Examples:
"8000" - Enables 128 sectors (32 KB) of D-Flash and 0 pages of EEE
"200C" - Enables 32 sectors (8 KB) of D-Flash and 12 pages (3 KB) of EEE
"100C" - Enables 16 sectors (4 KB) of D-Flash and 12 pages (3 KB) of EEE
"0010" - Enables 0 sectors of D-Flash and 16 pages (4 KB) of EEE
When you want to program the EEE, you should choose the algorithm for EEE. You do not need to run the Full Partition command again unless you want to change the memory configuration. Note that setting up the memory configuration using the FP
command will erase all the contents of both D-Flash and EEE. If you
get the error message "Started. Error during .12P specified function.",
you have entered an invalid value.
Reading
The D-Flash begins at 0x100000. If all your memory is allocated towards D-Flash only, execute the Upload Module (UM) command to dump the memory to a S19 file. UM reads the entire flash regardless of how it was partitioned. If there is D-Flash and EEE, execute the Upload Range (UR) command instead. For example, if there is 8 KB of D-Flash, then upload the range 0x100000 to 0x101FFF.