Hi @Kishore_14,
The most likely explanation is that CSEc was enabled on the MCU before you programmed this example. Could you check the DEPART register? Its value will indicate whether the MCU has been partitioned. Also, when CSEc is enabled, you cannot access the portion of FlexRAM reserved for CSEc keys.
Once CSEc is enabled, the mass‑erase operation is blocked by the CSEc module.
For more details, refer to:
AN12130 – Production Flash Programming Best Practices for S32K1xx MCUs.
https://www.nxp.com/docs/en/application-note/AN12130.pdf
3.2.5.2 Mass erase and CSEc considerations
Regards,
Daniel