6. Embedded flash memory (FLASH)
6.1 FLASH introduction
The embedded flash memory (FLASH) manages the accesses of any master to the up to 1 Mbyte of embedded nonvolatile memory. It implements the read, program and erase operations, error corrections, as well as various integrity and confidentiality protection mechanisms.
The FLASH manages the automatic loading of nonvolatile user option bytes at power-on reset, and implements the dynamic update of these options.
The FLASH also features a one-time-programmable (OTP) area and a read-only area provisioned by STMicroelectronics during the product manufacturing.
6.2 FLASH main features
- • Up to 1 Mbyte of nonvolatile memory divided into two banks
- • Flash memory read operations supporting multiple lengths: 128, 64, 32, 16 bits, or 1 byte
- • Flash memory programming by 128 bits in user area and 32 or 16 bits for OTP and flash data area
- • 8-Kbyte page erase, bank erase and dual-bank mass erase
- • 16 EDATA pages per bank that can be configured
- – to extend user area, 2-Kbyte pages, 128-bit programming
- – to offer user data flash memory, 1.5-Kbyte pages, 16- or 32-bit programming
- • Dual-bank organization supporting:
- – Simultaneous operations: read-while-write (program and erase) is supported.
- – The two banks share the same interface. Write and erase can not be performed in parallel (write-while-write is not supported).
- – Bank swapping: the address mapping of the user flash memory of each bank can be swapped, along with the corresponding registers. Security flags remain valid for the physical bank. So the data are not revealed by swapping to a bank with lower security configuration.
- • Error code correction (ECC): one error detection/correction or two error detections per 128-bit FLASH word using 9 ECC bits
- • User configurable nonvolatile option bytes
- • Flash memory enhanced protections, activated by option bytes
- – Read out protection for protecting memory content from debug access
- – Page group write-protection (WRPG)
- – HDP protection providing temporal isolation for startup code
- • 4.5-Kbyte one-time programmable (OTP) area
- • Read-only area provisioned by STMicroelectronics
- • Prefetch is reading the next sequential instruction from flash memory
6.3 FLASH functional description
6.3.1 FLASH block diagram
The following figure shows the simplified FLASH block diagram.
Figure 9. FLASH block diagram (simplified)

The diagram illustrates the internal architecture of the FLASH memory. It is divided into several functional blocks:
- External Interfaces:
- RCC: Provides flash_rst and po_rst signals.
- TAMP: Provides tamper_in signal.
- SBS: Provides addresses, RDP level, and HDP signals. It also receives dbg_en from the DEBUG block.
- DEBUG: Receives dbg_en from SBS.
- FLASH Internal Components:
- 32-bit AHB bus: Connects to the AHB Interface Configuration port.
- 128-bit AHB bus: Connects to the AHB interface.
- AHB Interface Configuration port: Manages configuration and connects to Register banks (containing OB words).
- IRQ logic: Generates flash_it interrupt.
- AHB interface: Handles user, system flash access, and read-only areas (OTP, data flash, engi, user option). It connects to the Flash interface logic.
- Flash interface logic: Manages data flow between the AHB interface and the memory banks. It includes 128-bit data paths and control/status signals.
- Nonvolatile memory bank1 and bank2: The main storage areas, each with 128-bit data paths and ECC/redundancy control.
MSv76083V1
6.3.2 FLASH signals
The flash memory has two AHB connections: the flash AHB register interface and the main AHB interface.
FLASH AHB register interface
- • Data size is 32 bits.
- • Except for some registers (FLASH_KEYR and FLASH_OPTKEYR that are used to insert unlock sequences for control and option registers and can be written in 32 bits), it is possible to read and write all registers in 8, 16, and 32 bits.
- • When an unlock sequence for control and option registers is incorrect, a bus error is raised. Otherwise, no read or write errors are generated on the bus.
Main AHB interface
The AHB data bus size is 128 bits. This interface is used to handle two different targets:
- • Code placed in user and system memory. 128-bit data are protected by 9 bits of ECC.
- • OTP, user data flash, and read only memory. 16-bit data are protected by 6 bits of ECC.
The main AHB interface is implemented as follows:
- • User and system memory:
- – Supports multiple length: 128-, 64-, 32-, 16-, and 8-bit data width.
- – There is a read buffer of 128 bits for each bank where the last data read is stored. If the data is available in the read buffer, no read access is done to the flash memory. Buffer is flushed when write access, OTP access, flash data area access user option change request or erase operation occurs
- – There is a prefetch of the same size as the read buffer.
- – A 9-bit ECC is associated to each 128-bit data flash memory word
- • OTP, user data flash and read only
- – Two dedicated data buffer of 137 bits are used to manage 16-bit data with 6-bit ECC.
- – Reading two times the same address triggers two FLASH read accesses.
- – During a read access, two wait states are added in addition of the memory wait states. These wait states are necessary to parse the data buffer
- – Each write access triggers a write in the flash memory.
- – 6-bit ECC is associated to each 16-bit data.
Caution: By default, all the AHB memory range is cacheable. For regions where caching is not permitted (OTP, RO, data area), MPU has to be used to disable local cacheability. An attempt to cache these regions will generate a Hard Fault.
6.3.3 Flash memory architecture and usage
Flash memory architecture
Figure 10 shows the nonvolatile memory organization supported by the FLASH.
Figure 10. Embedded flash memory organization

The embedded flash nonvolatile memory is composed of:
- • A main memory block is organized into two banks. Each bank is divided in pages of 8 Kbytes each and features flash-word rows of 128 bits + 9 bits of ECC per word.
- • A system memory block of 48 Kbytes is divided into two 24-Kbyte banks. Each bank is divided in three 8-Kbyte pages. The system flash memory is ECC protected (9-bit ECC per 128-bit word).
- • A set of nonvolatile option bytes loaded at reset by the FLASH, and accessible by the application software only through the AHB configuration register interface.
- • A 4.5-Kbyte OTP area that can be written only once by the application software
- • A 1.5-Kbyte read-only area . It contains a unique device ID and product information.
- • Up to 32 pages of user flash memory for data, 16 pages of 2 Kbytes per bank if EDATA_EN bit is reset, or 16 pages of 1.5 Kbytes per bank if EDATA_EN bit is set.
The overall flash memory architecture and its corresponding access interface is summarized in Table 24.
Partition usage
The figure below shows how the FLASH is used by both STMicroelectronics and the application software.
Figure 11. FLASH use

The diagram illustrates the partitioning of STM32C5 nonvolatile memory. It is divided into three main sections: User memory, Flash data area, and System memory. User memory contains Application software. Flash data area contains Application data. System memory contains Bootloader, Reserved, Read-only and OTP area, User option bytes, and Reserved. The diagram also shows the mapping of these sections to SWAP_BANK 0 and SWAP_BANK 1. A yellow box indicates 'Mapped on AHB config port' for the Read-only and OTP area. Another yellow box indicates 'Managed through registers only' for the User option bytes. The diagram is labeled MSv76011V2.
User and system memories are used differently according to RDP level and other option-byte settings.
The user memory contains the application code and associated constant data. The flash data area contains application nonvolatile data. The system memory contains the STM32 bootloader. When a reset occurs, the core jumps to the boot address configured through the BOOT pin (or BOOT option bit), the BOOTADD option bytes, and the RDP level.
Note: For more information on option-byte setup for boot, refer to Section 6.4.8.
6.3.4 FLASH read operations
Read operation overview
Read access to main flash memory and system flash memory operates as follows:
- • There is a 128-bit read data buffer associated to each bank, which stores the last data read. If several consecutive read accesses request data belonging to the same FLASH data word (128 bits), the data are read directly from the current data read buffer, without triggering additional FLASH read operations. This mechanism occurs each time a read access is granted. When a read access is rejected for security reasons, the corresponding read error response is issued by the FLASH and no read operation to flash memory is triggered
- • The read data buffer is disabled when write access or OTP access, user option change request or other erase operation occurs
Read access to OTP, RO, and user data flash area operates as follows:
- 1. A FLASH data word of 137 bits is read and stored in a temporary buffer.
- 2. The interface parses the 137-bit data word, and selects the 16- or 32-bit data requested.
- 3. While parsing the 137-bit data word, two wait states are added and the AHB bus is stalled.
- 4. If the application reads an OTP data or user data FLASH not previously written, a double ECC error is reported, and only word full of set bits is returned (see Section 6.3.9 for details). The read data (in 16 bits) is stored in FLASH_ECCDR, so that the user can identify if the double ECC error is due to a virgin data or a real ECC error.
- 5. Reading two times the same address triggers two reads in the flash memory.
- 6. For 8-bit accesses, an AHB bus error is generated.
Note: The FLASH can perform single-error correction and double-error detection while read operations are being executed (see Section 6.3.8).
Instruction prefetch
The Cortex-M33 fetches instructions and literal pools (constants/data) over the C-Bus and through the instruction cache if it is enabled. The prefetch block aims at increasing the efficiency of C-Bus accesses when the ICACHE is enabled, by reducing the cache refill latency.
Prefetch is efficient in case of sequential code; prefetch in the flash memory allows the next sequential instruction line to be read from the flash memory, while the current instruction line is being filled in the ICACHE and executed by the CPU.
Prefetch is enabled by setting the PRFTEN bit in FLASH_ACR. PRFTEN must be set only if at least one wait state is needed to access the flash memory.
Adjusting read-timing constraints
The FLASH clock must be enabled and running before reading data from a nonvolatile memory.
To correctly read data from the flash memory, the number of wait states (LATENCY) must be correctly programmed in FLASH_ACR, according to the FLASH main AHB interface clock frequency.
The table below shows the correspondence between the number of wait states (LATENCY), the programming delay parameter (WRHIGHFREQ) and the FLASH clock frequency.
Table 20. FLASH recommended number of wait states and programming delay
| Number of wait states (LATENCY) | Programming delay (WRHIGHFREQ) | Interface clock frequency |
|---|---|---|
| 0 WS (1 FLASH clock cycle) | 00 | [0 MHz; 34 MHz] |
| 1 WS (2 FLASH clock cycles) | [34 MHz; 68 MHz] | |
| 2 WS (3 FLASH clock cycles) | 01 | [68 MHz; 102 MHz] |
| 3 WS (4 FLASH clock cycles) | [102 MHz; 136 MHz] | |
| 4 WS (5 FLASH clock cycles) | 10 | [136 MHz; 144 MHz] |
Adjusting system frequency
After power-on, the FLASH is clocked by the divided by 3 high speed internal oscillator HSIDIV3 at 48 MHz. As a result, a conservative 7 wait-state latency is specified in FLASH_ACR register (see the previous table).
When changing the bus frequency, the application software must follow the sequence described below, in order to tune the number of wait states required to access the nonvolatile memory.
To increase the CPU frequency:
- 1. If necessary, program LATENCY and WRHIGHFREQ bits to the right value in the FLASH_ACR register, as described in Table 20.
- 2. Check that the new number of wait states is taken into account by reading back the FLASH_ACR register.
- 3. Modify the FLASH clock source and/or the clock prescaler in the RCC_CFGR register of the reset and clock controller (RCC).
- 4. Check that the new FLASH clock source and/or the new AHB clock prescaler value are taken in account by reading back the FLASH clock source status and/or the prescaler value in the RCC_CFGR register of the reset and clock controller (RCC).
To decrease the CPU frequency:
- 1. Modify the FLASH clock source and/or the clock prescaler in the RCC_CFGR register of reset and clock controller (RCC).
- 2. Check that the FLASH new clock source and/or the new clock prescaler value are taken in account by reading back the FLASH clock source status and/or the AHB interface prescaler value in the RCC_CFGR register of reset and clock controller (RCC).
- 3. If necessary, program the LATENCY and WRHIGHFREQ bits to the right value in FLASH_ACR register, as described in Table 20.
- 4. Check that the new number of wait states has been taken into account by reading back the FLASH_ACR register.
Error code correction (ECC)
The embedded flash memory embeds an error correction mechanism. Single-error correction and double-error detection are performed for each read operation. For more details, refer to Section 6.3.8.
Read errors
When the ECC mechanism is not able to correct the read operation, the embedded flash memory reports read errors as described in Section 6.8.5
Read interrupts
See Section 6.9 for details.
6.3.5 FLASH program operations
Program operation overview
Program operation consists in issuing write commands. The FLASH supports the execution of only one write-command at a time. Write-while-write are not supported. Nothing prevents overwriting a nonvirgin FLASH word but this is not recommended. The result may lead to invalid data and inconsistent ECC code.
User flash memory
For the user flash memory, 9-bit ECC is associated to each 128-bit data FLASH word. In this case, the FLASH must always perform write operations to nonvolatile memory with a 128-bit word granularity. Once the write buffer is full (128 bits), the busy flag BSY is set and a programming operation is triggered.
There is a write buffer common to bank1 and 2, which support multiple write-access types (128, 64, 32, 16, or 8 bits). The application can decide to write as little as 8- to a 128-bit FLASH word. In this case, a force-write mechanism to the 128 bits + ECC is used (see FW bit in FLASH_CR register).
When the write request is issued to the memory any new write request stalls the main AHB bus.
Moreover, while a write operation is ongoing, any new read request to the same bank stalls the main AHB bus.
OTP, RO and flash data area
When the target memory is OTP, RO, and flash data area pages, 6-bit ECC code is associated to each 16-bit data FLASH word. The FLASH supports 16- or 32-bit write operations (8-bit write operations are not supported). For 8-bit accesses, write accesses are ignored. There is no write data buffer. Each write access triggers a write in the flash memory.
Note: The OTP area is typically write-protected on the final product, as described in Section 6.3.9.
The write protection check is performed at the reception of the write request (during address phase). Write protection is not checked anymore at the output of the write buffer. If a write protection violation is detected, the write operation is canceled and write protection error (WRPERR) is raised in FLASH_SR register.
Note: For write protections of main FLASH, flash data area, and OTP, see Section 6.5.
Monitoring ongoing write operations
The application software can use a status flag located in FLASH_SR to monitor ongoing write operations. Since only one operation is possible at a time, this flag indicates if any operation (write, erase, option change) is ongoing, whatever the banks.
- • BSY: This bit indicates that an effective write, erase, option-byte change is ongoing in the nonvolatile memory. This flag is not dedicated to a specific bank. It is set when an operation is starting on the memory, whatever the bank. An operation is triggered by:
- – An erase (FLASH_CR.STRT)
- – A write (FLASH_CR.PG + AHB write)
- – An option modification (FLASH_OPTCR.OPTSTRT)
It is cleared when the current operation is ending or in case of error.
Note: BSY is also set when an OBL launch is triggered (OBL_LAUNCH in FLASH_OPTCR).
- • WBNE: This bit indicates that the FLASH is waiting for new data to complete the 128-bit write buffer. In this state, the write buffer is not empty. It is reset as soon as the application software fills the write buffer, or forces the writes by using FW bit in FLASH_CR, or an error is detected. When WBNE is high, it is not possible to launch an erase or an option modification on flash memory.
- • DBNE: This bit indicates that the data buffer for parsing 16-bits data is not empty:
- – 16-bit data write access is received and that the data buffer is being filled. It is set at the receipt of the a valid write access and it is reset as soon as the write request preparation has been processed.
Note: If the flash memory is busy at the receipt of the AHB write request, the CPU execution is stalled.
Enabling write operations
Before programming the user flash memory in bank1 or bank2, the application software must make sure that the PG bit is set to 1 in FLASH_CR. If it is not the case, an unlock sequence must be used (see Section 6.5.4), and the PG bit must be set.
When the option bytes must be modified, the application software must make sure that FLASH_OPTCR is unlocked. If this is not the case, an unlock sequence must be used (see Section 6.5.4).
Note: The application software must not unlock an already unlocked register, otherwise this register remains locked until the next system reset.
If needed, the application software can update the programming delay, as described in Adjusting programming timing constraints.
Writing to FLASH_CR and FLASH_OPTCR
The FLASH_CR and FLASH_OPTCR registers are not accessible in write mode when the BSY bit is set. Any attempt to write these registers while the BSY bit is set causes the AHB bus to stall until BSY bit is cleared.
Single-write sequence
The recommended single-write sequence is the following:
- 1. Make sure protection mechanism does not prevent to attempt programming.
- 2. Check that no flash memory operation is ongoing by checking the BSY bit in FLASH_SR and DBNE bit in FLASH_SR. Check that the write buffer is empty by checking the WBNE bit in FLASH_SR.
- 3. Check and clear all the error flags due to previous programming/erase operation.
- 4. Unlock the FLASH_CR register, as described in Section 6.5.4 (only if register is not already unlocked).
- 5. Enable write operations by setting PG bit in FLASH_CR.
- 6. Write one FLASH word at aligned address.
Note: WBNE flag indicates if the 128-bit write buffer is waiting for new data.
No erase request or options change request is allowed between the first write to the write buffer and the completion of the FLASH write operation.
- 7. Wait for the BSY bit to be cleared in the corresponding FLASH_SR register.
- 8. Clear PG bit in FLASH_CR if there are not any more programming requests.
If step 6 is executed incrementally (for example byte per byte), the write buffer can become partially filled. In this case, the application software can decide to force-write what is stored in the write buffer by using FW bit in FLASH_CR. In this particular case, the unwritten bits are automatically set to 1. If no bit in the write buffer is cleared to 0, the FW bit has no effect.
Note: Using a force-write operation prevents the application from updating later the missing bits with a value different from 1, which is likely to lead to a unexpected or inconsistent data or ECC.
Adjusting programming timing constraints
Program operation timing constraints depend of the FLASH clock frequency, which directly impacts the performance. If timing constraints are too tight, the nonvolatile memory does not operate correctly. If they are too lax, the programming speed is not optimal.
The user must therefore trim the optimal programming delay through the WRHIGHFREQ parameter in the FLASH_ACR register. Refer to Table 20 in Section 6.3.4 for the recommended programming delay depending on the FLASH clock frequency. FLASH_ACR configuration register is common to both banks.
The application software must check that no program/erase operation is ongoing before modifying WRHIGHFREQ parameter.
Caution: Modifying WRHIGHFREQ while programming/erasing the flash memory may corrupt the flash memory content.
Programming errors
When a program operation fails, an error can be reported as described in Section 6.8.
Programming interrupts
See Section 6.9 for details.
6.3.6 FLASH erase operations
Erase operation overview
The FLASH can perform erase operations on 8-Kbyte or 2-Kbyte user pages, on one user flash memory bank, or on two user flash memory banks (for example mass erase).
For more details in user flash memory, user data flash, user options, and OTP erase protection, see Section 6.5.
Erase commands are issued through the AHB configuration interface. Since the FLASH supports one operation at a time, if it receives simultaneously a write and an erase request, an error flag is raised and both operation are canceled (see Section 6.8 for details).
After successful completion of erase, all the bytes in the erased flash sectors are set to the flash default 0xFF value.
Erase and WRP
If the application software attempts to erase a user page that is write protected, the page erase operation is aborted, and the WRPERR flag is raised in FLASH_SR, as described in Section 6.8.1.
FLASH busy
Busy signals are described in Monitoring ongoing write operations.
Writing to FLASH_CR and FLASH_OPTCR
Refer to Writing to FLASH_CR and FLASH_OPTCR.
Enabling erase operations
Before erasing a page, the application software must make sure that FLASH_CR is unlocked. If this is not the case, an unlock sequence must be used (see Section 6.5.4).
Note: The application software must not unlock a register that is already unlocked, otherwise this register remains locked until next system reset. This can be used to deliberately lock-out a register from further accesses.
Similar constraints apply to bank erase requests.
FLASH page-erase sequence
To erase an 8-Kbyte, a 2-Kbyte user page, or a 1.5K-byte if in data flash without security protections, proceed as follows:
- 1. Make sure protection mechanism does not prevent to attempt page erase (WRP, HDP).
- 2. Check that no flash memory operation is ongoing by checking the BSY and DBNE bits in FLASH_SR, and that the write buffer is empty by checking the WBNE bit in the same register.
- 3. Check and clear all the error flags due to previous programming/erase operation (refer to Section 6.8 for details).
- 4. Unlock the FLASH_CR register, as described in Section 6.5.4 (only if register is not already unlocked).
- 5. Set BKSEL bit, PER bit, EDATASEL bit, and PNB bitfield in FLASH_CR.
- – BKSEL indicates in which physical bank page has to be erased.
- – PER indicates a page erase operation.
- – EDATASEL indicates if the page targeted is a 2-Kbyte EDATA page or a standard page.
- – PNB contains the target page number.
- 6. Set the STRT bit in FLASH_CR.
- 7. Wait for the BSY bit to be cleared in FLASH_SR.
- 8. STRT bit is automatically cleared at the end of the page erase or in case of error.
- 9. Clear PER in FLASH_CR if there are not anymore page erase request to be issued.
Note: If another erase flag is requested simultaneously to the page erase, an PGSERR error is generated.
Standard flash memory bank-erase sequence
To erase a bank , proceed as follows:
- 1. Make sure protection mechanism does not prevent to attempt bank erase.
- 2. Check that no flash memory operation is ongoing by checking the BSY and DBNE bits in FLASH_SR, and that the write buffer is empty by checking the WBNE bit in the same register.
- 3. Check and clear all the error flags due to previous programming/erase operation (refer to Section 6.8 for details).
- 4. Unlock the FLASH_CR register, as described in Section 6.5.4 (only if register is not already unlocked).
- 5. Set the BKSEL bit and the BER bit in FLASH_CR to the targeted physical bank (swap setting is ignored).
- 6. Set the STRT bit in FLASH_CR to start the bank erase operation. Then wait until the BSY bit is cleared in FLASH_SR.
- 7. STRT bit is automatically cleared at the end of erase sequence or in case of error.
- 8. Clear BER in FLASH_CR if there is not other bank erase request to be issued.
FLASH mass-erase sequence
The application software can set the MER bit to 1 in FLASH_CR, as described below:
- 1. Make sure protection mechanisms do not prevent to attempt mass erase (Section 6.5)
- 2. Check that no flash memory operation is ongoing by checking the BSY and DBNE bits in FLASH_SR, and that the write buffer is empty by checking the WBNE bit in the same register.
- 3. Check and clear all the error flags due to previous programming/erase operation (refer to Section 6.8 for details).
- 4. Unlock the FLASH_CR register as described in Section 6.5.4 (only if the registers are not already unlocked).
- 5. Set the MER bit to 1 in FLASH_CR.
- 6. Set the STRT bit in FLASH_CR. Then wait until BSY bit is cleared in FLASH_SR.
- 7. STRT bit is cleared automatically at the end of the erase sequence or in case of error.
- 8. Clear MER in FLASH_CR.
Note: Mass and bank erase also erase flash data area pages from the erased bank.
6.3.7 FLASH parallel operations
Since the nonvolatile memory is divided into two independent banks but encapsulated in the same macro, the embedded flash memory interface only supports reading in one bank while writing or erasing is executed in the other bank. This feature is called read-while-write capability (RWW). It does not support write-while-write or read-while-read. Same is valid for the flash data area.
In all cases, the sequences are described in Section 6.3.4, Section 6.3.5, and Section 6.3.6.
6.3.8 Flash memory error protections
Error correction codes (ECC)
The FLASH supports an error correction code (ECC) mechanism. It is based on the SECDED algorithm in order to correct single errors and detect double errors.
This mechanism uses 9 ECC bits per 128-bit FLASH word, and applies to user and system memory.
For read-only, OTP, and user flash data area, a stronger 6 ECC bits per 16-bit word is used. A double ECC error is generated for an OTP or flash data area virgin word (for example a word with 22 bits at 1). When this OTP or flash data area word is no more virgin, the ECC error disappears.
More specifically, during each read operation from a 128-bit FLASH word, the FLASH retrieves the 9-bit ECC information, computes the ECC of the FLASH word, and compares the result with the reference value. If they do not match, the corresponding ECC error is raised as described in Section 6.8.5.
During each program operation, a 9-bit ECC code is associated to each 128-bit data FLASH word, and the resulting 137-bit FLASH word information is written in nonvolatile memory.
A similar mechanism applies to read-only, OTP, and user flash data area but with 6-bit ECC for 16-bit data.
6.3.9 OTP and RO memory access
OTP and RO memory are accessed through the main AHB interface. The OTP is accessible at the address 0x08FF E000 to 0x08FF F1FF, and the read only section is accessible from 0x08FF F800 to 0x08FF FDFF.
They are stored in a distinct way as data or user flash, filling first 4 bytes of a page, then 5th to 8th and finally 9th to 12th as columns. It does not impact addressing nor locking mechanism but requires caution to decode ECC double error or operation interruption. Indeed for OTP or RO the ECC address returned in ADDR_ECC bitfield indicate FLASH line.
In case of double error detection, the corrupted access can be identified thanks to DATA_ADDR_ECC bitfield returning OTP position on the line.
They are stored in a different way than user data, each sector being filled vertically 32-bit wise as described in the table below.
Table 21. OTP first page organization
| FLASH line | OTP position on FLASH line | |||||
|---|---|---|---|---|---|---|
| 0b000 | 0b001 | 0b010 | 0b011 | 0b100 | 0b101 | |
| 0x00 | OTP0 0x08FF E000 | OTP1 0x08FF E002 | OTP256 0x08FF E200 | OTP257 0x08FF E202 | OTP512 0x08FF E400 | OTP513 0x08FF E402 |
| 0x01 | OTP2 0x08FF E004 | OTP3 0x08FF E006 | OTP258 0x08FF E204 | OTP259 0x08FF E206 | OTP514 0x08FF E404 | OTP515 0x08FF E406 |
| ... | ... | ... | ... | |||
| 0x7E | OTP252 0x08FF E1F8 | OTP253 0x08FF E1FA | OTP508 0x08FF E3F8 | OTP509 0x08FF E3FA | OTP764 0x08FF E5F8 | OTP765 0x08FF E5FA |
| 0x7F | OTP254 0x08FF E1FC | OTP255 0x08FF E1FE | OTP510 0x08FF E3FC | OTP511 0x08FF E3FE | OTP766 0x08FF E5FC | OTP767 0x08FF E5FE |
FLASH one-time programmable area
The FLASH offers a 4608-byte memory area dedicated to application nonconfidential, one-time programmable data (OTP). This area is composed of 2304 words of 16 bits (plus 6 bits of ECC). It cannot be erased, and can be written only once. The OTP area can be accessed through the main AHB interface from address 0x08FF E000 to 0x08FF F1FE (last whole readable 16-bit word).
OTP data can be programmed by the application software by chunks of 16 bits. Overwriting an already programmed 16-bit half-word can lead to data and ECC errors and is therefore not supported.
Note: The OTP area is virgin when the device is delivered by STMicroelectronics.
When reading OTP data with a single error corrected or a double error detected, the FLASH reports read errors, as described in Section 6.8.5.
When reading OTP data not written by the application software (such as virgin OTP), the ECC correction reports a double-error detection (ECCD), and the data are to be found in FLASH_ECCDR register. ECCD implies a NMI raised, unless setting in SBS prevents that.
OTP write protection
OTP data are organized as 24 blocks of 96 OTP words, as shown in Table 22. An entire OTP block can be protected (locked) from write accesses by setting the LOCKBLi (i = 0 to 23) bit corresponding to each OTP block (i = 0 to 23) in FLASH_OTPBLR. A block can be write-protected whether or not it has been programmed (even partially).
The OTP block locking operation is irreversible and independent from the product life state.
Note: The OTP area can only be accessed in read mode.
Table 22. Flash memory OTP organization
| OTP block | AHB address | AHB word | Lock bit | |
|---|---|---|---|---|
| [31:16] | [15:0] | |||
| Block 0 | 0x08FF E000 | OTP0001 | OTP0000 | LOCKBL0 |
| 0x08FF E004 | OTP0003 | OTP0002 | ||
| ... | ||||
| 0x08FF E0BC | OTP0095 | OTP0094 | ||
| Block 1 | 0x08FF E0C0 | OTP0097 | OTP0096 | LOCKBL1 |
| 0x08FF E0C4 | OTP0099 | OTP0098 | ||
| ... | ||||
| 0x08FF E17C | OTP0191 | OTP0190 | ||
| Block 2 | 0x08FF E180 | OTP0193 | OTP0192 | LOCKBL2 |
| 0x08FF E184 | OTP0195 | OTP0194 | ||
| ... | ||||
| 0x08FF E23C | OTP0287 | OTP0286 | ||
| ... | ||||
| Block 23 | 0x08FF F140 | OTP2209 | OTP2208 | LOCKBL23 |
| 0x08FF F144 | OTP2211 | OTP2210 | ||
| ... | ||||
| 0x08FF F1FC | OTP2303 | OTP2302 | ||
OTP write sequence
Follow the sequence below to write an OTP word:
- 1. Check that no flash memory operation is ongoing by checking the BSY bit in FLASH_SR register, and that the data buffer is empty by checking the DBNE bit in the same register.
- 2. Check and clear all the error flags due to previous programming/erase operation.
- 3. Set PG bit in FLASH_CR.
- 4. Check the protection status of the target OTP word (see Table 22). The corresponding LOCKBLi bit must not be set to 1.
- 5. Write two OTP words (32 bits) corresponding to the 4-byte aligned address shown in Table 22. Alternatively, the application software can program separately the 16-bit MSB or 16-bit LSB. In this case the first 16-bit write operation starts immediately without waiting for the second one
- 6. Wait for the BSY bit to be cleared in FLASH_SR.
- 7. Clear PG bit in FLASH_CR if there is not any programming request anymore in the bank.
- 8. Optionally, lock the OTP block using LOCKBLi to prevent further data changes.
Note: Do not write twice an OTP 16-bit word, otherwise an ECC error can be generated.
Writing OTP data at byte level is not supported and generates a bus error.
To avoid data corruption, it is important to complete the OTP write process (for example by reading back the OTP value), before starting an option change.
FLASH read-only area
The FLASH offers a 1.5-Kbyte memory area to store read-only data, also referred to as RO. This area is mapped as described in Table 23. It can be accessed through the AHB main port. This read-only area is protected by a robust ECC scheme, as explained in Section 6.3.8.
The read-only information that can be used by the application software are described in the table below. This information is programmed by STMicroelectronics.
Table 23. Read-only public data organization
| Read-only data name | Address | Comment |
|---|---|---|
| Unique device ID | 0x08FF F800 | U_ID[31:0] |
| 0x08FF F804 | U_ID[63:32] | |
| 0x08FF F808 | U_ID[96:64] | |
| Flash memory size/ package | 0x08FF F80C | Flash memory size[15:0] || Package code[15:0] |
| Factory calibration | 0x08FF F810 | Vrefint calibration value[31:0] |
| 0x08FF F814 | TS_CAL1[31:0] | |
| 0x08FF F818 | TS_CAL2[31:0] | |
| Reserved | 0x08FF F81C to 0x08FF FDFF | Reserved information |
6.3.10 FLASH data area
The FLASH offers 64 Kbytes to store extra code, data or emulate EEPROM in 16 EDATA pages per bank. Based on value of EDATA_EN option bit this area is one of the following:
- • Protected by a robust 6-bit ECC, which allows a write granularity of 16 or 32 bits at the expense of having page size shrunk to 1.5 Kbytes. This area is the FLASH data area and the memory can be accessed through the AHB system port from address 0x0900 0000 to 0x0900 BFFF.
- • Page size of 2 Kbytes with write granularity of 128 bits protected by a robust 9-bit ECC. This area is part of user main flash memory and instructions can be fetched from addresses 0x0840 0000 to 0x0840 FFFF (see Figure 13).
Caution: This area cannot be used as a boot location in BOOTADD.
For greater efficiency, it is always recommended to use page on the other bank for the FLASH data area, so that the application benefits from RWW capability of the dual-bank arrangement.
When SWAP_BANK feature is enabled, the banks are swapped: the flash data area in bank 2 are accessible from 0x0900 000 to 0x0900 5FFF, and the data in bank 1 are accessible from 0x0900 6000 to 0x0900 BFFF.
A bus error is generated on:
- • Attempt to access one of the following address
- – Between 0x0900 0000 to 0x0900 BFFF, and this address is not a data FLASH valid page.
- – Between 0x0840 0000 to 0x0840 FFFF, and this address is not a user memory valid page.
- • Attempt to fetch instructions from data FLASH area (fetch from 0x0900 0000 to 0x0900 BFFF result in HardFault).
Erasing these EDATA pages is possible by setting the EDATASEL bit and following a page erase request. The EDATA page erasure is not taking account EDATA_EN bit.
Protections and security of data FLASH area are detailed in Section 6.5.
Figure 12. FLASH data area memory map

MSv76086V1
6.3.11 FLASH bank swapping
The FLASH bank1 and bank2 can be swapped for the user FLASH. This feature can be used after a firmware upgrade to restart the device on the new firmware. Bank swapping is a user option-byte flag controlled by the SWAP_BANK bit in FLASH_OPTCR register.
Bank specific settings for data area and security attributes follow the original bank and its contents. The control bit BKSEL always refers to physical bank, not the SWAP_BANK setting.
Table 24 shows the memory map that can be accessed depending on the SWAP_BANK bit configuration.
Table 24. Memory map and the swapping option (STM32C53x/542 devices)
| Region name | Start address | End address | Size | Page |
|---|---|---|---|---|
| (bytes) (bytes) | Region name Region name | |||
| area SWAP_ BANK = 0 | SWAP_ BANK = 1 | |||
| area SWAP_ BANK = 0 | 0x0800 0000 | 0x0800 1FFF | 8 K | Page 0 |
| area SWAP_ BANK = 0 | 0x0800 2000 Bank2 | 0x0800 3FFF | 8 K | Page 1 |
| area SWAP_ BANK = 0 | ... | ... | ... | ... |
| User main | 0x0801 E000 | 0x0801 FFFF | 8 K | Page 15 |
| memory | 0x0802 0000 | 0x0802 1FFF | 8 K | Page 0 |
| memory | 0x0802 2000 Bank1 | 0x0802 3FFF | 8 K | Page 1 |
| memory | ... | ... | ... | ... |
| memory | 0x0803 E000 | 0x0803 FFFF | 8 K | Page 15 |
| memory | 0x0840 0000 | 0x0840 07FF | 2 K | EDATA Page 0 |
| memory | 0x0840 0800 Bank2 | 0x0840 0FFF | 2 K | EDATA Page 1 |
| User flash | ... | ... | ... | ... |
| memory / | 0x0840 7800 | 0x0840 7FFF | 2 K | EDATA Page 15 |
| EDATA_E | 0x0840 8000 | 0x0840 87FF | 2 K | EDATA Page 0 |
| N cleared Bank2 | 0x0840 8800 Bank1 | 0x0840 8FFF | 2 K | EDATA Page 1 |
| N cleared Bank2 | ... | ... | ... | ... |
| N cleared Bank2 | 0x0840 F800 | 0x0840 FFFF | 2 K | EDATA Page 15 |
| N cleared Bank2 | 0x0900 0000 | 0x0900 05FF | 1.5K | EDATA Page 0 |
| N cleared Bank2 | 0x0900 0600 Bank2 | 0x0900 0BFF | 1.5K | EDATA Page 1 |
| Data flash | ... | ... | ... | ... |
| memory / | 0x0900 5A00 | 0x0900 5FFF | 1.5K | EDATA Page 15 |
| EDATA_E | 0x0900 6000 | 0x0900 65FF | 1.5K | EDATA Page 0 |
| N set Bank2 | 0x0900 6600 Bank1 | 0x0900 6BFF | 1.5K | EDATA Page 1 |
| N set Bank2 | ... | ... | ... | ... |
| N set Bank2 | 0x0900 B800 | 0x0900 BFFF | 1.5K | EDATA Page 15 |
| N set Bank2 | 0x0BF8 0000 | 0x0BF8 1FFF | 8 K | System 1 Page 0 |
| Bank1 | 0x0BF8 2000 | 0x0BF8 3FFF | 8 K | System 1 Page 1 |
| System | 0x0BF8 4000 | 0x0BF8 5FFF | 8 K | System 1 Page 2 |
| memory | 0x0BF8 6000 | 0x0BF8 7FFF | 8 K | System 2 Page 0 |
| Bank2 | 0x0BF8 8000 | 0x0BF8 9FFF | 8 K | System 2 Page 1 |
| Bank2 | 0x0BF8 A000 | 0x0BF8 BFFF | 8 K | System 2 Page 2 |
Table 25. Memory map and the swapping option (STM32C55x/562 devices)
| Region name | Start address | End address | Size | Page |
|---|---|---|---|---|
| Bank2 | (bytes) (bytes) | Region name Region name | ||
| area SWAP_ BANK = 0 | SWAP_ BANK = 1 | |||
| area SWAP_ BANK = 0 | 0x0800 0000 | 0x0800 1FFF | 8 K | Page 0 |
| area SWAP_ BANK = 0 | 0x0800 2000 Bank2 | 0x0800 3FFF | 8 K | Page 1 |
| area SWAP_ BANK = 0 | ... | ... | ... | ... |
| User main | 0x0803 E000 | 0x0803 FFFF | 8 K | Page 31 |
| memory | 0x0804 0000 | 0x0804 1FFF | 8 K | Page 0 |
| memory | 0x0804 2000 Bank1 | 0x0804 3FFF | 8 K | Page 1 |
| memory | ... | ... | ... | ... |
| memory | 0x0807 E000 | 0x0807 FFFF | 8 K | Page 31 |
| memory | 0x0840 0000 | 0x0840 07FF | 2 K | EDATA Page 0 |
| memory | 0x0840 0800 Bank2 | 0x0840 0FFF | 2 K | EDATA Page 1 |
| User flash | ... | ... | ... | ... |
| memory / | 0x0840 7800 | 0x0840 7FFF | 2 K | EDATA Page 15 |
| EDATA_E | 0x0840 8000 | 0x0840 87FF | 2 K | EDATA Page 0 |
| N cleared Bank2 | 0x0840 8800 Bank1 | 0x0840 8FFF | 2 K | EDATA Page 1 |
| N cleared Bank2 | ... | ... | ... | ... |
| N cleared Bank2 | 0x0840 F800 | 0x0840 FFFF | 2 K | EDATA Page 15 |
| N cleared Bank2 | 0x0900 0000 | 0x0900 05FF | 1.5K | EDATA Page 0 |
| N cleared Bank2 | 0x0900 0600 Bank2 | 0x0900 0BFF | 1.5K | EDATA Page 1 |
| Data flash | ... | ... | ... | ... |
| memory / | 0x0900 5A00 | 0x0900 5FFF | 1.5K | EDATA Page 15 |
| EDATA_E | 0x0900 6000 | 0x0900 65FF | 1.5K | EDATA Page 0 |
| N set Bank2 | 0x0900 6600 Bank1 | 0x0900 6BFF | 1.5K | EDATA Page 1 |
| N set Bank2 | ... | ... | ... | ... |
| N set Bank2 | 0x0900 B800 | 0x0900 BFFF | 1.5K | EDATA Page 15 |
| N set Bank2 | 0x0BF8 0000 | 0x0BF8 1FFF | 8 K | System 1 Page 0 |
| Bank1 | 0x0BF8 2000 | 0x0BF8 3FFF | 8 K | System 1 Page 1 |
| System | 0x0BF8 4000 | 0x0BF8 5FFF | 8 K | System 1 Page 2 |
| memory | 0x0BF8 6000 | 0x0BF8 7FFF | 8 K | System 2 Page 0 |
| Bank2 | 0x0BF8 8000 | 0x0BF8 9FFF | 8 K | System 2 Page 1 |
| Bank2 | 0x0BF8 A000 | 0x0BF8 BFFF | 8 K | System 2 Page 2 |
Table 26. Memory map and the swapping option (STM32C59x/5A3 devices)
| Region name | Start address | End address | Size | Page |
|---|---|---|---|---|
| Bank2 | (bytes) (bytes) | Region name Region name | ||
| area SWAP_ BANK = 0 | SWAP_ BANK = 1 | |||
| area SWAP_ BANK = 0 | 0x0800 0000 | 0x0800 1FFF | 8 K | Page 0 |
| area SWAP_ BANK = 0 | 0x0800 2000 Bank2 | 0x0800 3FFF | 8 K | Page 1 |
| area SWAP_ BANK = 0 | ... | ... | ... | ... |
| User main | 0x0807 E000 | 0x0807 FFFF | 8 K | Page 63 |
| memory | 0x0808 0000 | 0x0808 1FFF | 8 K | Page 0 |
| memory | 0x0808 2000 Bank1 | 0x0808 3FFF | 8 K | Page 1 |
| memory | ... | ... | ... | ... |
| memory | 0x080F E000 | 0x080F FFFF | 8 K | Page 63 |
| memory | 0x0840 0000 | 0x0840 07FF | 2 K | EDATA Page 0 |
| memory | 0x0840 0800 Bank2 | 0x0840 0FFF | 2 K | EDATA Page 1 |
| User flash | ... | ... | ... | ... |
| memory / | 0x0840 7800 | 0x0840 7FFF | 2 K | EDATA Page 15 |
| EDATA_E | 0x0840 8000 | 0x0840 87FF | 2 K | EDATA Page 0 |
| N cleared Bank2 | 0x0840 8800 Bank1 | 0x0840 8FFF | 2 K | EDATA Page 1 |
| N cleared Bank2 | ... | ... | ... | ... |
| N cleared Bank2 | 0x0840 F800 | 0x0840 FFFF | 2 K | EDATA Page 15 |
| N cleared Bank2 | 0x0900 0000 | 0x0900 05FF | 1.5K | EDATA Page 0 |
| N cleared Bank2 | 0x0900 0600 Bank2 | 0x0900 0BFF | 1.5K | EDATA Page 1 |
| Data flash | ... | ... | ... | ... |
| memory / | 0x0900 5A00 | 0x0900 5FFF | 1.5K | EDATA Page 15 |
| EDATA_E | 0x0900 6000 | 0x0900 65FF | 1.5K | EDATA Page 0 |
| N set Bank2 | 0x0900 6600 Bank1 | 0x0900 6BFF | 1.5K | EDATA Page 1 |
| N set Bank2 | ... | ... | ... | ... |
| N set Bank2 | 0x0900 B800 | 0x0900 BFFF | 1.5K | EDATA Page 15 |
| N set Bank2 | 0x0BF8 0000 | 0x0BF8 1FFF | 8 K | System 1 Page 0 |
| Bank1 | 0x0BF8 2000 | 0x0BF8 3FFF | 8 K | System 1 Page 1 |
| System | 0x0BF8 4000 | 0x0BF8 5FFF | 8 K | System 1 Page 2 |
| memory | 0x0BF8 6000 | 0x0BF8 7FFF | 8 K | System 2 Page 0 |
| Bank2 | 0x0BF8 8000 | 0x0BF8 9FFF | 8 K | System 2 Page 1 |
| Bank2 | 0x0BF8 A000 | 0x0BF8 BFFF | 8 K | System 2 Page 2 |
The SWAP_BANK bit in FLASH_OPTCR register is loaded from the SWAP_BANK option bit only after system reset or POR.
To change the SWAP_BANK bit (for example to apply a new firmware update), respect the sequence below:
- 1. Check that no flash memory operation is ongoing by checking the BSY and DBNE bits in FLASH_SR, and that the write buffer is empty by checking the WBNE bit in the same register.
- 2. Clear all error flags due to a previous operation.
- 3. Unlock OPTLOCK bit, if not already unlocked.
- 4. Set the new desired SWAP_BANK value in the FLASH_OPTSR_PRG register.
- 5. Start the option-byte change sequence by setting the OPTSTRT bit in FLASH_OPTCR.
- 6. Once the option-byte change has completed, FLASH_OPTSR_CUR contains the expected SWAP_BANK value, but SWAP_BANK bit in FLASH_OPTCR has not yet been modified, and the bank swapping is not yet effective
- 7. Force a system reset or a POR. When the reset rises up, the bank swapping is effective (SWAP_BANK value updated in FLASH_OPTCR) and the new firmware must be executed.
Note: The SWAP_BANK bit in FLASH_OPTCR is read-only and cannot be modified by the application software.
The SWAP_BANK option bit in FLASH_OPTSR_PRG can be modified whatever the RDP level. Instead of being locked by RDP_LEVEL, it is locked by BOOT_LOCK User OB.
The figure below gives an overview of the bank swapping sequence.
Figure 13. FLASH bank swapping sequence

6.3.12 FLASH reset and clocks
Reset management
The FLASH can be reset by a core domain reset, driven by the reset and clock control (RCC). The main effects of this reset are the following:
- • All registers, except for option-byte registers, are cleared, including read and write latencies. If the bank swapping option is changed, it is applied.
- • Most control registers are automatically protected against write operations. To unprotect them, new unlock sequences must be used as described in Section 6.5.4.
The FLASH can be reset by a power-on core domain reset, driven by the RCC. When the reset falls, all option-byte registers are reset. When the reset rises up, the option bytes are
loaded, potentially applying new features. During this loading sequence, the device remains under reset and the FLASH is not accessible.
Reset occurring during FLASH operation
If a reset occurs during a FLASH operation (programing, erase, or option change), the content of the flash memory is not guaranteed. It is mandatory for flash memory integrity than user restarts the operation. The status register FLASH_OPSR gives information if any FLASH operation has been interrupted by a reset.
FLASH_OPSR.CODE_OP gives opcode of operation. The table below indicates how to use FLASH_OPSR and which operation is required.
Table 27. Recommended reactions to FLASH_OPSR contents
| CODE_OP | Operation interrupted | OTP_OP | BK_OP | DATA_OP | Flash memory area | ADDR_OP min | ADDR_OP max | Recommended action |
|---|---|---|---|---|---|---|---|---|
| 0b000 | No operation ongoing while reset | 0 | 0 | 0 | _(1) | - | - | No extra action |
| 0b001 | Write operation | 0 | 0/1 | 0 | User flash | 0x0000 | 0x7FFF(2) | Erase page and rewrite |
| 1 | 1 | 0 | OTP(3) | 0x0200 | 0x037F | |||
| 0 | 0/1 | 1 | EDATA Page(4) | 0x0000 | 0x07FF(2) | |||
| 0b011 | Page erase(5) | 0 | 0/1 | 0 | User flash | 0x0000 | 0x7FFF | Relaunch page erase |
| 0 | 0/1 | 1 | EDATA Page | 0x0000 | 0x07FF | |||
| 0b100 | Bank erase | 0 | 0/1 | 0 | User flash | - | - | Relaunch bank erase |
| 0b101 | Mass erase | 0 | 0 | 0 | - | - | Relaunch mass erase | |
| 0b110 | Option change | 0 | 0 | 0 | User configuration | - | - | New attempt on option change |
- 1. '-' = does not matter.
- 2. ADDR_OP maximum depends on the flash memory size of the device.
- 3. OTP are organized per column, refer to Section 6.3.9.
- 4. Depends on EDATA setting in the OB.
- 5. Addresses indicated are aligned to page start, data area pages are erased by erase request to corresponding user flash memory page.
Clock management
The FLASH uses the microcontroller AHB interface clock HCLK.
6.4 FLASH option bytes
6.4.1 About option bytes
The FLASH includes a set of nonvolatile option bytes. They are loaded at power-on reset and can be read and modified only through configuration registers.
This section documents:
- • When option bytes are loaded.
- • How application software can modify them.
- • The detailed list of option bytes, together with their initial values (before the first option byte change, user default configuration).
6.4.2 Option-byte loading
There are multiple ways of loading the option bytes into the FLASH:
- 1. Power-on wake-up
When the device is first powered, the FLASH automatically loads all the option bytes. During the option-byte loading (OBL) sequence, the device remains under reset, and the FLASH cannot be accessed. - 2. Wake-up from system Standby mode
When the core power domain, which contains the FLASH, is switched from Standby mode to Run mode, the FLASH behaves as during a power-on sequence. During OBL time, the device is not under reset, unlike power-on sequence. - 3. Dedicated option-byte reloading by the application
When the user application successfully modifies the option-byte content through the FLASH registers, the nonvolatile option bytes are programmed, and the FLASH automatically reloads all option bytes to update the option registers.
Note: The option-byte read sequence is protected by error correction code.
In case of error, the option bytes are loaded with default values (see Section 6.4.3). This value differs from the initial values (user default configuration), and tends to be more restrictive.
6.4.3 Option-byte modification
Changing user option bytes
A user-option-byte change operation can be used to modify the configuration and the protection settings saved in the nonvolatile option byte area.
There are numerous rules enforced when attempting to change a user option byte, they are all summarized in Section 6.4.9. Failing to stick to these rules usually results in error, described in Section 6.8.6.
The FLASH features two sets of option-byte registers:
- • The first register set contains the current values of the option bytes. Their names have the _CUR extension. All “_CUR” registers are read-only. Their values are automatically loaded from the nonvolatile memory after power-on reset, wake-up from system Standby mode, or after an option-byte change operation.
- • The second register set allows the modification of the option bytes. Their names contain the _PRG extension. All “_PRG” registers can be accessed in read/write mode.
When the OPTLOCK bit in FLASH_OPTCR is set, modifying the FLASH_XXX_PRG registers is not possible.
When OPTSTRT bit is set to 1, the FLASH checks the programming sequence (PGSERR), and the conditions described in Section 6.4.9 (OPTCHANGEERR). If no error has been detected (PGSERR/OPTCHANGEERR), the FLASH launches the option-byte modification in its nonvolatile memory, and updates the option-byte registers with _CUR extension.
If one of the condition described in Section 6.4.9, Section 6.8.6, or Section 6.8.2 is not respected, the FLASH aborts the option-byte change operation. In this case, FLASH_XXX_PRG registers are not overwritten by current option value. The user application can check what was wrong in their configuration.
Unlocking the option-byte modification
After reset, the OPTLOCK bit is set to 1 and FLASH_OPTCR is locked. As a result, the application software must unlock the option configuration register before attempting to change the option bytes. FLASH_OPTCR unlock sequence is described in Section 6.5.4.
Option-byte modification sequence
To modify user option bytes, follow the sequence below:
- 1. Check that no flash memory operation is ongoing by checking the BSY bit in FLASH_SR, and that the write buffer is empty by checking the WBNE bit in the same register.
- 2. Check the data buffer is empty (DBNE = 0) in FLASH_SR.
- 3. Clear all error flags due to a previous operation.
- 4. Unlock FLASH_OPTCR register as described in Section 6.5.4, unless the register is already unlocked.
- 5. Write the desired new option byte values in the corresponding option registers (FLASH_XXX_PRG).
- 6. Set the option byte start change OPTSTRT bit to 1 in FLASH_OPTCR.
- 7. Wait until BSY bit is cleared in FLASH_SR.
- 8. OPTSTRT bit is cleared automatically at the end of the sequence (or in case of error).
- 9. Perform a system reset if the RDP level, SWAP_BANK, or BOOTADD options have been changed. A system reset is also recommended if other option bytes have been modified.
Note: If a reset or a power-down occurs while the option-byte modification is ongoing, the original option-byte value is kept. A new option-byte modification sequence is required to program the new value
6.4.4 Option-byte overview
Table 28 lists all the user option bytes managed through the FLASH registers, as well as initial values before the first option-byte change (user default configuration).
Table 28. Option-byte organization
| Register | 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 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| FLASH_OPTSR | SWAP_BANK | SINGLE_BANK | EDATA_EN | Res. | Res. | Res. | Res. | Res. | BOOT0 | BOOT_SEL | IWDG_STDBY | IWDG_STOP | Res. | Res. | Res. | Res. | RDP_LEVEL | NRST_STDBY | NRST_STOP | Res. | Res. | Res. | Res. | Res. | Res. | Res. | |||||||
| 0 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | |||||||||||||||
| FLASH_OPTSR2 | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | |
| 1 | 1 | 1 | |||||||||||||||||||||||||||||||
| FLASH_BOOTR | BOOTADD[31:0] | BOOT_LOCK | |||||||||||||||||||||||||||||||
| 0x0800_00 | 0xC3 | ||||||||||||||||||||||||||||||||
| FLASH_WRPSG1R | WRPG[31:0] | ||||||||||||||||||||||||||||||||
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ||
| FLASH_WRPSG2R | WRPG[31:0] | ||||||||||||||||||||||||||||||||
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ||
| FLASH_OTPBLR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | LOCKBL | ||||||||||||||||||||||||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||||||||
| FLASH_BL_COM_CFG | BL_COM_CFG[31:0] | ||||||||||||||||||||||||||||||||
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ||
| FLASH_HDP1R | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_END | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_STRT | ||||||||||||||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | ||||||||||||||||||
| FLASH_HDP2R | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_END | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_STRT | ||||||||||||||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | ||||||||||||||||||
| FLASH_OEMKEY R1 | OEMKEY[31:0] | ||||||||||||||||||||||||||||||||
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ||
| FLASH_OEMKEY R2 | OEMKEY[63:32] | ||||||||||||||||||||||||||||||||
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ||
Table 28. Option-byte organization (continued)
| Register | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| FLASH_OEMKEYR3 | OEMKEY[95:64] | |||||||||||||||||||||||||||||||
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ||
| FLASH_OEMKEYR4 | OEMKEY[127:96] | |||||||||||||||||||||||||||||||
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ||
| FLASH_BSKEY | BSKEY[31:0] | |||||||||||||||||||||||||||||||
| 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | |
6.4.5 Description of user and system option bytes
The general-purpose option bytes that can be used by the application are listed below:
- • Bank management
- – SWAP_BANK: bank swapping option, set to 1 to swap user FLASH banks after boot (see Section 6.3.11).
- – SINGLE_BANK: this bit is applicable for:
- - STM32C53x/542 with 128 Kbytes of flash
- - STM32C55x/562 with 256 Kbytes of flash
- - STM32C59x/5A3 with 512 Kbytes of flash
- • Watchdog management
- – IWDG_STOP: independent watchdog IWDG counter active in Stop mode if 1 (stop counting or freeze if 0)
- – IWDG_STDBY: independent watchdog IWDG counter active in Standby mode if 1 (stop counting or freeze if 0)
- – IWDG_SW and WWDG_SW: hardware (0) or software (1) IWDG watchdog control selection
Note: If the hardware watchdog “control selection” feature is enabled (set to 0), the watchdog is automatically enabled at power-on, thus generating a reset unless the watchdog key register is written to or the down-counter is reloaded before the end-of-count is reached.
Depending on the configuration of IWDG_STOP and IWDG_STDBY options, the IWDG can continue counting (1) or not (0) when the device is in Stop or Standby mode, respectively. When the IWDG is kept running during Stop or Standby mode, it can wake up the device from these modes.
- • Reset management
- – NRST_STDBY: generates a reset when entering Standby mode if cleared to 0.
- – NRST_STOP: generates a reset when entering Stop mode if cleared to 0.
Note: Whenever a Standby (respectively Stop) mode entry sequence is successfully executed, the device is reset instead of entering Standby (respectively Stop) mode if NRST_STDBY (respectively NRST_STOP) is cleared to 0.

- • Bootloader configuration
After reset, if the STMicroelectronics bootloader is selected as boot location, it reads the contents of BL_COM_CFG, and only attempts to establish communication on selected interfaces. This setting allows using the bootloader safely in applications where it otherwise may cause trouble by reconfiguring some GPIOs.
When STMicroelectronics delivers the device, the values programmed in the general-purpose option bytes are the following:
- • Watchdog management
- – IWDG active in Standby and Stop modes (option value = 0x1)
- – IWDG not automatically enabled at power-on (option byte value = 0x1)
- • Reset management:
- – A reset is not generated when the device enters Standby or Stop low-power mode (option byte value = 0x1)
Refer to Section 6.10 for details.
6.4.6 Description of data protection option bytes
The option bytes that can be used to enhance data protection are listed below:
- • RDP_LEVEL[7:0]: product lifecycle state (see Section 6.5.8 for details)
- • WRP1/2: write-protection option of pages in bank1 (respectively bank2). It is active low. Refer to Section 6.5.5 for details.
Table 29. Write-protection management
| WRP bit number | Write-protected pages | |
|---|---|---|
| STM32C53x/542/55x/562 | STM32C59x/5A3 | |
| Bit 0 | Page 0 | Page [0 to 1] |
| Bit 1 | Page 1 | Page [2 to 3] |
| ... | ... | ... |
| Bit N | Page N | Page [2 x N to 2 x N +1] |
- • HDPx: HDPL exclusive area control in the user flash memory.
When factory programmed, values of the data-protection option bytes are the following:
- • Read-out protection level: L0 (Open)
- • Write protection disabled (all option byte bits set to 1)
Refer to Section 6.10 for details.
6.4.7 Description of data FLASH option bytes
The option bytes that can be used to address the data FLASH pages are:
- • EDATA_EN: activate data FLASH area for this device (see Section 6.3.10 for details).
6.4.8 Description of boot-address option byte
Below the list of option bytes that can be used to configure the appropriate boot address for an application:
- • RDP_LEVEL: Influences the boot sequence indirectly.
- • BOOTADD: Selects default boot address.
- • BOOT_LOCK: Protects the boot configuration from further modification attempts.
- • SWAP_BANK: bank swapping option, set to 1 to swap user FLASH banks after boot (see Section 6.3.11). If BOOT_LOCK is active, the value in SWAP_BANK is fixed, read-only.
- • BOOT0 management
- – BOOT0: This option bit is the value of BOOT0 used depending on BOOT_SEL to select boot location. BOOTLOADER (1) or User code(0).
- – BOOT_SEL: BOOT0 value is taken from option bit (0) or from BOOT0 pin (1)
When STMicroelectronics delivers the device, the RDP_LEVEL is L0, BOOT_LOCK is not set (0xC3). Address BOOTADD is 0x0800 0000.
Refer to Section 6.10 for details.
6.4.9 Specific rules for modifying option bytes
Besides the OPTLOCK bit and register access rules, there are additional protection means for selected security-sensitive option byte fields.
Multiple option bytes can be modified simultaneously, but if they rely on each other for protection, both states are checked.
With few exceptions listed in this section, failing to uphold the rules results in raising OPTCHANGEERR flag (Section 6.8.6 for additional details).
Table 30. Specific OB modifying rules overview
| OB | HDPL | Value | RDP level |
|---|---|---|---|
| RDP_LEVEL | - | Set of possible transitions | Set of possible transitions (Table 36) |
| HDP | 1(1) | - | - |
| BOOTADD | - | - | L0 open |
| LOCKBL | - | One way switch(1) | - |
| SWAP_BANK | - | BOOT_LOCK can restrict this change | - |
| BOOT_LOCK | - | - | L0 open |
1. No OPTCHANGEERR is raised in violation of this.
Even in the closed RDP_LEVEL progression, some OBs can still be modified, if all the other constraints are satisfied. An overview is presented in the table below.
Table 31. OBs modifiable in L2 product
| RDP_LEVEL | OBs that can be modified |
|---|---|
| L2_wBS or L2 | SWAP_BANK, LOCKBL, RDP_LEVEL |
Specific rules must be respected to update the following OBs:
- • RDP_LEVEL: its transitions follow a state machine with two types of transition. Locking down the product is allowed without restriction. Opening the product is only possible under the condition that OEM key were provisioned ahead. The regression to L0 RDP_LEVEL results in the erasing of the protected content (see Section 6.5.8).
- • HDP: Can only be modified in HDPL0 and HDPL1.
- • BOOTADD: Can only be changed in Open RDP L0 (open).
- • LOCKBL: Can only be changed freely in one direction. A permanent irreversible switch.
- • SWAP_BANK: Cannot be modified when BOOT_LOCK is active (0xB4).
- • BOOT_LOCK: Can only be changed freely in locking direction. Unlock is possible in L0.
Note: For all user option bytes above, default values are loaded and Tamper is signaled when a double ECC error occurs during OBL.
6.5 FLASH security and protections
Since sensitive information are stored in the flash memory, it is important to protect it against unwanted operations such as reading confidential areas, illegal programming of immutable pages, or malicious flash memory erasing.
For that purpose, the flash memory implements the following protection mechanisms:
- • Temporal isolation protection (HDP)
- • Configuration protection
- • User FLASH write protection
- • Device boot state management
- • OTP locking
This section provides a detailed description of all these security mechanisms.
The flash memory interface evaluates the access restrictions in the following order:
- 1. Write protection (for write access)
- 2. HDP
6.5.1 Hide protection (HDP)
A nonvolatile hide-protection (HDP) area per bank can be defined with a page granularity. Access to the hide-protection area can be denied by progressing the HDPL level in the SBS.
When the HDPL = 1, no user FLASH is protected by the HDP. With HDPL ≥ 2, the user OB defined HDP area in each bank is closed. No read, write, fetch, or erase is allowed in the HDP area.
The HDP area can be extended. The extension setting is only a register value, not stored in the OB. With HDPL = 3, the HDP area remains activated and the extension is added. If an extension is added while the base user OB defined area is not active, the extension covers one more page, because HDPx_END page is also protected.
The HDPL level can be only cleared by a system reset, there is no means to deactivate the HDP area.
The protected HDP area is defined by setting its size using start and end pages .
The size of the inaccessible area can be extended using register FLASH_HDPEXTR values HDPx_EXT. The value HDPx_EXT is a number of pages added to the HDP area (past the HDPx_END page). The volatile HDPx_EXT value in the register can be increased, but cannot decrement.
In case of HDPx_STRT > HDPx_END, the extension covers (HDPx_EXT + 1) size area between pages marked by HDPx_END and HDPx_END + HDPx_EXT.
By default, the HDPx_END is set to zero and HDPx_STRT is set to one. This means that the HDP area in user FLASH is zero size, and extends from the FLASH start address (first page).
For example, to protect area by HDP from 0x0800 2000 (included) to 0x0800 7FFF (included):
- • For physical bank1, the option-byte registers must be programmed with:
- – HDP1_STRT = 0x01,
- – HDP1_END = 0x03.
Figure 14. HDP in user flash memory

- • Once the HDPL is incremented to 2, the marked area becomes inaccessible. The HDPL = 2 code then sets the extension size to 2. Once the HDPL is incremented to 3, the extension area becomes also inaccessible.
Alternatively, if:
- – HDP1_END = 0
- – HDP1_START = 1
- – HDPx_EXT = 1
Page 0 and page 1 are HDP protected.
Or a rather unusual example:
- – HDP1_END = 2
- – HDP1_START = 7
- – HDPx_EXT = 3
- • Pages 2 until 5 are HDP protected. Here the user must know that, if the application needs pages 2 until 4 only as HDP area, HDPx_EXT must be programmed at 2 instead of 3.
- • If the two banks are swapped, the protection defined to physical bank1 remains on the physical bank1, unaffected by swapping. Separate protection applies to physical bank2 and the option bytes registers must also be programmed with:
- – HDP2_STRT = 0x01
- – HDP2_END = 0x03
Note: For more details on the bank-swapping mechanism, refer to Section 6.5.3.
Table 32. Secure hide protection| HDPx watermark option byte values (x = 1, 2) | Hide protection area | |
|---|---|---|
| HDPL = 1 | - | No inaccessible HDP area in user flash memory |
| HDPL = 2 | HDPx_END < HDPx_STRT | No inaccessible HDP area in user flash memory |
| HDPx_END = HDPx_STRT | Exactly one page is protected by HDP | |
| HDPx_END > HDPx_STRT | The area between HDPx_STRT and HDPx_END is HDP protected. | |
| HDPL = 3 | HDPx_END < HDPx_STRT and HDPx_EXT = 0 | No inaccessible HDP area in user flash memory |
| HDPx_END < HDPx_STRT and HDPx_EXT > 0 | The area between (HDPx_END + HDPx_EXT) is HDP protected | |
| HDPx_END ≥ HDPx_STRT and HDPx_EXT > 0 | The area between min (HDPx_STRT, HDPx_END) and (HDPx_END + HDPx_EXT) is HDP protected | |
| HDP protection | User flash memory | |||
|---|---|---|---|---|
| Access to OB HDP area | Access to EXT HDP area | |||
| HDPL 2 or 3 | HDPL1 | HDPL3 | HDPL1 or HDPL 2 | |
| Fetch | BUS ERROR | OK | BUS ERROR | OK |
| Read | RAZ | RAZ | ||
| Write | WI, WRPERR | If WRP disabled: OK else: WI, WRPERR | WI, WRPERR | If not WRP: OK Else: WI, WRPERR |
| Erase (mass erase) | ||||
6.5.2 Flash memory register privileged and unprivileged modes
The FLASH registers can be read and written by privileged and unprivileged accesses, depending on the PRIV bit in FLASH_PRIVCFGR.
- When the PRIV bit is reset, all flash memory registers can be read and written by both privileged or unprivileged access.
- When the PRIV bit is set, all flash memory registers can be read and written by privileged access only. Unprivileged access to a privileged registers is RAZ/WI.
6.5.3 Flash memory banks attributes in case of bank swap
The SWAP_BANK option bit modifies the address of each bank in the memory map.
When SWAP_BANK is reset, FLASH bank1 is mapped at the lower address range.
When SWAP_BANK is set, FLASH bank1 is mapped at the higher address range. FLASH
bank attributes follow their bank contents so there is no need to modify their setting registers when swapping banks:
- • FLASH write protection page FLASH_WRPGR (refer to Section 6.5.5)
- • Hide protection in FLASH_HDPx registers
The SWAP_BANK is rendered immutable by setting BOOT_LOCK.
Note: The BK_ECC bit in FLASH_OEMKEYR2_CUR and FLASH_ECCDETR, BKSEL bit in FLASH_CR always refers to bank1 (respectively bank2) when it is low (respectively high), regardless of the SWAP_BANK value.
The figure below shows how security attributes and protections behave in case of bank swap.
Figure 15. Protection attributes in case of bank swap illustration

MSv76014V1
6.5.4 Flash memory configuration protection
The FLASH uses hardware mechanisms to protect the following assets against unwanted or spurious modifications (such as software bugs):
- • Option-byte changes
- • Write operations
- • Erase commands
- • Interrupt masking
The FLASH configuration registers protection is summarized in Table 34. Registers not present in this table are not protected by a key.
Table 34. FLASH interface register protection summary
| Register name | Unlocking register | Protected asset |
|---|---|---|
| FLASH_CR | FLASH_KEYR | Write/erase control |
| FLASH_OPTCR | FLASH_OPTKEYR | FLASH bank option-byte words change |
6.5.5 Write protection
The purpose of FLASH write protection is to prevent unwanted modifications to embedded nonvolatile code and/or data.
A write-protected group of pages can neither be erased nor programmed. As a result, a bank erase cannot be performed if some page is write-protected, unless a RDP level transition to L0 is triggered (erasing the whole user flash memory).
Note: Write protection errors are documented in Section 6.8.
6.5.6 FLASH data area protections
The FLASH can be configured to have 64-Kbyte (or 48-Kbyte if EDATA_EN is set) memory area to store data and emulate EEPROM (see Section 6.3.10: FLASH data area). These pages can not be protected by HDP or WRPGS whatever the setting of EDATA_EN.
6.5.7 RDP protection and life cycle management
Nonvolatile states, or debug states, are determined by the RDP levels set by user option bytes. Debug possibility and possibility to change selected security settings are related to this state. While the state is stored in the OB, it is the SBS that controls the debug policy.
Figure 16. RDP transitions

The diagram illustrates the transitions between different Readout Protection (RDP) levels. It features three main states: Level 0 (RDP = 0xED), Level 2 + boundary scan (RDP = 0xD1), and Level 2 (RDP = 0x72). Transitions are represented by colored arrows with specific conditions:
- Level 0 to Level 0: A green self-loop arrow indicates 'RDP unchanged + option-byte modification'.
- Level 0 to Level 2 + boundary scan: A blue arrow labeled 'Write RDP = 0xD1' indicates 'RDP increase + option-byte modification (valid at next reset)'.
- Level 0 to Level 2: A blue arrow labeled 'Write RDP = 0x72' indicates 'RDP increase + option-byte modification (valid at next reset)'.
- Level 2 + boundary scan to Level 0: A purple arrow labeled 'OEM' with a lock icon indicates 'Regression not possible by default – can be allowed by debug interface under reset with OEM key if previously provisioned in L0 RDP level'.
- Level 2 + boundary scan to Level 2: A yellow arrow labeled 'BSKEY' with a lock icon indicates 'Transition to L2 from L2_wBS thanks to BSKEY sent to debug interface under reset'.
- Level 2 to Level 2: A red self-loop arrow indicates 'No option bytes modification, except SWAP_BANK if BOOT_LOCK is not active'.
A legend at the bottom defines the arrow colors:
- Blue line: RDP increase + option-byte modification (valid at next reset)
- Purple line: Regression not possible by default – can be allowed by debug interface under reset with OEM key if previously provisioned in L0 RDP level
- Yellow line: Transition to L2 from L2_wBS thanks to BSKEY sent to debug interface under reset
- Green line: RDP unchanged + option-byte modification
- Red line: No option bytes modification, except SWAP_BANK if BOOT_LOCK is not active
MSv76087V2
HDP works equally regardless of the RDP level.
Table 35. RDP levels description
| RDP_LEVEL | Code in OB | Description |
|---|---|---|
| L0 (Open) | 0xED |
|
| L2_wBS (Closed + boundary scan) | 0xD1 |
|
| L2 (Closed) | 0x72 |
|
Caution: STMicroelectronics cannot functionally analyze parts with level 2 protection enabled. Regress parts to RDP level 0 before returning them for analysis (refer to OEM RDP lock mechanism).
6.5.8 RDP level transitions
Progressing to more closed levels is the normal product life cycle, that does not require security measures. Transition in direction to open level (RDP Level 0) is a regression, and is possible only thanks to the OEM Key.
There is no restriction on reading the current RDP level.
Transitions to L2 with boundary scan (L2_wBS) or L2 (L2) closed states
Transition from L0 to L2 with or without boundary scan is managed either by software running on the device, or directly, using a debug interface. By software, it is assumed that transitions are triggered by the bootloader, but generally any software running on the device can do a progress transition.
Caution: The new RDP Level will only be valid after next system or power reset.
Transition from L2 with boundary scan to L2 is only feasible thanks the BSKEY option-byte key:
- • If the BSKEY key have not been modified under L0 state, the default value apply.
- • If the BSKEY key have been modified under L0 state, the user must apply the key populated.
This key must be written under reset and L2 with boundary scan thanks to JTAG in order to progress to L2 RDP level.
Regression to L0 open debug level
This transition is a full regression, possible from either L2_wBS or L2 if an OEM key has been provisioned. The debug tools are used to provide the OEM key, if the key matches the one provisioned under L0, the device regresses securely in RDP L0.
The regression has the following consequences:
- • RDP level updated
- • User options updated (security settings reset)
- • Flash memory mass erase (even write protected pages)
Table 36. RDP levels transitions
| From | To(1) | ||
|---|---|---|---|
| L0 | L2_wBS | L2 | |
| L0 | - | OB update thanks to debug or bootloader | |
| L2_wBS | OEM key regression | - | BSKEY |
| L2 | OEM key regression | X | - |
1. 'X' = transitions that are not permitted (OPTCHANGEERR raised). '-' = no change.
An attempt to make an illegal transition results in the OPTCHANGEERR.
An incorrect RDP_LEVEL (on OBL) is interpreted as L2.
6.5.9 OEM key management
The OEM 128-bit key (OEMKEY) can be defined in order to permit the RDP regression.
OEM lock activation
The 128-bit key is coded on four registers: FLASH_OEMKEYR1 to FLASH_OEMKEYR4. OEMKEY and BSKEY cannot be read through these registers. They are read as zero.
Caution: OEMKEY can only be modified in readout protection level 0.
In order to activate OEM regression mechanism, the following steps are needed:
- 1. Check that the RDP is at L0.
- 2. Write a 128-bit key in FLASH_OEMKEYR1 to FLASH_OEMKEYR4.
- 3. Launch option modification by setting the OPTSTRT bit in FLASH_CR.
- 4. Wait for the BSY bit to be cleared and check that OPTWERR is not set.
- 5. Check that OEMLOCK is set.
Note: Once the OEM KEY has been programmed a first time, the OEMLOCK bit remains set. The user can reprogram the key, but cannot erase it.
OEM key validation mechanism
The OEM RDP lock mechanism is active when the OEMLOCK bit is set. The OEMKEY, can
be validated while in RDP L0.
- • Shift OEMKEY[31:0], then OEMKEY[63:32], then OEMKEY[95:64], then OEMKEY[127:96] through JTAG or SWD under reset in DBGMCU_DBG_AUTH_HOST register.
- • If this key matches the OEMKEY value:
- – A status bit in DBGMCU_DBG_VALR indicates that the adequate key has been successfully entered, a power sequence is required to clear the validation status bit. Omitting this step will prevent to enter RDP Level 2.
- • If the key does not match the OEMKEY value, a power sequence is required to clear the validation status bit and retry.
OEM RDP regression mechanism
The OEM RDP lock mechanism is active when the OEMLOCK bit is set. It authorizes RDP L2 to RDP L0 regression.
- • Shift OEMKEY[31:0], then OEMKEY[63:32], then OEMKEY[95:64], then OEMKEY[127:96] through JTAG or SWD under reset in DBGMCU_DBG_AUTH_HOST register.
- • If this key matches the OEMKEY value:
- – The RDP regression is launched by hardware when the reset is released (it is not possible to execute instructions when the key is matching).
- – A power-on reset must be applied (cycle VDD power supply off and on).
- • If the key does not match the OEMKEY value, the RDP regression is blocked until next power-on reset.
6.5.10 BS key management
The BS key is used to transition from RDP L2_wBS to L2. This key is coded in FLASH_BSKEYR, and can be modified only under RDP L0. During production, the value 0xAAAA AAAA is preprogrammed in BSKEY option bytes.
In order to personalize BSKEY transition mechanism, the following steps are needed:
- 1. Check that the RDP is at L0.
- 2. Write the desired key in FLASH_BSKEYR.
- 3. Launch option modification by setting the OPTSTRT bit in FLASH_CR.
- 4. Wait for the BSY bit to be cleared and check that OPTWERR is not set.
- 5. Check that BSLOCK bit has been set.
BSKEY RDP transition mechanism
In order to transition from RDP L2_wBS to L2 follow these steps:
- 1. Provide BSKEY[31:0] through JTAG or SWD under reset in DBGMCU_BSKEY_PWD. The key is 0xAAAA AAAA if not updated under L0, otherwise it is the value provisioned in BSKEYR.
- 2. If this key matches the BSKEY value:
- – The RDP transition is launched by hardware (it is not possible to execute instructions when the key is matching).
- – A power-on reset is applied (cycle VDD power supply off and on).
if the key does not match the BSKEY value, the RDP transition and any access to the flash memory are blocked until a next power-on reset.
6.5.11 One-time-programmable and read-only memory protections
OTP/RO in the flash memory are detailed in Section 6.3.9. There is no protection provided by the FLASH interface other than the dedicated write protection.
No write is possible to the RO area, once it was established in manufacturing. OTP write protection describes a method of locking out the OTP area.
The access conditions are summarized in the table below.
Table 37. OTP/RO access constraints
| - | Undefined addresses | 4.5-Kbyte page dedicated to OTP | 1.5-Kbyte page dedicated to RO |
|---|---|---|---|
| 0x08FF_F200 - F7FF 0x08FF_FE00 - FFFF | 0x08FF_E000 - F1FF OTP | 0x08FF_F800 - FDFF RO | |
| X | Bus error | Bus error | |
| R | If correct size OK, else bus error | ||
| W | Bus error if incorrect size. WRPERR if block is protected by LOCKBL, else OK. | If correct size WI, else bus error | |
| erase | Not applicable | ||
6.6 System memory
6.6.1 System memory introduction
System memory stores bootloader firmware that is programmed by ST during production. The bootloader provides runtime services to user firmware. These services are described hereafter in this section.
6.6.2 Bootloader user functions
As other microcontroller peripherals features and mapping, the bootloader library functions are exposed to user within the CMSIS device header file provided by the STM32CubeC5 firmware package. Refer to the online HAL/LL drivers documentation to get more details regarding STM32CubeC5 firmware package. Bootloader library provides runtime services through prefixed EXITHDP functions.
Table 38. C defined macro for HDP services
| C defined macro | Location in flash memory |
|---|---|
| EXITHDP_PFUNC | 0x0BF883E0 |
EXITHDPLIB
The user firmware calls EXITHDPLIB functions using EXITHDPLIB_PFUNC C defined macro, that points to a location within system memory.
Table 39. EXITHDPlib interface function list| Library | Function |
|---|---|
| EXITHDP_PFUNC | JumpHDPLvl2 |
| JumpHDPLvl3 |
The EXITHDPLIB functions are described within section hereafter.
a) JumpHDPLvl2
Prototype:
uint32_t JumpHDPLvl2(uint32_t VectorTableAddr, uint32_t MPUIndex)
User code function call example:
EXITHDPLIB_PFUNC->JumpHDPLvl2((uint32_t)NextVectorTableAddr, 1U );
Arguments:
- • VectorTableAddr:
Input parameter, address of the next vector table to apply.
The vector table format is the one used by the Cortex-M33 core.
- • MPUIndex:
Input parameter, MPU region index. Caller function shall define but keep disable the corresponding MPU region before calling JumpHDPLvl2. The function enables the MPU region before jumping to the Reset Handler of the vector table. The vector table Reset Handler function shall belong to the MPU region.
Descriptions:
User calls JumpHDPLvl2 to:
- • Close user Flash HDPL1 area by incrementing HDPL to 2
- • Jump to the reset handler embedded within the Vector Table which address is passed as input parameter
After closing HDPL1, JumpHDPLvl2 enables the MPU region provided as input parameter. Once the MPU is enabled, the function sets the SP to the address provided by the passed Vector Table and jumps to the Reset Handler function supported by the Vector Table too. JumpHDPLvl2 does not set the new vector table.
On successful execution, the function does not return and does not push LR onto the stack.
Errors:
In case of failure (bad input parameter value), EXITHDPLIB_Sec_JumpHDPLvl2 returns 0xF5F5F5F5.
b) JumpHDPLvl3
Prototype
uint32_t JumpHDPLv13(uint32_t VectorTableAddr, uint32_t MPUIndex)
User code function call example:
EXITHDPLIB_PFUNC->JumpHDPLv13((uint32_t)NextVectorTableAddr, 1U );
Arguments:
- • VectorTableAddr:
Input parameter, address of the next vector table to apply.
The vector table format is the one used by the Cortex-M33 core. - • MPUIndex:
Input parameter, MPU region index. Caller function shall define but keep disable the corresponding MPU region before calling JumpHDPLv13. The function enables the MPU region before jumping to the Reset Handler of the vector table. The vector table Reset Handler function shall belong to the MPU region.
Descriptions:
User calls JumpHDPLv13 to:
- • Close user Flash HDPL1 and HDPL2 areas by incrementing HDPL up to 3
- • Then jump to the reset handler embedded within the Vector Table which address is passed as input parameter
After closing HDPL1/2, JumpHDPLv13 enables the MPU region provided as input parameter. Once the MPU is enabled, the function sets the SP to the address provided by the passed Vector Table and jumps to the Reset Handler function supported by the Vector Table too. JumpHDPLv13 does not set the new vector table.
On successful execution, the function does not return and does not push LR onto the stack.
Errors:
In case of failure (bad input parameter value), JumpHDPLv13 returns 0xF5F5F5F5.
6.7 FLASH low-power modes
The table below summarizes the FLASH behavior in STM32 low-power modes. The FLASH belongs to the core domain.
Table 40. Effect of low-power modes on the FLASH
| Power mode | Allowed if FLASH busy | FLASH power mode |
|---|---|---|
| Run/Sleep | Yes | Run |
| Stop (clock stopped) | No | Clock gated (in normal or low-power mode) |
| Standby | No | Off |
The procedure to switch the FLASH into various power mode (run, clock gated, stopped, off) is described hereafter.
Note: For more information on microcontroller power states, refer to Section 8: Power control (PWR).
Managing FLASH domain switching to Stop or Standby mode
As explain in Table 40, if the FLASH informs the RCC that it is busy (BSY, DBNE, WBNE is set), the microcontroller cannot switch the core domain to Stop or Standby mode.
There are two ways to release the FLASH:
- • Reset the WBNE busy flag in FLASH_SR by any of the following actions:
- – Complete the write buffer with missing data.
- – Force the write operation without filling the missing data by activating the FW bit in FLASH_CR. This forces all missing data “high”.
- • Poll BSY busy bits in FLASH_SR until they are cleared. This indicates that all recorded write, erase, and option change operations are complete.
The microcontroller can then switch the domain to Stop or Standby mode.
6.8 FLASH error management
The FLASH automatically reports when an error occurs during a read, program or erase operation. A wide range of errors are reported:
- • Write protection error (WRPERR) (Section 6.8.1)
- • Programming sequence error (PGSERR) (Section 6.8.2)
- • Error correction code error (ECCC/ECCD) (Section 6.8.3)
- • Option-byte change error (OPTCHANGEERR) (Section 6.8.4)
The application software can individually enable the interrupt for each error, as detailed in Section 6.9.
Note: For all errors, the application software must clear the error flag before attempting a new modify operation.
Since there is just one write buffer and only one operation is allowed at a time, the write control bits and status bits are shared by both banks:
- • Write control bits (PG, FW, EOPIE, WRPERRIE, PGSERRIE, STRBERRIE, INCERRIE, CLR_EOP, CLR_WRPERR, CLR_STRBERR, CLR_INCERR, CLR_PGSERR) controls bank1 and 2 at the same time.
- • Write status flag reports (WBNE, DBNE, EOP, WRPERR, PGSERR, STRBERR, INCERR, BSY) error for bank1 and 2 at the same time.
6.8.1 Write protection error (WRPERR)
When an illegal erase/program operation is attempted to the nonvolatile memory, the FLASH sets the write protection error flag WRPERR in FLASH_SR.
An erase operation is rejected and flagged as illegal if it targets one of the following memory areas:
- • A page write-protected with WRP.
- • An HDP area while the HDPL has made it inaccessible.
A program operation is ignored and flagged as illegal if it targets one of the following memory areas:
- • The system flash memory
- • A user page write-protected with WRP
- • An OTP block, locked with LOCKBL
- • A reserved area
When WRPERR flag is raised, the operation is rejected and nothing is changed in the corresponding bank.
If this error is detected the write buffer is invalidated.
Note: WRPERR flag has to be cleared before any erase/program operation.
WRPERR flag is cleared by setting CLR_WRPERR bit to 1 in FLASH_CCR.
If WRPERRIE bit in FLASH_CR is set to 1, an interrupt is generated when WRPERR flag is raised (see Section 6.9 for details).
6.8.2 Programming sequence error (PGSERR)
When the programming sequence is incorrect, the FLASH interface sets the programming sequence error flag PGSERR in FLASH_SR.
More specifically, PGSERR flag is set when one of below conditions is met:
- • An error like INCERR, WRPERR, PGSERR, STRBERR, OPTCHANGEERR have not been cleared before requesting a new write or erase operation or options change.
- • For erase, PGSERR is set:
- – If missing erase operation (FLASH_CR): STRT = 1 with (MER = 0, PER = 0, and BER = 0)
- – If page and bank erase requested at the same time (STRT and more than one of MER, PER and BER)
- – If PG is set during erase operation (it ensures that no erase request and write request happen at the same time): (STRT = 1) with (PG = 1)
- – If an erase operation is started while write buffer is waiting for next data: (STRT = 1) with WBNE = 1.
- – If an erase operation is started while DBNE = 1.
- • For programming, PGSERR is set:
- – If missing write flag: A write operation is requested but the program enable bit PG has not been set in FLASH_CR prior to the request.
- – If a write operation to flash data area is requested but PG = 0.
- – If an AHB write request is received and (PER = 1, BER = 1, or MER = 1)
- – If a 16-bit data access requested while WBNE = 1.
- • For options change, PGSERR is set:
- – If an option change is started while write buffer is waiting for next data: OPTSTRT = 1 with WBNE = 1
- – If OPTSTRT is set with DBNE = 1.
When PGSERR flag is raised as consequence of failed write attempt (FLASH programming), the current program operation is aborted, and nothing is changed in the corresponding bank. The write data buffer is also invalidated.
Note: When PGSERR flag is raised, there is a risk that the last write operation performed by the application has been lost because of the above protection mechanism. Hence it is recommended to generate interrupts on PGSERR, and to verify in the interrupt handler if the last write operation has been successful by reading back the value in the flash memory.
The PGSERR flag also blocks any new program operation. This means that PGSERR must be cleared before starting a new program operation.
PGSERR flag is cleared by setting CLR_PGSERR bit to 1 in FLASH_CCR.
If PGSERRIE bit in FLASH_CR is set to 1, an interrupt is generated when PGSERR flag is raised (see Section 6.9 for details).
6.8.3 Strobe error (STRBERR)
When the application software writes several times to the same byte in the write buffer, the FLASH sets the strobe error flag STRBERR in FLASH_SR, whatever the target bank of the write access.
When STRBERR is raised, the current program operation is aborted and the write buffer is invalidated.
STRBERR is cleared by setting CLR_STRBERR bit to 1 in FLASH_CCR.
If STRBERRIE bit in FLASH_CR is set to 1, an interrupt is generated when STRBERR flag is raised (see Section 6.9 for details).
6.8.4 Inconsistency error (INCERR)
When a programming inconsistency is detected, the FLASH sets the inconsistency error flag INCERR in FLASH_SR.
More specifically, INCERR flag is set when the following condition is met:
- • A write operation is attempted before completion of the previous write operation, for example:
- – The application software starts a write operation to fill the 128-bit write buffer, but sends a new write burst request to a different flash memory address before the buffer is full.
Note: INCERR flag must be cleared before starting a new write operation, otherwise a sequence error (PGSERR) is raised.
It is recommended to follow the sequence below to avoid losing data when an inconsistency error occurs:
- 1. Execute a handler routine when INCERR flag is raised.
- 2. Stop all write requests to FLASH.
- 3. Clear INCERR bit.
- 4. Restart the write operations where they have been interrupted.
INCERR flag is cleared by setting CLR_INCERR bit to 1 in FLASH_CCR.
If INCERRIE bit in FLASH_CR register is set to 1, an interrupt is generated when INCERR flag is raised (see Section 6.9 for details).
6.8.5 Error correction code error (ECCC/ECCD)
When a single-error correction is detected during a read, the FLASH interface sets the single-error correction flag ECCC in FLASH_ECCCORR.
When two ECC errors are detected during a read, the FLASH interface sets the double error detection flag ECCD in FLASH_ECCDETR.
When ECCC flag is raised, the corrected read data are returned. Hence the application can ignore the error and request new read operations. When ECCD flag is raised a NMI is generated. The software must invalidate the instruction cache (CACHEINV = 1) in the NMI interrupt service routine when the ECCD flag is set. This NMI can be masked in SBS registers Section 12.5.12: SBS ECC NMI mask register (SBS_ECCNMIR) for data access (OTP, data area, RO data).
When ECCC or ECCD flag is raised, the address of the FLASH word that generated the error is saved in the FLASH_ECCCORR (FLASH_ECCDETR). If the address corresponds to a read-only area, to a EDATA page (in user mode or in FLASH data area mode) or to an OTP area, the OTP_ECC or SYSF_ECC or EDATA_ECC bit is also set to 1 in FLASH_ECCCORR (FLASHBS_ECCDETR). This register is automatically cleared when the associated flag that generated the error is reset.
A BK_ECC flag indicates in which FLASH bank the error occurred.
A SYSF_ECC flag indicates error detected in the system FLASH area.
Table 41. Locating ECC failure
| OTP_ECC | SYSF_ECC | BK_ECC | DATA_EC C | FLASH area | ADDR_ECC min | ADDR_ECC max |
|---|---|---|---|---|---|---|
| 0 | 0 | 0/1 | 0 | User FLASH | 0x0000 | 0x7FFF(1) |
| 0 | 1 | 0/1 | 0 | System FLASH | 0x0000 | 0x0FFF |
| 1 | 0 | 1 | 0 | OTP | 0x0200 | 0x037F |
| 0 | 0 | 0/1 | 1 | EDATA page 0 | 0x0000 | 0x007F |
| 0 | 0 | 0/1 | 1 | EDATA page 1 | 0x0080 | 0x00FF |
| 0 | 0 | 0/1 | 1 | EDATA page 2 | 0x0100 | 0x017F |
Table 41. Locating ECC failure (continued)
| OTP_ECC | SYSF_ECC | BK_ECC | DATA_EC C | FLASH area | ADDR_ECC min | ADDR_ECC max |
|---|---|---|---|---|---|---|
| 0 | 0 | 0/1 | 1 | EDATA page 3 | 0x0180 | 0x01FF |
| 0 | 0 | 0/1 | 1 | EDATA page 4 | 0x0200 | 0x027F |
| 0 | 0 | 0/1 | 1 | EDATA page 5 | 0x0280 | 0x02FF |
| 0 | 0 | 0/1 | 1 | EDATA page 6 | 0x0300 | 0x037F |
| 0 | 0 | 0/1 | 1 | EDATA page 7 | 0x0380 | 0x03FF |
| 0 | 0 | 0/1 | 1 | EDATA page 8 | 0x0400 | 0x047F |
| 0 | 0 | 0/1 | 1 | EDATA page 9 | 0x0480 | 0x04FF |
| 0 | 0 | 0/1 | 1 | EDATA page 10 | 0x0500 | 0x057F |
| 0 | 0 | 0/1 | 1 | EDATA page 11 | 0x0580 | 0x05FF |
| 0 | 0 | 0/1 | 1 | EDATA page 12 | 0x0600 | 0x067F |
| 0 | 0 | 0/1 | 1 | EDATA page 13 | 0x0680 | 0x06FF |
| 0 | 0 | 0/1 | 1 | EDATA page 14 | 0x0700 | 0x077F |
| 0 | 0 | 0/1 | 1 | EDATA page 15 | 0x0780 | 0x07FF |
1. ADDR_ECC maximum depends on the flash memory size of the product.
Note: In case of successive single correction or double detection errors, only the address corresponding to the first error is stored in FLASH_ECCCORR (FLASH_ECCDETR). It is mandatory to clear ECCC or ECCD flags before starting a new read operation. As the ECC interface is shared by the two banks, if the same error is registered simultaneously, a physical bank1 error is registered. Both errors are registered if one bank reports ECCD and the other bank ECCC. ADDR_ECC value indicates the FLASH line where the ECC error occurred. If the EDATA_EN option bit is set, the EDATA sectors are programmed and read as 16-bit accesses, (memory row being 137 bits long: 128-bit + 9-bit ECC). Consequently, the arrangement of the memory is modified. The first 32 bits of each row of a sector are filled first, then the bits from 32 to 63 and finally from 64 to 96 (the rest of the memory row contains ECC code). The ADDR_ECC indicates the memory line holding the failure. To identify the data corrupted on the line, DATA_ADDR_ECC bitfield value can be used to
discriminate which column holds the failed data (only in case of error relative to data area or OTP).
Example: ADDR_ECC = 0x0312 and DATA_ADDR_ECC = 0x3.
- • With ADDR_ECC between 0x0300 and 0x037F, the address of failure is in page 6, starting at 0x0900 2400.
- • DATA_ADDR_ECC = 0b01X indicates the concerned column is the second, starting from 0x0900 2600.
- • ADDR_ECC ending with 0xXX12 means the concerned row in memory is 0x12. With 4 bytes per column, this gives the 32-bit address as 0x0900 2648.
- • DATA_ADDR_ECC = 0b0X1 indicates the concerned final address is the second 16-bit data, so 0x0900 264A.
ECCC (respectively ECCD) flag is cleared by setting to 1 the ECCC bit (respectively ECCD bit) in FLASH_ECCCORR (FLASH_ECCDETR).
If ECCC bit in FLASH_ECCCORR is set to 1, an interrupt is generated when ECCC flag is raised. Only NMI is generated for the ECCD (see Section 6.9 for details).
6.8.6 Option-byte change error (OPTCHANGEERR)
When the FLASH finds an error during an option-byte change operation, it aborts the operation, and sets the option-byte change error flag OPTCHANGEERR in FLASH_SR.
The error is raised after OPTSTRT bit set if one of the following occurs:
- • Any forbidden RDP_LEVEL transition (Table 36).
- • SWAP_BANK is locked out by BOOT_LOCK.
- • Attempt to modify OB with invalid value not recognized by the specification (enumerated magic numbers only)
- • Attempt to modify OB in RDP level where it is not allowed (usually a state open for debug is required for change)
Note: Exceptions and details provided in the OB description (see Section 6.4.9).
OPTCHANGEERR flag is cleared by setting CLR_OPTCHANGEERR bit to 1 in FLASH_CCR.
If OPTCHANGEERRIE bit in FLASH_CR is set to 1, an interrupt is generated when OPTCHANGEERR flag is raised (see Section 6.9 for details).
It is mandatory to clean the OPTCHANGEERR flag before starting a new operation (option change, erase, or write).
6.8.7 Miscellaneous HardFault errors
The following events generate a bus error on the corresponding bus interface:
- • On main AHB system bus for access targeting code and data with 9-bit ECC.
- – Access to invalid address (including data addresses forbidden for code use)
- – Fetching from HDP area with incorrect HDPL value
- – Fetching from privilege area in unprivileged mode
- • On AHB configuration or system bus for accesses targeting OTP/RO (all addresses using 6-bits ECC):
- – Wrong key input to FLASH_KEYR or FLASH_OPTKEYR
- – 8-bit accesses to system AHB interface
- – Wrong unlock sequence on a register
6.9 FLASH interrupts
The FLASH can generate a maskable interrupt to signal the following events on a given bank:
- • Read and write errors (see Section 6.8)
- – Single ECC error correction during read operation
- – Write inconsistency error
- – Bad programming sequence
- – Strobe error during write operations
- – Option-byte change operation error
- • Security errors (see Section 6.8)
- – Write protection error
- • Miscellaneous events (described below)
- – End of programming
A NMI is raised on double-ECC-error detection during read operation.
The user can individually enable or disable FLASH interrupt sources by changing the mask bits in FLASH_CR, FLASH_ECCCORR, and FLASH_ECCDETR. Setting the appropriate mask bit to 1 enables the interrupt.
Note: Before writing, FLASH_CR must be unlocked as explained in Section 6.5.4.
The table below summarizes the available FLASH interrupt features. As mentioned, some flags need to be cleared before a new operation is triggered.
Table 42. FLASH interrupt request
| Interrupt event flag | Error flag label in register | Enable control bit | Clear flag to resume operation |
|---|---|---|---|
| End of operation event | EOP | EOPIE | N/A |
| Write protection error | WRPERR | WRPERRIE | Yes |
| Programming sequence error | PGSERR | PGSERRIE | Yes |
| Strobe error | STRBERR | STRBERRIE | Yes |
Table 42. FLASH interrupt request (continued)
| Interrupt event flag | Error flag label in register | Enable control bit | Clear flag to resume operation |
|---|---|---|---|
| Inconsistency error | INCERR | INCERRIE | Yes |
| Option byte error | OPTCHANGEERR | - | Yes |
| ECC single error correction event | ECCC | ECCCIE | No |
| ECC double error detection event(1) | ECCD | Disabled | No |
1. NMI.
The status of the individual maskable interrupt sources described in Table 42 (except for option-byte error and ECC) can be read in FLASH_SR register. They can be cleared by setting to 1 the adequate bit in FLASH_CCR.
Note: No unlocking mechanism is required to clear an interrupt.
End of operation event
Setting the end of operation interrupt enable bit (EOPIE) in FLASH_CR enables the generation of an interrupt at the end of an erase operation, a program operation, or an option-byte change.
Setting CLR_EOP bit to 1 in FLASH_CCR clears EOP flag.
6.10 FLASH registers
Each register is assigned a offset address and a reset value. In case of registers representing option-byte value, the reset value is determined by the OBL process. In case of success, the reset value is loaded from OB. In case of OBL failure, a highly restrictive default value is set.
6.10.1 FLASH access control register (FLASH_ACR)
Address offset: 0x000
Reset value: 0x000X 0027
Bit 16 not reset by system reset
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR. For more details, refer to Section 6.3.4 and Section 6.3.5.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | EMPTY |
| rw | |||||||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | PRFTEN | Res. | Res. | WRHIGHFREQ[1:0] | LATENCY[3:0] | ||||
| rw | rw | rw | rw | rw | rw | rw | |||||||||
Bits 31:17 Reserved, must be kept at reset value.
Bit 16 EMPTY: Main flash memory area empty (not reset by system reset)
Set and reset by software. This bit indicates whether the boot location of the main flash memory area (indicated by BOOT_ADD) is erased or has a programmed value.
0: Boot address in main flash memory area programmed
1: Boot address in main flash memory area empty
Bits 15:9 Reserved, must be kept at reset value.
Bit 8 PRFTEN: Prefetch enable
When this bit value is modified, the user must read back this register to be sure PRFTEN has been taken into account. This bit is used to control the prefetch.
0: Prefetch disabled
1: Prefetch enabled when latency is at least 1 wait-state
Bits 7:6 Reserved, must be kept at reset value.
Bits 5:4 WRHIGHFREQ[1:0]: FLASH signal delay
These bits are used to control the delay between nonvolatile memory signals during programming operations. The application software has to program them to the correct value depending on the FLASH frequency. Refer to Table 20 for details.
Note: No check is performed to verify that the configuration is correct.
Two WRHIGHFREQ values can be selected for some frequencies.
Bits 3:0 LATENCY[3:0]: Read latency
These bits are used to control the number of wait states used during read operations on both nonvolatile memory banks. The application software has to program them to the correct value depending on the FLASH frequency and voltage conditions.
0000: 0 wait state
0001: 1 wait state
0010: 2 wait states
0011-1111: {v} wait states
Note: No check is performed by hardware to verify that the configuration is correct.
6.10.2 FLASH key register (FLASH_KEYR)
Address offset: 0x004
Reset value: 0x0000 0000
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR. This register is write-only.
The following values must be programmed consecutively to unlock FLASH_CR and to allow programming/erasing it. A wrong sequence locks FLASH_CR until next system reset.
1st key = 0x4567 0123
2nd key = 0xCDEF 89AB
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| KEY[31:16] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| KEY[15:0] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 KEY[31:0]: Nonvolatile memory configuration access unlock key
6.10.3 FLASH option key register (FLASH_OPTKEYR)
Address offset: 0x00C
Reset value: 0x0000 0000
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR. This register is write-only.
The following values must be programmed consecutively to unlock FLASH_OPTCR. A wrong sequence locks FLASH_OPTCR until next system reset.
1st key = 0x0819 2A3B
2nd key = 0x4C5D 6E7F
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| OPTKEY[31:16] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| OPTKEY[15:0] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 OPTKEY[31:0]: FLASH option-byte control access unlock key
6.10.4 FLASH operation status register (FLASH_OPSR)
Address offset: 0x018
Reset value: 0xXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| CODE_OP[2:0] | Res. | Res. | Res. | Res. | OTP_OP | Res. | BK_OP | DATA_OP | Res. | Res. | Res. | Res. | Res. | ||
| r | r | r | r | r | r | ||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| ADDR_OP[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:29 CODE_OP[2:0]: Flash memory operation code
- 000: No FLASH operation ongoing during previous reset
- 001: Single write operation interrupted
- 010: Reserved
- 011: Page erase operation interrupted
- 100: Bank erase operation interrupted
- 101: Mass erase operation interrupted
- 110: Option change operation interrupted
- 111: Reserved
Bits 28:25 Reserved, must be kept at reset value.
Bit 24 OTP_OP: OTP operation interrupted
This bit indicates that a reset interrupted an ongoing operation in the OTP area.
Bit 23 Reserved, must be kept at reset value.
Bit 22 BK_OP: Interrupted operation bank
This bit indicates which bank was concerned by operation. (Refer to Section Table 24.: Memory map and the swapping option (STM32C53x/542 devices))
Bit 21 DATA_OP: FLASH data area operation interrupted
This bit indicates if user data FLASH area is concerned by an operation.
Bits 20:16 Reserved, must be kept at reset value.
Bits 15:0 ADDR_OP[15:0]: Interrupted operation address
6.10.5 FLASH option control register (FLASH_OPTCR)
Address offset: 0x01C
Reset value: 0xX000 0001
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
Access: No wait state when no flash memory operation is ongoing.
This register is not accessible in write mode when the BSY bit is set. Any attempt to write to it while the BSY bit set causes the AHB bus to stall until the BSY bit is cleared.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| SWAP_BANK | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| r | |||||||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | OPTSTRT | OPTLOCK |
| rw | rs |
Bit 31 SWAP_BANK: Bank-swapping option configuration bit
SWAP_BANK controls whether bank1 and bank2 are swapped or not. This bit is loaded with the SWAP_BANK bit of FLASH_OPTSR_CUR register only after reset or POR.
0: Bank1 and bank2 not swapped
1: Bank1 and bank2 swapped
Bits 30:2 Reserved, must be kept at reset value.
Bit 1 OPTSTRT: Option-byte start change option configuration bit
OPTSTRT triggers an option byte change operation. The user can set OPTSTRT only when the OPTLOCK bit is cleared to 0. It is set only by software and cleared when the option-byte change is completed or an error occurs (PGSERR or OPTCHANGEERR). It is reset at the same time as BSY bit.
The user application cannot modify any FLASH_XXX_PRG register until the option change operation has been completed.
Before setting this bit, the user has to write the required values in FLASH_XXX_PRG.
FLASH_XXX_PRG registers are locked until the option-byte change operation has been executed in nonvolatile memory.
Bit 0 OPTLOCK: FLASH_OPTCR lock option configuration bit
The OPTLOCK bit locks the FLASH_OPTCR register as well as all _PRG registers. The correct write sequence to FLASH_OPTKEYR register unlocks this bit. If a wrong sequence is executed, or the unlock sequence to FLASH_OPTKEYR is performed twice, this bit remains locked until next system reset.
It is possible to set OPTLOCK by programming it to 1. When set to 1, a new unlock sequence is mandatory to unlock it. When OPTLOCK changes from 0 to 1, the others bits of FLASH_OPTCR register do not change.
0: FLASH_OPTCR register unlocked
1: FLASH_OPTCR register locked.
6.10.6 FLASH status register (FLASH_SR)
Address offset: 0x020
Reset value: 0x0000 000X
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | OPTCH ANGEER RR | Res. | Res. | INCER R | STRBE RR | PGSER R | WRPE RR | EOP |
| r | r | r | r | r | r | ||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | BSLOC K | OEML OCK | Res. | Res. | Res. | Res. | DBNE | Res. | WBNE | BSY |
| r | r | r | r | r |
Bits 31:24 Reserved, must be kept at reset value.
Bit 23 OPTCHANGEERR: Option-byte change error flag
This flag indicates that an error occurred during an option-byte change operation. When This bit is set to 1, the option-byte change operation did not successfully complete. An interrupt is generated when this flag is raised if OPTCHANGEERRIE in FLASH_NSCR is set to 1.
Writing 1 to CLR_OPTCHANGEERR in FLASH_CCR clears OPTCHANGEERR.
0: No option-byte change errors occurred.
1: One or more errors occurred during an option-byte change operation.
Note: OPTSTRT in FLASH_OPTCR cannot be set while OPTCHANGEERR is set.
Bits 22:21 Reserved, must be kept at reset value.
Bit 20 INCERR: Inconsistency error flag
This flag is raised when an inconsistency error occurs. An interrupt is generated if INCERRIE is set to 1. Writing 1 to CLR_INCERR in FLASH_CCR clears INCERR.
0: No inconsistency error occurred.
1: An inconsistency error occurred.
Bit 19 STRBERR: Strobe error flag
This flag is raised when a strobe error occurs (when the master attempts to write several times the same byte in the write buffer). An interrupt is generated if STRBERRIE is set to 1.
Writing 1 to CLR_STRBERR in FLASH_CCR clears STRBERR.
0: No strobe error occurred.
1: A strobe error occurred.
Bit 18 PGSERR: Programming sequence error flag
This flag is raised when a sequence error occurs. An interrupt is generated if the PGSERRIE bit is set to 1. Writing 1 to CLR_PGSERR in FLASH_CCR clears PGSERR.
0: No sequence error occurred.
1: A sequence error occurred.
Bit 17 WRPERR: Write protection error flag
This flag is raised when a protection error occurs during a program operation. An interrupt is also generated if the WRPERRIE is set to 1. Writing 1 to CLR_WRPERR bit in FLASH_CCR clears WRPERR.
0: No write-protection error occurred.
1: A write-protection error occurred.
Bit 16 EOP: End of operation flag
This flag is set when an operation (program/erase) completes. An interrupt is generated if EOPIE is set to 1. It is not necessary to reset EOP before starting a new operation. EOP bit is cleared by writing 1 to CLR_EOP in FLASH_CCR.
- 0: No operation completed.
- 1: An operation completed.
Bits 15:10 Reserved, must be kept at reset value.
Bit 9 BSLOCK: BS lock
This bit indicates that the BS key read during the option byte loading is not default (default is 0xAAAA AAAA).
When set, the BS personalized key mechanism to transition to L2 from L2_wBS is active.
Bit 8 OEMLOCK: OEM lock
This bit indicates that the OEM key read during the OBL is not virgin. When set, the OEM RDP lock mechanism is active. The lock mechanism allows the user to regress from RDP L2_wBS or L2 to L0. This bit is set once a 128-bit password is written in OEMKEYRx registers and written in memory. It cannot be cleared.
- 0: Lock mechanism is not active, progressing to RDP L2_wBS or L2 is irrevocable.
- 1: Lock mechanism is active, a key exist to regress to RDP L0.
Bits 7:4 Reserved, must be kept at reset value.
Bit 3 DBNE: Data buffer not empty flag
This flag is set when the FLASH is processing 6-bit ECC data (OTP or EDATA area when EDATA_EN option bit set) in a dedicated buffer. This bit cannot be cleared by software. The hardware resets it once the buffer is free.
- 0: Data buffer not used
- 1: Data buffer used, wait
Bit 2 Reserved, must be kept at reset value.
Bit 1 WBNE: Write buffer not empty flag
This flag is set when the FLASH is waiting for new data to complete the write buffer. In this state, the write buffer is not empty. WBNE is reset by hardware each time the write buffer is complete or the write buffer is emptied following one of the event below:
- - The application software forces the write operation using FW bit in FLASH_CR.
- - The FLASH detects an error that involves data loss.
This bit cannot be reset by software writing 0 directly. To reset it, clear the write buffer by performing any of the above listed actions, or send the missing data.
- 0: Write buffer empty or full
- 1: Write buffer waiting data to complete
Bit 0 BSY: Busy flag
This flag indicates that a flash memory is busy by an operation (write, erase, option-byte change). It is set at the beginning of a flash memory operation, and cleared when the operation finishes or an error occurs.
- 0: No programming, erase, or option-byte change operation being executed
- 1: Programming, erase, or option byte change operation being executed
6.10.7 FLASH control register (FLASH_CR)
Address offset: 0x028
Reset value: 0x0000 0001
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
Access: No wait state when no flash memory operation is ongoing.
This register is not accessible in write mode when the BSY bit is set. Any attempt to write to it with the BSY bit set causes the AHB bus to stall until the BSY bit is cleared.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| BKSEL | Res. | EDATASEL | Res. | Res. | Res. | Res. | Res. | OPTCHANGEERRIE | Res. | Res. | INCERRIE | STRBEERRIE | PGSERRIE | WRPEERRIE | EOPIE |
| rw | rw | rw | rw | rw | rw | rw | rw | ||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| MER | Res. | Res. | PNB[6:0] | STRT | FW | BER | PER | PG | LOCK | ||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rs | rw | rw | rw | rw | rs | ||
Bit 31 BKSEL: Bank selector bit
This bit can only be programmed when LOCK is cleared to 0. This bit selects physical bank, SWAP_BANK setting is ignored.
0: Bank1 is selected for bank erase (BER)/page erase (PER)/interrupt enable.
1: Bank2 is selected for BER/PER.
Bit 30 Reserved, must be kept at reset value.
Bit 29 EDATASEL: EDATA erase selector bit
This bit can only be programmed when LOCK is cleared to 0. This bit selects if page erased concern EDATA page or User main flash pages. This bit has no effect if PER bit is reset.
0: Main FLASH page erase
1: FLASH data area EDATA page erase
Note: During a bank erase, the user and the EDATA sectors are always erased, regardless of this bit setting.
Bits 28:24 Reserved, must be kept at reset value.
Bit 23 OPTCHANGEERRIE: Option-byte change error interrupt enable bit
This bit controls if an interrupt has to be generated when an error occurs during an option-byte change. This bit can be programmed only when LOCK bit is cleared to 0.
0: No interrupt is generated when an error occurs during an option-byte change.
1: An interrupt is generated when and error occurs during an option-byte change.
Bits 22:21 Reserved, must be kept at reset value.
Bit 20 INCERRIE: Inconsistency error interrupt enable bit
When INCERRIE bit is set to 1, an interrupt is generated when an inconsistency error occurs during a write operation. INCERRIE can be programmed only when LOCK is cleared to 0.
0: No interrupt generated when a inconsistency error occurs.
1: Interrupt generated when a inconsistency error occurs.
- Bit 19 STRBERRIE: Strobe error interrupt enable bit
When this bit is set to 1, an interrupt is generated when a strobe error occurs (the master programs several times the same byte in the write buffer) during a write operation. STRBERRIE can be programmed only when LOCK is cleared to 0.
0: No interrupt generated when a strobe error occurs.
1: Interrupt generated when strobe error occurs. - Bit 18 PGSERRIE: Programming sequence error interrupt enable bit
When this bit is set to 1, an interrupt is generated when a sequence error occurs during a program operation. PGSERRIE can be programmed only when LOCK is cleared to 0.
0: No interrupt generated when a sequence error occurs.
1: Interrupt generated when sequence error occurs. - Bit 17 WRPERRIE: Write protection error interrupt enable bit
When this bit is set to 1, an interrupt is generated when a protection error occurs during a program operation. WRPERRIE can be programmed only when LOCK is cleared to 0.
0: No interrupt generated when a protection error occurs.
1: Interrupt generated when a protection error occurs. - Bit 16 EOPIE: End of operation interrupt control bit
Setting this bit to 1 enables the generation of an interrupt at the end of a program or erase operation. EOPIE can be programmed only when LOCK is cleared to 0.
0: No interrupt generated at the end of operation.
1: Interrupt enabled when at the end of operation. - Bit 15 MER: Mass erase request
Setting this bit to 1 requests a mass erase operation (user flash memory only). MER can be programmed only when LOCK is cleared to 0. If BER or PER are both set, a PGSERR is raised.
0: Mass erase not requested
1: Mass erase requested
Note: An error is triggered when a mass erase is required and some pages are protected. - Bits 14:13 Reserved, must be kept at reset value.
- Bits 12:6 PNB[6:0]: Page erase selection number
These bits are used to select the target page for an erase operation (they are unused otherwise). PNB can be programmed only when LOCK is cleared to 0.
0x00: Page 0 selected
0x01: Page 1 selected
0x02-0x3F: Page {v} selected
Note: Values corresponding to addresses outside the main memory are not allowed. Refer to Table 24: Memory map and the swapping option (STM32C53x/542 devices), Table 25: Memory map and the swapping option (STM32C55x/562 devices), and Table 26: Memory map and the swapping option (STM32C59x/5A3 devices) - Bit 5 STRT: Erase start control bit
This bit is used to start a page erase or a bank erase operation. STRT can be programmed only when LOCK is cleared to 0.
This bit is reset at the end of the operation or when an error occurs. It cannot be reseted by software.
Bit 4 FW: Write forcing control bit
This bit forces a write operation even if the write buffer is not full. In this case, all bits not written are set to 1 by hardware. FW can be programmed only when LOCK is cleared to 0. The FLASH resets this bit when the corresponding operation has been acknowledged.
Note: Using a force-write operation prevents the application from updating later the missing bits with something else than 1, because it is likely that it leads to permanent ECC error.
Write forcing is effective only if the write buffer is not empty (in particular, FW does not start several write operations when the force-write operations are performed consecutively).
Since there is just one write buffer, FW can force a write in bank1 or bank2.
Bit 3 BER: Bank-erase request
Setting this bit to 1 requests a bank erase operation (user flash memory only). BER can be programmed only when LOCK is cleared to 0. If MER and PER are also set, a PGSERR is raised.
0: Bank erase not requested
1: Bank erase requested
Note: Write protection error is triggered when a bank erase is required and some pages are protected.
Bit 2 PER: Page-erase request
Setting this bit to 1 requests a sector erase. PER can be programmed only when LOCK is cleared to 0. If MER and PER are also set, a PGSERR is raised.
0: Page erase not requested
1: Page erase requested
Bit 1 PG: Programming control bit
This bit can be programmed only when LOCK is cleared to 0. It allows programming in bank1 and bank2.
0: Programming disabled
1: Programming enabled
Bit 0 LOCK: Configuration lock bit
This bit locks FLASH_CR. The correct write sequence to FLASH_KEYR unlocks this bit. If a wrong sequence is executed, or if the unlock sequence to FLASH_KEYR is performed twice, this bit remains locked until the next system reset.
LOCK can be set by programming it to 1. When set to 1, a new unlock sequence is mandatory to unlock it. When LOCK changes from 0 to 1, the other bits of FLASH_CR register do not change.
0: FLASH_CR unlocked
1: FLASH_CR locked
6.10.8 FLASH clear control register (FLASH_CCR)
Address offset: 0x030
Reset value: 0x0000 0000
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | CLR_OPTCHANGEERR | Res. | Res. | CLR_INCERR | CLR_STRBERR | CLR_PGSERR | CLR_WRPERR | CLR_EOP |
| w | w | w | w | w | w | ||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
Bits 31:24 Reserved, must be kept at reset value.
Bit 23 CLR_OPTCHANGEERR: OPTCHANGEERR clear bit
Setting this bit to 1 clears the corresponding flag in FLASH_SR.
Bits 22:21 Reserved, must be kept at reset value.
Bit 20 CLR_INCERR: INCERR flag clear bit
Setting this bit to 1 resets to 0 INCERR flag in FLASH_SR.
Bit 19 CLR_STRBERR: STRBERR flag clear bit
Setting this bit to 1 resets to 0 STRBERR flag in FLASH_SR.
Bit 18 CLR_PGSERR: PGSERR flag clear bit
Setting this bit to 1 resets to 0 PGSERR flag in FLASH_SR.
Bit 17 CLR_WRPERR: WRPERR flag clear bit
Setting this bit to 1 resets to 0 WRPERR flag in FLASH_SR.
Bit 16 CLR_EOP: EOP flag clear bit
Setting this bit to 1 resets to 0 EOP flag in FLASH_SR.
Bits 15:0 Reserved, must be kept at reset value.
6.10.9 FLASH privilege configuration register (FLASH_PRIVCFGR)
Address offset: 0x03C
Reset value: 0x0000 0000
This register can be read by both privileged and unprivileged access. It can only be written by privileged mode.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | PRIV | Res. |
| rw |
Bits 31:2 Reserved, must be kept at reset value.
Bit 1 PRIV: Privilege attribute
0: Access to registers is always granted.
1: Access to registers is denied in case of unprivileged access.
Bit 0 Reserved, must be kept at reset value.
6.10.10 FLASH HDP extension register (FLASH_HDPEXTR)
Address offset: 0x048
Reset value: 0x0000 0000
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR. The register can only be modified in HDPL ≤ 2.
The values in this register cannot be decremented. Attempt to write a lower value that current is ignored.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_EXT[5:0] | |||||
| rw | rw | rw | rw | rw | rw | ||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_EXT[5:0] | |||||
| rw | rw | rw | rw | rw | rw | ||||||||||
Bits 31:22 Reserved, must be kept at reset value.
Bits 21:16 HDP2_EXT[5:0]: HDP area extension in 8-Kbyte pages in bank2
Extension is added after the HDP2_END page (included).
Bits 15:6 Reserved, must be kept at reset value.
Bits 5:0 HDP1_EXT[5:0]: HDP area extension in 8-Kbyte pages in bank1
Extension is added after the HDP1_END page (included).
6.10.11 FLASH option status register (FLASH_OPTSR_CUR)
Address offset: 0x050
Reset value: 0xXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
Default value: 0x20B0 72D8 (value in case of double ECC issue during OBL).
ST production value: refer to Table 28: Option-byte organization
This read-only register reflects the current values of corresponding option bits.
(Register bits 0 to 31 are loaded with values from the flash memory at OBL)
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| SWAP_BANK | SINGLE_BANK | EDATA_EN | Res. | Res. | Res. | Res. | Res. | BOOT0 | BOOT_SEL | IWDG_STDBY | IWDG_STOP | Res. | Res. | Res. | Res. |
| r | r | r | r | r | r | r | |||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| RDP_LEVEL[7:0] | NRST_STDBY | NRST_STOP | Res. | WWDG_SW | IWDG_SW | Res. | Res. | Res. | |||||||
| r | r | r | r | r | r | r | r | r | r | r | r | ||||
Bit 31 SWAP_BANK: Bank-swapping option status bit
SWAP_BANK reflects whether bank1 and bank2 are swapped or not.
SWAP_BANK is loaded to SWAP_BANK in FLASH_OPTCR after a reset.
0: Bank1 and bank2 not swapped
1: Bank1 and bank2 swapped
Bit 30 SINGLE_BANK: Dual-bank selection option status bit
For products:
- STM32C53x/542 with 128-Kbyte user memory
- STM32C55x/562 with 256-Kbyte user memory
- STM32C59x/5A3 with 512-Kbyte user memory
SINGLE_BANK reflects single or dual-bank memory selection.
0: User flash is split between bank 1 and bank 2
1: User flash is located in one bank
Note: This bit has no impact on EDATA sectors.
Bit 29 EDATA_EN: FLASH data area enable
0: No FLASH data area (EDATA pages are 128-bit writable)
1: FLASH data area is enabled (EDATA pages are 16/32-bit writable)
Bits 28:24 Reserved, must be kept at reset value.
Bit 23 BOOT0: Boot 0 option bit
0: BOOT0 = 0
1: BOOT0 = 1
Bit 22 BOOT_SEL: Boot 0 source selection
0: BOOT0 signal is defined by the BOOT0 option bit.
1: BOOT0 signal is defined by BOOT0 pin value (legacy mode).
- Bit 21 IWDG_STDBY: IWDG Standby mode freeze option status bit
When this bit is set, the IWDG is frozen in system Standby mode.
0: IWDG frozen in Standby mode
1: IWDG keeps running in Standby mode. - Bit 20 IWDG_STOP: IWDG Stop mode freeze option status bit
When set the independent watchdog IWDG is in system Stop mode.
0: IWDG frozen in system Stop mode
1: IWDG keeps running in system Stop mode. - Bits 19:16 Reserved, must be kept at reset value.
- Bits 15:8 RDP_LEVEL[7:0]: RDP level code (based on Hamming 8,4)
See Section 6.5.8. - Bit 7 NRST_STDBY: Core domain Standby entry reset option status bit
0: A reset is generated when entering Standby mode on core domain.
1: No reset generated when entering Standby mode on core domain. - Bit 6 NRST_STOP: Core domain Stop entry reset option status bit
0: A reset is generated when entering Stop mode on core domain.
1: No reset generated when entering Stop mode on core domain.. - Bit 5 Reserved, must be kept at reset value.
- Bit 4 WWDG_SW: WWDG control mode option status bit
0: WWDG controlled by hardware
1: WWDG controlled by software - Bit 3 IWDG_SW: IWDG control mode option status bit
0: IWDG controlled by hardware
1: IWDG controlled by software - Bits 2:0 Reserved, must be kept at reset value.
6.10.12 FLASH option status register (FLASH_OPTSR_PRG)
Address offset: 0x054
Reset value: 0XXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
This register is used to program values in corresponding option bits. Values after reset reflects the current values of the corresponding option bits.
(Register bits 0 to 31 are loaded with values from the flash memory at OBL)
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| SWAP_BANK | SINGLE_BANK | EDATA_EN | Res. | Res. | Res. | Res. | Res. | BOOT0 | BOOT_SEL | IWDG_STDBY | IWDG_STOP | Res. | Res. | Res. | Res. |
| rw | rw | rw | rw | rw | rw | rw | |||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| RDP_LEVEL[7:0] | NRST_STDBY | NRST_STOP | Res. | WWDG_SW | IWDG_SW | Res. | Res. | Res. | |||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | ||||

- Bit 31 SWAP_BANK: Bank-swapping option configuration bit
This bit is used to configure whether the bank1 and bank2 are swapped or not. This bit is loaded with SWAP_BANK in FLASH_OPTSR_CUR after a reset.
0: Bank1 and bank2 not swapped
1: Bank1 and bank2 swapped - Bit 30 SINGLE_BANK: Dual-bank option configuration bit
For products:
- STM32C53x/542 with 128-Kbyte user memory
- STM32C55x/562 with 256-Kbyte user memory
- STM32C59x/5A3 with 512-Kbyte user memory
This bit configures memory as single or dual bank. This bit is loaded with SINGLE_BANK in FLASH_OPTSR_CUR after a reset.
0: User flash is split between bank 1 and bank 2
1: User flash is located in one bank - Bit 29 EDATA_EN: FLASH data area enable
0: No FLASH data area
1: FLASH data area enabled - Bits 28:24 Reserved, must be kept at reset value.
- Bit 23 BOOT0: Boot 0 option bit
0: BOOT0 = 0
1: BOOT0 = 1 - Bit 22 BOOT_SEL: Boot 0 source configuration
0: BOOT0 signal is defined by the BOOT0 option bit.
1: BOOT0 signal is defined by BOOT0 pin value (legacy mode). - Bit 21 IWDG_STDBY: IWDG Standby mode freeze option configuration bit
When this bit is set, the IWDG is frozen in system Standby mode.
0: IWDG frozen in Standby mode
1: IWDG keeps running in Standby mode. - Bit 20 IWDG_STOP: IWDG Stop mode freeze option configuration bit
When this bit is set, the IWDG is frozen in system Stop mode.
0: IWDG frozen in system Stop mode
1: IWDG keeps running in system Stop mode. - Bits 19:16 Reserved, must be kept at reset value.
- Bits 15:8 RDP_LEVEL[7:0]: RDP level code (based on Hamming 8,4)
See Section 6.5.8. - Bit 7 NRST_STDBY: Core domain Standby entry reset option configuration bit
0: A reset is generated when entering Standby mode on core domain.
1: No reset generated when entering Standby mode on core domain. - Bit 6 NRST_STOP: Core domain Stop entry reset option configuration bit
0: A reset is generated when entering Stop mode on core domain.
1: No reset generated when entering Stop mode on core domain. - Bit 5 Reserved, must be kept at reset value.
Bit 4 WWDG_SW: WWDG control mode option configuration bit
- 0: WWDG controlled by hardware
- 1: WWDG controlled by software
Bit 3 IWDG_SW: IWDG control mode option configuration bit
- 0: IWDG controlled by hardware
- 1: IWDG controlled by software
Bits 2:0 Reserved, must be kept at reset value.
6.10.13 FLASH option status register 2 (FLASH_OPTSR2_CUR)
Address offset: 0x070
Reset value: 0XXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
Default value: 0x0000 0010 (value in case of double ECC issue during OBL).
ST production value: refer to Table 28: Option-byte organization
This read-only register reflects the current values of corresponding option bits.
(Register bits 0 to 31 are loaded with values from the flash memory at OBL)
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | SRAM2_ECC | Res. | Res. | SRAM2_RST | SRAM1_RST |
| r | r | r |
Bits 31:5 Reserved, must be kept at reset value.
Bit 4 SRAM2_ECC: SRAM2 ECC detection and correction disable
- 0: SRAM2 ECC check enabled
- 1: SRAM2 ECC check disabled
Bits 3:2 Reserved, must be kept at reset value.
Bit 1 SRAM2_RST: SRAM2 erase when system reset
- 0: SRAM2 erased when a system reset occurs
- 1: SRAM2 not erased when a system reset occurs
Bit 0 SRAM1_RST: SRAM1 erase upon system reset
- 0: SRAM1 erased when a system reset occurs
- 1: SRAM1 not erased when a system reset occurs
6.10.14 FLASH option status register 2 (FLASH_OPTSR2_PRG)
Address offset: 0x074
Reset value: 0xXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
This register is used to program values in corresponding option bits. Values after reset reflects the current values of the corresponding option bits.
(Register bits 0 to 31 are loaded with values from the flash memory at OBL)
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | SRAM2_ECC | Res. | Res. | SRAM2_RST | SRAM1_RST |
| rw | rw | rw |
Bits 31:5 Reserved, must be kept at reset value.
Bit 4 SRAM2_ECC: SRAM2 ECC detection and correction disable
0: SRAM2 ECC check enabled
1: SRAM2 ECC check disabled
Bits 3:2 Reserved, must be kept at reset value.
Bit 1 SRAM2_RST: SRAM2 erase when system reset
0: SRAM2 erased when a system reset occurs
1: SRAM2 not erased when a system reset occurs.
Note: SRAM erase is triggered by option-byte change operation, when enabling this feature.
Bit 0 SRAM1_RST: SRAM1 erase upon system reset
0: SRAM1 erased when a system reset occurs
1: SRAM1 not erased when a system reset occurs
Note: SRAM erase is triggered by option-byte change operation, when enabling this feature.
6.10.15 FLASH unique boot entry register (FLASH_BOOTR_CUR)
Address offset: 0x080
Reset value: 0XXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
Default value: 0xFFFF FFB4 (value in case of double ECC issue during OBL).
ST production value: refer to Table 28: Option-byte organization
This register reflects the current values of corresponding option bits.
(Register bits 0 to 31 are loaded with values from the flash memory at OBL)
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| BOOTADD[23:8] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| BOOTADD[7:0] | BOOT_LOCK[7:0] | ||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:8 BOOTADD[23:0]: Unique boot-entry address
These bits reflect the user memory boot address.
Caution: The BOOTADD must be a valid address within user main flash area. Otherwise, the boot stalls, and the flash memory becomes unreadable.
Note: The SRAM or EDATA areas cannot be selected as BOOTADD.
Bits 7:0 BOOT_LOCK[7:0]: BOOT0, BOOT_SEL, SWAP_BANK, and BOOTADD option settings lock
0xC3: BOOT0, BOOT_SEL, SWAP_BANK, and BOOTADD can still be modified following their individual rules.
0xB4: BOOT0, BOOT_SEL, SWAP_BANK, and BOOTADD are frozen.
6.10.16 FLASH unique boot entry address (FLASH_BOOTR_PRG)
Address offset: 0x084
Reset value: 0XXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
This register is used to program values in corresponding option bits.
(Register bits 0 to 31 are loaded with values from the flash memory at OBL)
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| BOOTADD[23:8] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| BOOTADD[7:0] | BOOT_LOCK[7:0] | ||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bits 31:8 BOOTADD[23:0]: Unique boot entry address
These bits reflect the user memory boot address.
Bits 7:0 BOOT_LOCK[7:0]: BOOT0, BOOT_SEL, SWAP_BANK, and BOOTADD option settings lock
0xC3: BOOT0, BOOT_SEL, SWAP_BANK, and BOOTADD can still be modified following their individual rules.
0xB4: BOOT0, BOOT_SEL, SWAP_BANK, and BOOTADD are frozen.
6.10.17 FLASH OTP block lock (FLASH_OTPBLR_CUR)
Address offset: 0x090
Reset value: 0x00XX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
Default value: 0xFFFF FFFF (value in case of double ECC issue during OBL).
ST production value: refer to Table 28: Option-byte organization
This register reflects the current values of corresponding option bits.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | LOCKBL[23:16] | |||||||
| r | r | r | r | r | r | r | r | ||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| LOCKBL[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:24 Reserved, must be kept at reset value.
Bits 23:0 LOCKBL[23:0]: OTP block lock
Block n corresponds to OTP 16-bit word 96 × n to 96 × n+95.
LOCKBL[n] = 1 indicates that all OTP 16-bit words in OTP block n are locked and attempt to program them results in WRPERR.
LOCKBL[n] = 0 indicates that all OTP 16-bit words in OTP block n are not locked.
When one block is locked, it is not possible to remove the write protection.
Also if not locked, it is not possible to erase OTP words.
6.10.18 FLASH OTP block lock (FLASH_OTPBLR_PRG)
Address offset: 0x094
Reset value: 0x00XX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
This register is used to program values in corresponding option bits.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | LOCKBL[23:16] | |||||||
| rs | rs | rs | rs | rs | rs | rs | rs | ||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| LOCKBL[15:0] | |||||||||||||||
| rs | rs | rs | rs | rs | rs | rs | rs | rs | rs | rs | rs | rs | rs | rs | rs |
Bits 31:24 Reserved, must be kept at reset value.
Bits 23:0 LOCKBL[23:0]: OTP block lock
Block n corresponds to OTP 16-bit word 96 × n to 96 × n+95.
LOCKBL[n] = 1 indicates that all OTP 16-bit words in OTP block n are locked and attempt to program them results in WRPERR.
LOCKBL[n] = 0 indicates that all OTP 16-bit words in OTP block n are not locked.
When one block is locked, it is not possible to remove the write protection.
LOCKBL bits can be set if the corresponding bit in FLASH_OTPBLR_CUR is cleared.
6.10.19 FLASH bootloader interface selection (FLASH_BL_COM_CFG_CUR)
Address offset: 0x098
Reset value: 0XXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
Default value: 0xFFFF FFFF (value in case of double ECC issue during OBL).
ST production value: refer to Table 28: Option-byte organization
This register reflects the current values of corresponding option bits.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| BL_COM_CFG[31:16] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| BL_COM_CFG[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:0 BL_COM_CFG[31:0]: Bootloader interface selection/configuration
This register is used to configure the set of interfaces on which the ST bootloader is active.
BL_COM_CFG[n] = 1 indicates that the corresponding interface is used by the bootloader.
BL_COM_CFG[n] = 0 indicates that the corresponding interface is not used by the bootloader. The GPIO remains in default state.
Note: For assignment of interfaces to register bits, see the bootloader documentation.
6.10.20 FLASH bootloader interface selection (FLASH_BL_COM_CFG_PRG)
Address offset: 0x09C
Reset value: 0xXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
This register is used to program values in the corresponding option bits.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| BL_COM_CFG[31:16] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| BL_COM_CFG[15:0] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bits 31:0 BL_COM_CFG[31:0]: Bootloader interface selection/configuration
This register is used to configure the set of interfaces on which the ST bootloader is active.
BL_COM_CFG[n] = 1 indicates that the corresponding interface is used by the bootloader.
BL_COM_CFG[n] = 0 indicates that the corresponding interface is not used by the bootloader. The GPIO remains in default state.
Note: For assignment of interfaces to register bits see the bootloader documentation.
6.10.21 FLASH OEM key register 1 (FLASH_OEMKEYR1_PRG)
Address offset: 0xA4
Reset value: 0xXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR. This register is read as zero.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| OEMKEY[31:16] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| OEMKEY[15:0] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 OEMKEY[31:0]: Least significant bytes of OEMKEY
6.10.22 FLASH OEM key register 2 (FLASH_OEMKEYR2_PRG)
Address offset: 0xAC
Reset value: 0XXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR. This register is read as zero.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| OEMKEY[63:48] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| OEMKEY[47:32] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 OEMKEY[63:32]: Mid-least significants bytes of OEMKEY
6.10.23 FLASH OEM key register 3 (FLASH_OEMKEYR3_PRG)
Address offset: 0xB4
Reset value: 0XXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR. This register is read as zero.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| OEMKEY[95:80] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| OEMKEY[79:64] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 OEMKEY[95:64]: Mid-most significants bytes of OEMKEY
6.10.24 FLASH OEM key register 4 (FLASH_OEMKEYR4_PRG)
Address offset: 0xBC
Reset value: 0XXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR. This register is read as zero.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| OEMKEY[127:112] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| OEMKEY[111:96] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 OEMKEY[127:96]: Most significants bytes of OEMKEY

6.10.25 FLASH boundary scan key register (FLASH_BSKEYR_PRG)
Address offset: 0xC4
Reset value: 0XXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR. This register is read as zero.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| BSKEY[31:16] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| BSKEY[15:0] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 BSKEY[31:0]: Boundary scan key
6.10.26 FLASH write page protection for bank1 (FLASH_WRP1R_CUR)
Address offset: 0x0E8
Reset value: 0XXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
Default value: 0x0000 0000 (value in case of double ECC issue during OBL).
ST production value: refer to Table 28: Option-byte organization
This read-only register reflects the current values of corresponding option bits.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| WRPSG1[31:16] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| WRPSG1[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:0 WRPSG1[31:0]: Bank1 page protection option status byte
Each bit reflects the write protection status of the corresponding group of pages in Bank1.
0: Write protected
1: Not write protected
Note: Refer to Table 29: Write-protection management for group definition.
6.10.27 FLASH write-page protection for bank1 (FLASH_WRP1R_PRG)
Address offset: 0x0EC
Reset value: 0xXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR. This register is used to program values in corresponding option bits.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| WRPSG1[31:16] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| WRPSG1[15:0] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bits 31:0 WRPSG1[31:0]: Bank1 page protection option status byte
Setting these bits to 0 write-protects the corresponding pages in bank 1
0: Write protected
1: Not write protected
Note: Refer to Table 29: Write-protection management for group definition.
6.10.28 FLASH HDP bank1 register (FLASH_HDP1R_CUR)
Address offset: 0x0F8
Reset value: 0xXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
This register is initially loaded with the values of corresponding option bits.
Default value: 0x000F 0000 (value in case of double ECC issue during OBL) for STM32C53x/542.
Default value: 0x001F 0000 (value in case of double ECC issue during OBL) for STM32C55x/562.
Default value: 0x003F 0000 (value in case of double ECC issue during OBL) for STM32C59x/5A3.
ST production value: refer to Table 28: Option-byte organization
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_END[5:0] | |||||
| r | r | r | r | r | r | ||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_STRT[5:0] | |||||
| r | r | r | r | r | r | ||||||||||
Bits 31:22 Reserved, must be kept at reset value.
Bits 21:16 HDP1_END[5:0]: HDPL barrier end set in number of 8-Kbyte pages
Bits 15:6 Reserved, must be kept at reset value.
Bits 5:0 HDP1_STRT[5:0]: HDPL barrier start set in number of 8-Kbyte pages
6.10.29 FLASH HDP bank1 register (FLASH_HDP1R_PRG)
Address offset: 0x0FC
Reset value: 0XXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR. Register is accessible only in HDPL1. In HDPL=2 or 3 it is WI, RAZ.
This register is used to program values in corresponding option bits.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_END[5:0] | |||||
| rw | rw | rw | rw | rw | rw | ||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_STRT[5:0] | |||||
| rw | rw | rw | rw | rw | rw | ||||||||||
Bits 31:22 Reserved, must be kept at reset value.
Bits 21:16 HDP1_END[5:0]: Bank 1 HDPL barrier end set in number of 8-Kbyte pages
Bits 15:6 Reserved, must be kept at reset value.
Bits 5:0 HDP1_STRT[5:0]: Bank 1 HDPL barrier start set in number of 8-Kbyte pages
6.10.30 FLASH ECC correction register (FLASH_ECCCORR)
Address offset: 0x100
Reset value: 0x0000 0000
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | ECCC | Res. | Res. | Res. | Res. | ECCCI E | OTP_E CC | SYSF_ ECC | BK_EC C | EDATA_ ECC | Res. | Res. | Res. | Res. | Res. |
| rw | rw | r | r | r | r | ||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| ADDR_ECC[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bit 31 Reserved, must be kept at reset value.
Bit 30 ECCC: ECC correction
Set by hardware when single ECC error has been detected and corrected.
Cleared by writing 1.
Bits 29:26 Reserved, must be kept at reset value.
- Bit 25 ECCIE: ECC single-correction error interrupt enable bit
When this bit is set to 1, an interrupt is generated when an ECC single-correction error occurs during a read operation.
0: No interrupt generated when an ECC single-correction error occurs.
1: Interrupt generated when an ECC single-correction error occurs. - Bit 24 OTP_ECC: OTP ECC error bit
This bit is set to 1 when one ECC single-correction occurred during the last successful read operation from the read-only/ OTP area. The address of the ECC error is available in ADDR_ECC bitfield. - Bit 23 SYSF_ECC: ECC flag for corrected ECC error in system FLASH
This bit indicates if system flash memory is concerned by an ECC error. - Bit 22 BK_ECC: ECC bank flag for corrected ECC error
This bit indicates which bank is concerned by an ECC error . - Bit 21 EDATA_ECC: ECC fail for corrected ECC error in FLASH data area
This bit indicates if FLASH data area is concerned by an ECC error.
Bits 20:16 Reserved, must be kept at reset value.
- Bits 15:0 ADDR_ECC[15:0]: ECC error address
When an ECC error occurs (for single correction) during a read operation, this bitfield contains the address that generated the error. It is reset when the flag error is reset.
The FLASH programs the address in this register only when no ECC error flags are set. This means that only the first address that generated an ECC error is saved.
The address in ADDR_ECC is relative to the FLASH area where the error occurred (user flash memory, system flash memory, data area, read-only/OTP area).
6.10.31 FLASH ECC detection register (FLASH_ECCDETR)
Address offset: 0x104
Reset value: 0x0000 0000
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
| column_1 | column_2 | Bit 25 Bit 24 Bit 23 Bit 22 Bit 21 Bits 15:0 | ECCCIE OTP_ECC SYSF_ECC BK_ECC EDATA_ECC | column_5 | column_6 | column_7 | column_8 | column_9 | column_10 | column_11 | column_12 | column_13 | column_14 | column_15 | RM0522 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| ECCD | Res. | Res. | Res. | Res. | Res. | Res. | OTP_E | SYSF_ | BK_EC | EDATA | |||||
| CC | ECC | C | _ECC | Res. | Res. | Res. | Res. | Res. | |||||||
| rc_w1 | r | r | r | r | |||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 ADDR_ECC[15:0] | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| Bit 31 | ECCD: | ECC detection set by hardware when two ECC errors have been detected | |||||||||||||
| Bit 24 | OTP_ECC | : OTP ECC error bit |
- Bit 31 ECCD: ECC detection set by hardware when two ECC errors have been detected
When this bit is set, a NMI is generated. This bit is cleared by writing 1. Needs to be cleared in order to detect subsequent double ECC errors.
Bits 30:25 Reserved, must be kept at reset value.
- Bit 24 OTP_ECC: OTP ECC error bit
This bit is set to 1 when a double ECC detection occurred during the last read operation from the read-only/ OTP area. The address of the ECC error is available in ADDR_ECC bitfield.

Bit 23 SYSF_ECC: ECC fail for double ECC error in system flash memory
This bit indicates if system flash memory is concerned by an ECC error.
Bit 22 BK_ECC: ECC fail bank for double ECC Error
This bit indicates which bank is concerned by an ECC error.
Bit 21 EDATA_ECC: ECC fail for double ECC error in FLASH data area
This bit indicates if FLASH EDATA sector is concerned by an ECC error.
Bits 20:16 Reserved, must be kept at reset value.
Bits 15:0 ADDR_ECC[15:0]: ECC error address
When an ECC error occurs (double detection) during a read operation, this bitfield contains the address that generated the error. It is reset when the flag error is reset.
The FLASH programs the address in this register only when no ECC error flags are set. This means that only the first address that generated an double ECC error is saved. The address in ADDR_ECC is relative to the flash memory area where the error occurred (user flash memory, system flash memory, data area, read-only/OTP area).
6.10.32 FLASH ECC data (FLASH_ECCDR)
Address offset: 0x108
Reset value: 0x0000 0000
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | DATA_ADDR_ECC[2:0] | ||
| r | r | r | |||||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| DATA_ECC[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:19 Reserved, must be kept at reset value.
Bits 18:16 DATA_ADDR_ECC[2:0]: DATA ECC error address
When a double detection ECC error occurs on special areas with 6-bit ECC on 16-bit data (data area, read-only/OTP area), the position of the failing word on the FLASH line can be read to this register.
000: Double error on first 16-bit data or first 32-bit data accessed on the FLASH line
001: Double error on second 16-bit data accessed on the FLASH line
010: Double error on third 16-bit data or second 32-bit data accessed on the FLASH line
011: Double error on fourth 16-bit data accessed on the FLASH line
100: Double error on fifth 16-bit data or third 32-bit data accessed on the FLASH line
101: Double error on sixth 16-bit data
Note: If the data access was 16 bits, the corrupted word can be fully located. If access was 32 bits, use DATA_ECC value to discriminate which one of the two 16-bit word is faulty.
Bits 15:0 DATA_ECC[15:0]: ECC error data
When a double detection ECC error occurs on special areas with 6-bit ECC on 16-bit data (data area, read-only/OTP area), the failing data is read to this register.
By checking if it is possible to determine whether the failure was on a real data, or due to access to uninitialized memory.
6.10.33 FLASH write page protection for bank2 (FLASH_WRP2R_CUR)
Address offset: 0x1E8
Reset value: 0xXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
Default value: 0x0000 0000 (value in case of double ECC issue during OBL).
ST production value: refer to Table 28: Option-byte organization
This read-only register reflects the current values of corresponding option bits.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| WRPSG2[31:16] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| WRPSG2[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:0 WRPSG2[31:0]: Bank2 page protection option status byte
Each bit reflects the write protection status of the corresponding group of pages in Bank2.
0: Write protected
1: Not write protected
Note: Refer to Table 29: Write-protection management group definition.
6.10.34 FLASH write page protection for bank2 (FLASH_WRP2R_PRG)
Address offset: 0x1EC
Reset value: 0xXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
This register is used to program values in corresponding option bits.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| WRPSG2[31:16] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| WRPSG2[15:0] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bits 31:0 WRPSG2[31:0]: Bank2 page protection option status byte
Setting WRPSG2 bits to 0 write protects the corresponding pages in bank 2
0: write protected;
1: not write protected
Note: Refer to Table 29: Write-protection management group definition.
6.10.35 FLASH HDP bank2 register (FLASH_HDP2R_CUR)
Address offset: 0x1F8
Reset value: 0xXXXX XXXX
This register is initially loaded with the values of corresponding option bits.
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
Default value: 0x000F 0000 (value in case of double ECC issue during OBL) for STM32C53x/542.
Default value: 0x001F 0000 (value in case of double ECC issue during OBL) for STM32C55x/562.
Default value: 0x003F 0000 (value in case of double ECC issue during OBL) for STM32C59x/5A3.
ST production value: refer to Table 28: Option-byte organization
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_END[5:0] | |||||
| r | r | r | r | r | r | ||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_STRT[5:0] | |||||
| r | r | r | r | r | r | ||||||||||
Bits 31:22 Reserved, must be kept at reset value.
Bits 21:16 HDP2_END[5:0]: Bank 2 HDPL barrier end set in number of 8-Kbyte pages
Bits 15:6 Reserved, must be kept at reset value.
Bits 5:0 HDP2_STRT[5:0]: Bank 2 HDPL barrier start set in number of 8-Kbyte pages
6.10.36 FLASH HDP bank2 register (FLASH_HDP2R_PRG)
Address offset: 0x1FC
Reset value: 0xXXXX XXXX
This register can be protected against unprivileged access when PRIV = 1 in FLASH_PRIVCFGR.
Register is accessible only in HDPL0 and HDPL1. In HDPL=2 or 3 it is WI, RAZ.
This register is used to program values in corresponding option bits.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_END[5:0] | |||||
| rw | rw | rw | rw | rw | rw | ||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_STRT[5:0] | |||||
| rw | rw | rw | rw | rw | rw | ||||||||||
Bits 31:22 Reserved, must be kept at reset value.
Bits 21:16 HDP2_END[5:0]: Bank 2 HDPL barrier end set in number of 8-Kbyte pages
Bits 15:6 Reserved, must be kept at reset value.
Bits 5:0 HDP2_STRT[5:0]: Bank 2 HDPL barrier start set in number of 8-Kbyte pages
6.10.37 FLASH register map
Table 43. FLASH register map and reset values
| Offset | Register name | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x000 | FLASH_ACR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | EMPTY | Res. | Res. | Res. | Res. | Res. | Res. | Res. | PRFTEN | Res. | Res. | WRHIGHFREQ[1:0] | LATENCY[3:0] | ||||
| Reset value | x | 0 | 1 | 0 | 0 | 1 | 1 | 1 | |||||||||||||||||||||||||
| 0x004 | FLASH_KEYR | KEY[31:0] | |||||||||||||||||||||||||||||||
| Reset value | 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 | |
| 0x008 | Reserved | ||||||||||||||||||||||||||||||||
| 0x00C | FLASH_OPTKEYR | OPTKEY[31:0] | |||||||||||||||||||||||||||||||
| Reset value | 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 | |
| 0x010 - 0x014 | Reserved | ||||||||||||||||||||||||||||||||
| 0x018 | FLASH_OPSR | CODE_OP[2:0] | Res. | Res. | Res. | Res. | OTP_OP | Res. | BK_OP | DATA_OP | Res. | Res. | Res. | Res. | ADDR_OP[15:0] | ||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |||||||||||
| 0x01C | FLASH_OPTCR | SWAP_BANK | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | OPTSTRT | OPTLOCK | |
| Reset value | x | 0 | 1 | ||||||||||||||||||||||||||||||
| 0x020 | FLASH_SR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | OPTCHANGEERR | Res. | Res. | INCERR | STRBERR | PGSERR | WRPERR | EOP | Res. | Res. | Res. | Res. | Res. | Res. | Res. | BSLOCK | OEMLOCK | Res. | Res. | Res. | Res. | DBNE | Res. | WBNE |
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | x | x | |||||||||||||||||||||||
| 0x024 | Reserved | ||||||||||||||||||||||||||||||||

| Offset | Register name | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x028 | FLASH_CR | BKSEL | Res. | EDATASEL | Res. | Res. | Res. | Res. | Res. | OPTCHANGEERRIE | Res. | Res. | INCERIE | STRBERRIE | PGSERRIE | WRPERIE | EOPIE | MER | Res. | Res. | PNB[6:0] | STRT | FW | BER | PER | PG | LOCK | ||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | |||||||||||
| 0x02C | Reserved | ||||||||||||||||||||||||||||||||
| 0x030 | FLASH_CCR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | CLR_OPTCHANGEERR | Res. | Res. | CLR_INCERR | CLR_STRBERR | CLR_PGSERR | CLR_WRPERR | CLR_EOP | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | |||||||||||||||||||||||||||
| 0x034 - 0x038 | Reserved | ||||||||||||||||||||||||||||||||
| 0x03C | FLASH_PRIVCFGR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | PRIV | Res. |
| Reset value | 0 | ||||||||||||||||||||||||||||||||
| 0x040 - 0x044 | Reserved | ||||||||||||||||||||||||||||||||
| 0x048 | FLASH_HDPEXTR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_EXT[5:0] | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_EXT[5:0] | ||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||||||||||||||||||||
| 0x04C | Reserved | ||||||||||||||||||||||||||||||||
| 0x050 | FLASH_OPTSR_CUR | SWAP_BANK | SINGLE_BANK | EDATA_EN | Res. | Res. | Res. | Res. | Res. | BOOT0 | BOOT_SEL | IWDG_STDBY | IWDG_STOP | Res. | Res. | Res. | Res. | RDP_LEVEL[7:0] | NRST_STDBY | NRST_STOP | Res. | WWDG_SW | IWDG_SW | Res. | Res. | Res. | |||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | ||||||||||||||
| 0x054 | FLASH_OPTSR_PRG | SWAP_BANK | SINGLE_BANK | EDATA_EN | Res. | Res. | Res. | Res. | Res. | BOOT0 | BOOT_SEL | IWDG_STDBY | IWDG_STOP | Res. | Res. | Res. | Res. | RDP_LEVEL[7:0] | NRST_STDBY | NRST_STOP | Res. | WWDG_SW | IWDG_SW | Res. | Res. | Res. | |||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | ||||||||||||||
| 0x058 - 0x06C | Reserved | ||||||||||||||||||||||||||||||||
| 0x070 | FLASH_OPTSR2_CUR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | SRAM2_ECC | Res. | Res. | SRAM2_RST | SRAM1_RST | Res. | |
| Reset value | x | x | x | ||||||||||||||||||||||||||||||
Table 43. FLASH register map and reset values (continued)
| Offset | Register name | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x074 | FLASH_OPTSR2_PRG | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | SRAM2_ECC | |||||
| Reset value | x | ||||||||||||||||||||||||||||||||
| 0x078 - 0x07C | Reserved | ||||||||||||||||||||||||||||||||
| 0x080 | FLASH_BOOTR_CUR | BOOTADD[23:0] | BOOT_LOCK[7:0] | ||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x084 | FLASH_BOOTR_PRG | BOOTADD[23:0] | BOOT_LOCK[7:0] | ||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x088 - 0x08C | Reserved | ||||||||||||||||||||||||||||||||
| 0x090 | FLASH_OTPBLR_CUR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | LOCKBL[23:0] | ||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | ||||||||||
| 0x094 | FLASH_OTPBLR_PRG | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | LOCKBL[23:0] | ||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | ||||||||||
| 0x098 | FLASH_BL_COM_CFG_CUR | BL_COM_CFG[31:0] | |||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x09C | FLASH_BL_COM_CFG_PRG | BL_COM_CFG[31:0] | |||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x0A0 | Reserved | ||||||||||||||||||||||||||||||||
| 0x0A4 | FLASH_OEMKEYR1_PRG | OEMKEY[31:0] | |||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x0A8 | Reserved | ||||||||||||||||||||||||||||||||
| 0x0AC | FLASH_OEMKEYR2_PRG | OEMKEY[31:0] | |||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x0B0 | Reserved | ||||||||||||||||||||||||||||||||
| 0x0B4 | FLASH_OEMKEYR3_PRG | OEMKEY[31:0] | |||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x0B8 | Reserved | ||||||||||||||||||||||||||||||||
| 0x0BC | FLASH_OEMKEYR4_PRG | OEMKEY[31:0] | |||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x0C0 | Reserved | ||||||||||||||||||||||||||||||||

Table 43. FLASH register map and reset values (continued)
| Offset | Register name | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x0C4 | FLASH_BSKEYR_PRG | BSKEY[31:0] | |||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x0C8 - 0x0E4 | Reserved | ||||||||||||||||||||||||||||||||
| 0x0E8 | FLASH_WRP1R_CUR | WRPSG1[31:0] | |||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x0EC | FLASH_WRP1R_PRG | WRPSG1[31:0] | |||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x0F0 - 0x0F4 | Reserved | ||||||||||||||||||||||||||||||||
| 0x0F8 | FLASH_HDP1R_CUR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_END[5:0] | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_STRT[5:0] | |||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | |||||||||||||||||||||
| 0x0FC | FLASH_HDP1R_PRG | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_END[5:0] | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP1_STRT[5:0] | |||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | |||||||||||||||||||||
| 0x100 | FLASH_ECCCORR | Res. | ECCC | Res. | Res. | Res. | Res. | Res. | ECCIE | OTP_ECC | SYSF_ECC | BK_ECC | EDATA_ECC | Res. | Res. | Res. | Res. | Res. | ADDR_ECC[15:0] | ||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||||||||||
| 0x104 | FLASH_ECCDETR | ECCD | Res. | Res. | Res. | Res. | Res. | Res. | Res. | OTP_ECC | SYSF_ECC | BK_ECC | EDATA_ECC | Res. | Res. | Res. | Res. | Res. | ADDR_ECC[15:0] | ||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||||||||||||
| 0x108 | FLASH_ECCDR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | DATA_ADDR_ECC[2:0] | DATA_ECC[15:0] | |||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||||||||||||
| 0x10C - 0x1E4 | Reserved | ||||||||||||||||||||||||||||||||
| 0x1E8 | FLASH_WRP2R_CUR | WRPSG2[31:0] | |||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x1EC | FLASH_WRP2R_PRG | WRPSG2[31:0] | |||||||||||||||||||||||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |
| 0x1F0 - 0x1F4 | Reserved | ||||||||||||||||||||||||||||||||
Table 43. FLASH register map and reset values (continued)
| Offset | Register name | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x1F8 | FLASH_HDP2R_CUR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_END[5:0] | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_STRT[5:0] | ||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | |||||||||||||||||||||
| 0x1FC | FLASH_HDP2R_PRG | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_END[5:0] | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | HDP2_STRT[5:0] | ||||||||||
| Reset value | x | x | x | x | x | x | x | x | x | x | x | x | |||||||||||||||||||||
Refer to Section 2.2: Memory organization for the register boundary addresses.