Hi, @diego_charles ! Thanks for ur reply!
My IDE is cw11.0, and mcu is KEA128.
It is true that the content of SEC is not being written as expected by checking flash memory. It is always 10b, which is unsecure.
The code which set SEC bits is generated by Processor Expert. SEC bits is written as 00b by code.
Here is code by Processor Expert.
/* Flash configuration field constants */
#define CPU_FLASH_CONFIG_FIELD \
/* NV_BACKKEY0: KEY=0xFF */ \
0xFFU, \
/* NV_BACKKEY1: KEY=0xFF */ \
0xFFU, \
/* NV_BACKKEY2: KEY=0xFF */ \
0xFFU, \
/* NV_BACKKEY3: KEY=0xFF */ \
0xFFU, \
/* NV_BACKKEY4: KEY=0xFF */ \
0xFFU, \
/* NV_BACKKEY5: KEY=0xFF */ \
0xFFU, \
/* NV_BACKKEY6: KEY=0xFF */ \
0xFFU, \
/* NV_BACKKEY7: KEY=0xFF */ \
0xFFU, \
/* Reserved */ \
0xFFU, \
/* Reserved */ \
0xFFU, \
/* Reserved */ \
0xFFU, \
/* Reserved */ \
0xFFU, \
/* Reserved */ \
0xFFU, \
/* NV_FPROT: FPOPEN=1,??=1,FPHDIS=1,FPHS=0,FPLDIS=1,FPLS=0 */ \
0xE4U, \
/* NV_FSEC: KEYEN=3,??=1,??=1,??=1,??=1,SEC=0 */ \
0xFCU, \
/* NV_FOPT: ??=1,??=1,??=1,??=1,??=1,??=1,??=1,??=1 */ \
0xFFU
__attribute__ ((section (".cfmconfig"))) const uint8_t _cfm[0x10] = {CPU_FLASH_CONFIG_FIELD};
However, the content of _cfm[14] is not 0xFC, it is 0xFE!