 Hello and welcome to this presentation of the STM32 flash memory interface. It covers all the new features of the STM32-F7 flash memory. STM32-F7 microcontrollers embed up to two megabytes of flash memory. The flash memory interface manages all memory access, read, programming and erasing as well as memory protection and option bytes. Applications using this flash memory interface benefit from its high performance together with low power access. It supports read while write and allows dual bank booting for devices supporting the dual bank feature. Flash memory has several key features. It has the adaptive real-time or ART memory accelerator with a unified instruction and data cache. Also, a pre-fetch buffer allows a linear performance in relation to frequency while executing from the tightly coupled memories for instructions or ITCM interface. The STM32-F7 series has up to two megabytes of flash memory configurable in single or dual bank mode with a read while write capability that can program or erase one bank while executing code from the other bank. Note that the dual bank feature is only available on STM32-F7 6x-F7 7x devices. The flash memory interface has three main buses, a 64-bit ITCM interface, a 64-bit AXI-AHB interface and a 32-bit AHB register interface. The flash memory is mapped on the ITCM interface of the Cortex-M7 processor and used for code execution and data read accesses to the flash memory. Write accesses to the flash memory are not possible through this interface. The flash memory remains accessible to the Cortex-M7 processor and other masters such as DMA controllers through the AHB interface. The 32-bit AHB register interface is used for control and status register accesses during user flash memory and option byte programming. The flash memory is divided into two functional blocks, a main memory block containing up to two megabytes for user code and data. The default configuration for the main flash memory is in single bank mode. For devices supporting dual bank mode, the flash memory organization can be changed via the ND bank user option bit. The second flash memory functional block is an information block which contains three parts. The first part is the system memory which is reserved for use by ST Microelectronics and contains the bootloader. When selected, the device boots in system memory to execute the bootloader. The second part is a one kilobyte one-time programmable area. The OTP area cannot be erased and can be written to only once. The last part contains the option bytes for configuring user options. This slide shows an example of the flash memory map. This example is from STM32-F76X-F77X devices with two megabytes of flash memory. In single bank mode, there are four sectors of 32 kilobytes starting from sector 0 to 3, one sector of 128 kilobytes which is sector 4 and seven sectors of 256 kilobytes starting from sector 5 to sector 11. The sector number is used in the software procedure to erase a sector or to protect it. In dual bank mode for STM32-F76X-F77X MCUs, the two megabytes of flash memory is organized as 12 sectors for each flash memory bank. Where each bank has four sectors of 16 kilobytes, one sector of 64 kilobytes and seven sectors of 128 kilobytes. Bank two sectors start from sector 12 to sector 23. Dual bank mode is also available for STM32-F76X-F77X MCUs that are one megabyte devices. This slide describes the memory organization in this configuration. The embedded flash memory is a dual bank memory with read while write and dual bank boot capability able to boot either from bank one or bank two. The ND boot option in the user option bytes is used to select the dual bank boot mode. When the ND boot option is reset, the device boots either from bank two or from bank one depending on the boot ADD address and valid bank content. When dual bank boot is enabled, the device boots from system memory to execute bank swap when valid bank is detected. With a dual bank memory, it is possible to read from one bank while programming or erasing the other bank. Code execution is not stopped when the flash memory is being programmed. When programming or erasing data in the same bank, the fetch is stalled as long as the flash memory controller is busy. Using the FV mode bit in the system configuration memory remap register, the two flash memory bank addresses can be swapped. When this bit is cleared, bank one is mapped at address 0x0800000 for AHB access and 0x0020000 for ITCM access. When this bit is set, bank two is mapped at address 0x0800000 for AHB access and 0x00200000 for ITCM access, which allows the device to boot into bank two. The dual bank boot allows a safe firmware upgrade as the previous firmware version is still present in the other memory bank. The dual bank boot is managed by the bootloader. The device boots in bank two using the ND boot option bit programmed in the flash option bytes. The boot pin and boot option are configured for booting in flash memory. If the ND boot option bit is set, the device boots according to address in boot ADD option bytes. If the ND boot option bit is cleared, the device boots in the system flash memory. The bootloader checks the bank's content indexed by boot ADD address as it must read there the stack pointer at that location. If bank two's boot ADD address content is a valid SRAM address, the bootloader swaps the banks to remap the bank two at address 0x00200000 and jumps into bank two. If it is not valid, the bootloader swaps the banks to remap bank one at address 0x00200000 and jumps into bank one. Note that the bootloader uses resources in SRAM for dual boot. The content of SRAM is not preserved after reset. The flash memory interface implements program and erase operations. The programming granularity depends on the MCU supply range. Word parallelism is only available in the 2.7 to 3.6 volt range. Half-word parallelism is available starting from 2.1 to 2.7 volts, while byte programming is available on the full VDD range. To enhance programming parallelism, it is possible to use double-word programming. This is only available starting from 2.7 volts while applying an external VPP while programming. Erase granularity can be down to sector size. Also, it is possible to erase the complete flash memory using the mass erase option. Bank erase is only available with devices supporting dual bank mode. As the flash memory has a long read access time, in order to read the flash memory, software is required to configure the number of weight states to be inserted in a read access, depending on the clock frequency. The number of weight states also depends on the MCU supply voltage range. For the 2.7 to 3.6 volt range, the flash memory can be accessed at up to 216 MHz with 7 weight states. It can be accessed with 0 weight states at up to 30 MHz. For the 2.4 to 2.7 volt range, code execution at up to 216 MHz is possible with 8 weight states. For the 2.1 to 2.4 volt range, code execution at up to 216 MHz is possible with 9 weight states. When VDD is below 2.1 volts, flash memory can be accessed with 0 weight states at up to 20 MHz. Thanks to the Cortex-M7-L1 cache and to the Adaptive Real-Time Memory Accelerator, the Art Accelerator on the ITCM interface, the program can be executed with 0 weight states independent of the clock frequency. This provides an almost linear performance in relation to frequency. The Art Accelerator is available only on the Cortex-M7-ITCM interface. It brings outstanding performance and reduces cache usage while executing code from flash memory. It consists of 64 unified cache lines with a 256 or 128 bit width depending on the flash memory interface with configuration. For each Cortex-M7 fetch, a lookup in current buffer, pre-fetch buffer and art cache is performed. If there is a hit, the data is immediately returned to the CPU. In case of a miss, the Cortex-M7 processor takes the data directly from the flash memory. In parallel, the flash memory line is copied into the current buffer enabled and art cache if enabled. If pre-fetch is enabled, another flash memory access is performed to fill the pre-fetch buffer with sequential data. Several option bytes are available in the flash memory information block to configure certain specific features of the device. The option bytes are saved in the flash memory after programming. The user option bytes are loaded in two cases, either after a power or a brownout reset when exiting from standby mode or after option byte programming. Three option bits are used to configure the brownout reset threshold. Two options are available to prohibit or allow the stop or standby low power modes. Four options are available to configure whether the watchdogs are enabled by hardware or after a software configuration and if the independent watchdog is frozen or not in stop and standby modes. Two options are used to enable dual bank boot mode and dual bank boot in devices supporting dual bank mode. The boot ADD options are used together with the boot zero pin to configure the memory address used for booting. The RDP option byte is used to set the memory readout protection level. Several flash memory protection options can be configured using the option bytes. The readout protection is configured using the RDP option byte. The readout protection prohibits any access to the flash memory or the backup registers by the debug interface or when booting from SRAM or when the bootloader is selected. The write protection is configured using the WRP option byte. This option protects specific code areas from unwanted write accesses. The write protected area can be defined with sector granularity for single bank flash memory devices while in dual bank mode. One bit protects two consecutive sectors. Three interrupts can be generated by the flash memory. The end of operation interrupt is triggered when one or more flash program or erase operations is completed successfully. The programming error interrupt is triggered when a flash memory program or erase operation failed. The write protection error interrupt is triggered when a write access is attempted to a write protected area of the flash memory. This shows a summary of the flash memory interface states in each of the power modes. The performance of the flash memory is almost linear with the frequency using the ART accelerator or Cortex-M7 processor using the instruction and data cache. The core mark score is 1082 at 216 megahertz which corresponds to roughly 5 core mark per megahertz when executing from the ITCM interface with the instruction cache, data cache and prefetch buffer enabled or when executing over the AXEM interface with the Cortex-M7L1 cache enabled. This is a list of peripherals related to the flash memory interface. Please refer to these trainings for more information if needed. For more details please refer to these application notes about the STM32F7 microcontroller execution performances, dual bank feature and system memory boot mode.