Hi,
1) There are two ways how to program MCU with self made programmer – either via BDM or using bootloader. Of course, bootloader also requires its load via BDM.
If you use mass erase command then it is suitable immediately unsecure the mcu by rewriting the security byte in the flash. If it is not done then the MCU is secured after next reset.
You can also erase the flash sector by sector.
Bootloader is described here:
https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-MagniV-Serial-Bootloader-Interface/m-p...
https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-Serial-Bootloader-for-S12Z-AN-draft/...
First of all you should read the data sheet to understand how the programming and erasing memory works.
2) If you mean you want to program the data into the EEPROM and FLASH by means your application SW, then it is another story.
In both cases it is necessary to switch off the memory window (or shift to the part which is not EW) because it reads flash and it is not allowed to read the flash while it is E/W.
My question is. Does the “self made programmer” means either bootloader or debug interface or your application SW?
Best regards,
Ladislav