Flash Memory Operations

Writing to flash memory consists of an erase cycle followed by a program cycle. Following the erase cycle, the erased cells have a value of all ones. Programming the flash cells clears some of these cells to zero.

IMPORTANT: The flash write library contains functions that the user application can use to perform writes. A copy of this flash write library is provided in the RSL15 program ROM, and can be used to write to the flash at any time. Refer to the RSL15 Firmware Reference for more information.

Commands are issued explicitly to the flash interface by writes to the FLASH_CMD_CTRL_COMMAND bit-field of the FLASH_CMD_CTRL register, or as side effects of writes to the FLASH_IF_CTRL register that change the value of the FLASH_IF_CTRL_VREAD1_MODE, FLASH_IF_CTRL_RECALL, or FLASH_IF_CTRL_LP_MODE bits. Commands that can be executed on the flash are listed in the "Flash Low-Level Commands" table. All commands return to the idle state, except the sequential programming (CMD_PROGRAM_SEQ) and the deep power down (CMD_DPD) commands. If the flash is already busy, the command is ignored along with writes to all other flash registers, except:

  • FLASH_DATA* when new data is requested for a CMD_PROGRAM_SEQ command
  • FLASH_CMD_CTRL_CMD_END from FLASH_CMD_CTRL, which can be used to terminate the current command
  • FLASH_DELAY_CTRL, which updates the flash timing as described in Flash
  • FLASH_ECC_CTRL, which updates the use of the error correction coding as described in Error-Correction Coding

CAUTION: While changing FLASH_ECC_CTRL is possible while executing a flash command, changing the FLASH_ECC_CTRL_CMD_ECC_CTRL bit while executing a read or write command results in undefined behavior for the flash operation. Since this can result in an unknown value written to or read from flash, this bit-field must not be changed while writing or reading from flash.

NOTE: While any flash operations are in progress, the flash memory instance cannot be accessed from the Arm Cortex-M33 processor's code bus. This includes any case where a flash command is issued through a write to the FLASH_CMD_CTRL register or when a low-level flash command is triggered by writing to the FLASH_IF_CTRL register. Access to the flash while a flash operation is being processed results in a bus fault.

Table: Flash Low-Level Commands

Command

Description

CMD_IDLE

No flash command is active or pending.

CMD_WAKE_UP

This power-up sequence starts automatically when the flash isolation is removed through the SYSCTRL_MEM_ACCESS_CFG register.

CMD_LOAD_TRIM

Transfer from the MNVR sector to the PATCH_ADDR[7:0] registers and to the flash internal configuration registers. The status bit TRIMMED_STATUS is updated at the end of the command, indicating if there has been an uncorrectable ECC error or a word pair containing all 1s or 0s when reading MNVR, in which case the default trim values are used to guarantee the proper flash read functionality.

CMD_SET_CONF_REG

Copy from FLASH_DATA[1:0] registers to the flash internal configuration registers specified by the FLASH_ADDR register (only used for Production test).

CMD_DPD

This command that does not complete by itself, but requires CMD_END for this. While this command is active, the BUSY bit of the FLASH_IF_STATUS register is set and any CBus access to the flash results in a bus fault.

CMD_READ

Execute a read access, mainly for test purposes.

If ECC is enabled, a pair of 32-bit words is read from the flash.

If ECC is disabled, a single 38-bit word is read from the flash.

CMD_PROGRAM_NOS EQ

Execute a non-sequential programming access.

This command is only accepted when the sector addressed by FLASH_ADDR is in an unlocked flash zone.

A single word is written in the flash.

The RETRY field of FLASH_IF_CTRL must be set to FLASH_RETRY_4.

CMD_PROGRAM_SEQ

Initiates a sequential programming access.

This command is only accepted when the sector addressed by FLASH_ADDR is in an unlocked flash zone.

Up to 128 words can be written in the same row within a Code sector and up to 32 words can be written in the same row within a Data sector.

The RETRY field of FLASH_IF_CTRL must be set to FLASH_RETRY_4. This command that does not complete by itself, but requires CMD_END for this. While this command is active, the BUSY bit of the FLASH_IF_STATUS register is set and any CBus access to the flash results in a bus fault.

CMD_PRE_PROGRAM_NOS EQ

Execute a non-sequential programming access with a pre-programming step. The pre-program is needed if an endurance higher than 10 k is required.

This command is only accepted when the sector addressed by FLASH_ADDR is in an unlocked flash zone.

A single word is written in the flash.

The RETRY field of FLASH_IF_CTRL must be set to FLASH_RETRY_4.

This command must be follow by the CMD_PROGRAM_NOSEQ command with the same address and the same data written with the CMD_PRE_PROGRAM_NOSEQ command.

CMD_PRE_PROGRAM_SEQ

Initiates a sequential programming access with a pre-programming step. The pre-program is needed if an endurance higher than 10 k is required.

This command is only accepted when the sector addressed by FLASH_ADDR is in an unlocked flash zone.

Up to 128 words can be written in the same row within a Code sector and up to 32 word can be written in the same row within a Data sector.

The RETRY field of the FLASH_IF_CTRL register must be set to FLASH_RETRY_4.

This command that does not complete by itself, but requires CMD_END for this. While this command is active, the BUSY bit of the FLASH_IF_STATUS register is set and any CBus access to the flash results in a bus fault.

This command must be followed by the CMD_PROGRAM_SEQ command with the same addresses and the data written with the CMD_PRE_PROGRAM_SEQ command.

CMD_END

Terminates a sequential programming access (with or without pre-program) or exits deep power down mode.

This command is only accepted when the PROG_SEQ_DATA_REQ bit of the FLASH_IF_STATUS register is set, or while in deep power down mode. Note that it is not an actual flash command, but a write action bit.

CMD_SECTOR_ERASE

This sector erase command is only accepted when the sector addressed by FLASH_ADDR is in an unlocked Flash zone.

The RETRY field of FLASH_IF_CTRL determines the erase strength; see Flash Memory Registers for more details.

CMD_MASS_ERASE

This mass erase command is only accepted when all MAIN zones are unlocked, and NVR zones are locked.

All MAIN sectors (code & data arrays), including the redundancy sectors, are erased except when NVR0 through NVR7 are unlocked.

The RETRY field of FLASH_IF_CTRL must be set to FLASH_RETRY_4.

The write cycle endurance of the Flash is impacted by performing a mass erase. It is therefore recommended to only use sector erase in the application.

CMD_SET_LOW_POWER

Sets the LPWR Flash pin respecting the hold & setup time. This command is called automatically when the LP_MODE bit in the FLASH_IF_CTRL register is changed from 0 to 1.

CMD_UNSET_LOW_POWER

Unsets the LPWR Flash pin respecting the hold & setup time. This command is called automatically when the LP_MODE bit in theFLASH_IF_CTRL register is changed from 1 to 0.

CMD_SET_RECALL

Sets the RECALL Flash pin respecting the hold & setup time. This command is called automatically when the RECALL bit in theFLASH_IF_CTRL register is changed from 0 to 1.

CMD_UNSET_RECALL

Unsets the RECALL Flash pin respecting the hold & setup time. This command is called automatically when the RECALL bit in the FLASH_IF_CTRL register is changed from 1 to 0.

CMD_SET_VREAD1

Sets the VREAD1 Flash pin respecting the hold & setup time. This command is called automatically when the VREAD1_MODE bit in the FLASH_IF_CTRL register is changed from 0 to 1

CMD_UNSET_VREAD1

Sets the VREAD1 Flash pin respecting the hold & setup time. This command is called automatically when the VREAD1_MODE bit in the FLASH_IF_CTRL register is changed from 1 to 0.

CMD_WRITE_USER_RED

Writes FLASH_DATA[0] into MNVR. FLASH_DATA[1] indicates the redundancy sector.