NVMC — Non-volatile memory controller

The non-volatile memory controller (NVMC) is used for writing and erasing of the internal flash memory and the UICR (user information configuration registers).

The CONFIG is used to enable the NVMC for writing (CONFIG.WEN) and erasing (CONFIG.EEN). The user must make sure that writing and erasing are not enabled at the same time. Having both enabled at the same time may result in unpredictable behavior.

The CPU must be halted before initiating a NVMC operation from the debug system.

Writing to flash

When writing is enabled, full 32-bit words are written to word-aligned addresses in flash.

As illustrated in Memory, the flash is divided into multiple pages. The same 32-bit word in the flash can only be written nWRITE number of times before a page erase must be performed.

The NVMC is only able to write 0 to bits in the flash that are erased (set to 1). It cannot rewrite a bit back to 1. Only full 32-bit words can be written to flash using the NVMC interface. To write less than 32 bits, write the data as a full 32-bit word and set all the bits that should remain unchanged in the word to 1. Note that the restriction on the number of writes (nWRITE) still applies in this case.

Only word-aligned writes are allowed. Byte or half-word-aligned writes will result in a hard fault.

The time it takes to write a word to flash is specified by tWRITE. The CPU is halted while the NVMC is writing to the flash.

Erasing a page in flash

When erase is enabled, the flash memory can be erased page by page using the ERASEPAGE.

After erasing a flash page, all bits in the page are set to 1. The time it takes to erase a page is specified by tERASEPAGE. The CPU is halted if the CPU executes code from the flash while the NVMC is writing to the flash.

See Partial erase of a page in flash for information on dividing the page erase time into shorter chunks.

Writing to user information configuration registers (UICR)

User information configuration registers (UICR) are written in the same way as flash. After UICR has been written, the new UICR configuration will take effect after a reset.

UICR can only be written nWRITE number of times before an erase must be performed using ERASEUICR or ERASEALL. The time it takes to write a word to UICR is specified by tWRITE. The CPU is halted while the NVMC is writing to the UICR.

Erasing user information configuration registers (UICR)

When erase is enabled, UICR can be erased using the ERASEUICR.

After erasing UICR all bits in UICR are set to 1. The time it takes to erase UICR is specified by tERASEPAGE. The CPU is halted if the CPU executes code from the flash while the NVMC performs the erase operation.

Erase all

When erase is enabled, flash and UICR can be erased completely in one operation by using ERASEALL. This operation will not erase the factory information configuration registers (FICR).

The time it takes to perform an ERASEALL command is specified by tERASEALL. The CPU is halted if the CPU executes code from the flash while the NVMC performs the erase operation.

Partial erase of a page in flash

Partial erase is a feature in the NVMC to split a page erase time into shorter chunks, so this can be used to prevent longer CPU stalls in time-critical applications. Partial erase is only applicable to the code area in the flash and does not work with UICR.

When erase is enabled, the partial erase of a flash page can be started by writing to ERASEPAGEPARTIAL. The duration of a partial erase can be configured in ERASEPAGEPARTIALCFG. A flash page is erased when its erase time reaches tERASEPAGE. Use ERASEPAGEPARTIAL N number of times so that N * ERASEPAGEPARTIALCFGtERASEPAGE, where N * ERASEPAGEPARTIALCFG gives the cumulative (total) erase time. Every time the cumulative erase time reaches tERASEPAGE, it counts as one erase cycle.

After the erase is done, all bits in the page are set to '1'. The CPU is halted if the CPU executes code from the flash while the NVMC performs the partial erase operation.

The bits in the page are undefined if the flash page erase is incomplete, i.e. if a partial erase has started but the total erase time is less than tERASEPAGE.

Registers

Table 1. Instances
Base address Peripheral Instance Description Configuration
0x4001E000 NVMC NVMC

Non-volatile memory controller

   
Table 2. Register overview
Register Offset Description
READY 0x400

Ready flag

 
CONFIG 0x504

Configuration register

 
ERASEPAGE 0x508

Register for erasing a page in code area

 
ERASEPCR1 0x508

Register for erasing a page in code area. Equivalent to ERASEPAGE.

Deprecated

ERASEALL 0x50C

Register for erasing all non-volatile user memory

 
ERASEPCR0 0x510

Register for erasing a page in code area. Equivalent to ERASEPAGE.

Deprecated

ERASEUICR 0x514

Register for erasing user information configuration registers

 
ERASEPAGEPARTIAL 0x518

Register for partial erase of a page in code area

 
ERASEPAGEPARTIALCFG 0x51C

Register for partial erase configuration

 

READY

Address offset: 0x400

Ready flag

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 R

READY

   

NVMC is ready or busy

     

Busy

0

NVMC is busy (ongoing write or erase operation)

     

Ready

1

NVMC is ready

CONFIG

Address offset: 0x504

Configuration register

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 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

WEN

   

Program memory access mode. It is strongly recommended to activate erase and write modes only when they are actively used.

     

Ren

0

Read only access

     

Wen

1

Write enabled

     

Een

2

Erase enabled

ERASEPAGE

Address offset: 0x508

Register for erasing a page in code area

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 A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A 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

ERASEPAGE

   

Register for starting erase of a page in code area.

The value is the address to the page to be erased (addresses of first word in page). Note that the erase must be enabled using CONFIG.WEN before the page can be erased. Attempts to erase pages that are outside the code area may result in undesirable behavior, e.g. the wrong page may be erased.

ERASEPCR1 ( Deprecated )

Address offset: 0x508

Register for erasing a page in code area. Equivalent to ERASEPAGE.

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 A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A 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

ERASEPCR1

   

Register for erasing a page in code area. Equivalent to ERASEPAGE.

ERASEALL

Address offset: 0x50C

Register for erasing all non-volatile user memory

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 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

ERASEALL

   

Erase all non-volatile memory including UICR registers. Note that the erase must be enabled using CONFIG.WEN before the non-volatile memory can be erased.

     

NoOperation

0

No operation

     

Erase

1

Start erase of chip

ERASEPCR0 ( Deprecated )

Address offset: 0x510

Register for erasing a page in code area. Equivalent to ERASEPAGE.

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 A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A 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

ERASEPCR0

   

Register for starting erase of a page in code area. Equivalent to ERASEPAGE.

ERASEUICR

Address offset: 0x514

Register for erasing user information configuration registers

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 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

ERASEUICR

   

Register starting erase of all user information configuration registers. Note that the erase must be enabled using CONFIG.WEN before the UICR can be erased.

     

NoOperation

0

No operation

     

Erase

1

Start erase of UICR

ERASEPAGEPARTIAL

Address offset: 0x518

Register for partial erase of a page in code area

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 A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A 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

ERASEPAGEPARTIAL

   

Register for starting partial erase of a page in code area

The value is the address to the page to be partially erased (address of the first word in page). Note that the erase must be enabled using CONFIG.WEN before every erase page partial and disabled using CONFIG.WEN after every erase page partial. Attempts to erase pages that are outside the code area may result in undesirable behaviour, e.g. the wrong page may be erased.

ERASEPAGEPARTIALCFG

Address offset: 0x51C

Register for partial erase configuration

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 A A A A A A
Reset 0x0000000A 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 0 1 0
ID RW Field Value ID Value Description
A RW

DURATION

   

Duration of the partial erase in milliseconds

The user must ensure that the total erase time is long enough for a complete erase of the flash page.

Electrical specification

Flash programming

Symbol Description Min. Typ. Max. Units
nWRITE

Number of times a 32-bit word can be written before erase

2  
nENDURANCE

Erase cycles per page

10000  
tWRITE

Time to write one 32-bit word

411 µs
tERASEPAGE

Time to erase one page

851 ms
tERASEALL

Time to erase all flash

1691 ms
tERASEPAGEPARTIAL,acc

Accuracy of the partial page erase duration. Total execution time for one partial page erase is defined as ERASEPAGEPARTIALCFG * tERASEPAGEPARTIAL,acc.

1.051  
1 HFXO is used here