toggling program flash protection mk22fn1m0vlh12

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

toggling program flash protection mk22fn1m0vlh12

1,282件の閲覧回数
daafies
Contributor II

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

0 件の賞賛
返信
2 返答(返信)

1,176件の閲覧回数
mjbcswitzerland
Specialist V

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

0 件の賞賛
返信

1,176件の閲覧回数
daafies
Contributor II

thanks Mark!

0 件の賞賛
返信