BPROT — Block protection

The mechanism for protecting non-volatile memory can be used to prevent erroneous application code from erasing or writing to protected blocks.

Non-volatile memory can be protected from erases and writes depending on the settings in the CONFIG registers. One bit in a CONFIG register represents one protected block of 4 kB. There are multiple CONFIG registers to cover the whole range of the flash. Protected regions of program memory illustrates how the CONFIG bits map to the program memory space.

Important: If an erase or write to a protected block is detected, the CPU will hard fault. If an ERASEALL operation is attempted from the CPU while any block is protected it will be blocked and the CPU will hard fault.

On reset, all the protection bits are cleared. To ensure safe operation, the first task after reset must be to set the protection bits. The only way of clearing protection bits is by resetting the device from any reset source.

The protection mechanism is turned off when in debug mode (a debugger is connected) and the DISABLEINDEBUG register is set to disable.

Figure 1. Protected regions of program memory

Registers

Table 1. Instances
Base address Peripheral Instance Description Configuration
0x40000000 BPROT BPROT

Block protect

   
Table 2. Register overview
Register Offset Description
CONFIG0 0x600

Block protect configuration register 0

 
CONFIG1 0x608

Block protect configuration register 1

 
DISABLEINDEBUG[0] 0x608

Disable protection mechanism in debug mode

 
UNUSED0 0x60C  

Reserved

CONFIG0

Address offset: 0x600

Block protect configuration register 0

Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ID f e d c b a Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
Reset 0x00000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ID RW Field Value ID Value Description
A RW

REGION0

   

Enable protection for region 0. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

B RW

REGION1

   

Enable protection for region 1. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

C RW

REGION2

   

Enable protection for region 2. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

D RW

REGION3

   

Enable protection for region 3. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

E RW

REGION4

   

Enable protection for region 4. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

F RW

REGION5

   

Enable protection for region 5. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

G RW

REGION6

   

Enable protection for region 6. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

H RW

REGION7

   

Enable protection for region 7. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

I RW

REGION8

   

Enable protection for region 8. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

J RW

REGION9

   

Enable protection for region 9. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

K RW

REGION10

   

Enable protection for region 10. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

L RW

REGION11

   

Enable protection for region 11. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

M RW

REGION12

   

Enable protection for region 12. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

N RW

REGION13

   

Enable protection for region 13. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

O RW

REGION14

   

Enable protection for region 14. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

P RW

REGION15

   

Enable protection for region 15. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

Q RW

REGION16

   

Enable protection for region 16. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

R RW

REGION17

   

Enable protection for region 17. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

S RW

REGION18

   

Enable protection for region 18. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

T RW

REGION19

   

Enable protection for region 19. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

U RW

REGION20

   

Enable protection for region 20. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

V RW

REGION21

   

Enable protection for region 21. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

W RW

REGION22

   

Enable protection for region 22. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

X RW

REGION23

   

Enable protection for region 23. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

Y RW

REGION24

   

Enable protection for region 24. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

Z RW

REGION25

   

Enable protection for region 25. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

a RW

REGION26

   

Enable protection for region 26. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

b RW

REGION27

   

Enable protection for region 27. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

c RW

REGION28

   

Enable protection for region 28. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

d RW

REGION29

   

Enable protection for region 29. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

e RW

REGION30

   

Enable protection for region 30. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

f RW

REGION31

   

Enable protection for region 31. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

CONFIG1

Address offset: 0x608

Block protect configuration register 1

Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ID                                 P O N M L K J I H G F E D C B A
Reset 0x00000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ID RW Field Value ID Value Description
A RW

REGION32

   

Enable protection for region 32. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

B RW

REGION33

   

Enable protection for region 33. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

C RW

REGION34

   

Enable protection for region 34. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

D RW

REGION35

   

Enable protection for region 35. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

E RW

REGION36

   

Enable protection for region 36. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

F RW

REGION37

   

Enable protection for region 37. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

G RW

REGION38

   

Enable protection for region 38. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

H RW

REGION39

   

Enable protection for region 39. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

I RW

REGION40

   

Enable protection for region 40. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

J RW

REGION41

   

Enable protection for region 41. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

K RW

REGION42

   

Enable protection for region 42. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

L RW

REGION43

   

Enable protection for region 43. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

M RW

REGION44

   

Enable protection for region 44. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

N RW

REGION45

   

Enable protection for region 45. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

O RW

REGION46

   

Enable protection for region 46. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

P RW

REGION47

   

Enable protection for region 47. Write '0' has no effect.

     

Disabled

0

Protection disabled

     

Enabled

1

Protection enabled

DISABLEINDEBUG[0]

Address offset: 0x608

Disable protection mechanism in debug mode

Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ID                                                               A
Reset 0x00000001 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
ID RW Field Value ID Value Description
A RW

DISABLEINDEBUG

   

Disable the protection mechanism for NVM regions while in debug mode. This register will only disable the protection mechanism if the device is in debug mode.

     

Disabled

1

Disabled in debug

     

Enabled

0

Enabled in debug