hi i'm trying to turn on and off flash protection. i can see how to do it in PE or by using
/* Flash configuration field */
__attribute__ ((section (".cfmconfig"))) const uint8_t _cfm[0x10] = {
/* NV_BACKKEY3: KEY=0xFF */
0xFFU,
/* NV_BACKKEY2: KEY=0xFF */
etc
but how do i change the following field in my application:
/* NV_FPROT3: PROT=0xFF */
0xFFU,
/* NV_FPROT2: PROT=0xFF */
0xFFU,
/* NV_FPROT1: PROT=0xFF */
0xFFU,
/* NV_FPROT0: PROT=0x7F */
i tried
NV_FPROT3 = 0xFF;
NV_FPROT2 = 0xFF;
NV_FPROT1 = 0xFF;
NV_FPROT0 = 0x7F;
but that causes hard fault. i can read from those however.
thanks for help
dave
Hi Dave
1. NV_FPROTn is an address in Flash and so you can't write to it from your code (it gives you your hard fault).
2. You can "enable" protection also by writing the FPROTn register (in the FTFE module itself - address 0x40020010..13)
3. Once protection has been enabled YOU CAN NOT DISABLE it (without either reprogramming the values in the Flash Configuration area, or by a reset if set manually).
For full details see the video:
https://youtu.be/c9GRYXFs9LU
Regards
Mark
thanks Mark!