Hi kui wu,
0X40C is the FSEC area, it is used to secure the JTAG and the Ezport interfaces.

FSEC also contains the key, the MEEN etc bits.
If you use the backdoor key, then you also can use your own key to unlock it.
If you enable the mass erase, then you can do the mass erase to unlock it.
But if your mass earse is disabled, and SEC is also secured, and the backdoor key is disabled, then the secure leve is to the highest, you can't unsecure it again.
If you want to change your chip mode to secure, you can modify your flash address 0x40C to 0XFC, then the SWD is secured. You can modify the 0X40C in your app code directly, take an example:

The Flashconfig code in the .s file.
So, you don't need to secure it in your app code directly, just in the .s file before you download the code is OK.
Wish it helps you!
If you still have questions about it, please kindly let me know.
Best Regards,
Kerry
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------