QSPI Interface On STM32 - en - DM00227538
QSPI Interface On STM32 - en - DM00227538
QSPI Interface On STM32 - en - DM00227538
Application note
Quad-SPI interface (QUADSPI) on STM32 microcontrollers
Introduction
In order to manage a wide range of multimedia, richer graphics and other data-intensive
content, embedded applications evolve to offer more sophisticated features. These
sophisticated features require extra demands on the often limited MCU on-chip memory.
External parallel memories are used to extend the MCU on-chip memory and solve the
memory size limitation. Usually this action compromises the pin count and implies a need of
more complex designs.
To face these requirements, STM32 MCUs (see applicable products in Table 1 below)
embed an external memory interface named QUADSPI (see more details on Table 2 on
page 9). This interface permits to connect external compact-footprint quad-spi (QSPI) high-
speed memories.This QUADSPI interface can be used for data storage such as images,
icons, or code execution.
This application note describes the QUADSPI interface on the STM32 microcontrollers and
explains how to use the module to configure, program, and read external QSPI memories. It
describes some typical use cases to use the QUADSPI interface based on some software
examples from the STM32Cube firmware package and from the STM32F7 Series
application notes.
This document refers to STM32 Quad-SPI interface by its name “QUADSPI” and to
Quad-SPI memories as “QSPI memories”.
For additional more detailed information about the products listed on the table below, refer
to the corresponding datasheets and reference manuals available from STMicroelectronics
web site www.st.com.
Contents
1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1 QUADSPI availability and features across STM32 families . . . . . . . . . . . . 8
1.2 QUADSPI benefits against classic SPI and parallel interfaces . . . . . . . . 10
1.2.1 Main benefits of STM32 embedded QUADSPI interface . . . . . . . . . . . . 10
1.3 QUADSPI in a smart architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
1.3.1 System architecture: STM32L4 Series . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.3.2 System architecture: STM32F4 Series . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.3.3 System architecture: STM32F7 Series . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.4 System architecture: STM32H7 Series . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.3.5 System architecture: STM32WB55xx devices . . . . . . . . . . . . . . . . . . . . 16
3 QUADSPI configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.1 GPIOs configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.1.1 GPIOs configuration using STM32CubeMX tool . . . . . . . . . . . . . . . . . . 40
3.2 QUADSPI peripheral configuration and clock . . . . . . . . . . . . . . . . . . . . . 43
3.2.1 QUADSPI peripheral configuration (QUADSPI_CR register) . . . . . . . . 43
3.2.2 QSPI Flash memory parameters configuration
(QUADSPI_DCR register) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.2.3 QUADSPI and MPU configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.2.4 QSPI memory device configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.2.5 Starting a communication (QUADSPI_CCR register) . . . . . . . . . . . . . . 47
3.3 Hardware considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.3.1 Pull-up resistance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.3.2 Good PCB design allows maximum QUADSPI speed . . . . . . . . . . . . . 48
3.3.3 Chip-select high time (CSHT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.3.4 CKMODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.3.5 Some considerations when using QUADSPI in classical SPI mode . . . 49
7 Supported devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
9 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
List of tables
List of figures
Figure 47. Project configurations: executing code from QSPI Flash memory . . . . . . . . . . . . . . . . . . . 68
Figure 48. Changing QUADSPI configuration in the project settings. . . . . . . . . . . . . . . . . . . . . . . . . . 69
Figure 49. QSPI Flash memory connection in STM32756-EVAL board . . . . . . . . . . . . . . . . . . . . . . . 70
Figure 50. 6_1-Quad-SPI_rwRAM-DTCM project configuration: code and data in QSPI memory . . . 74
Figure 51. 6_2-Quad-SPI_rwRAM-DTCM project configuration: only code in QSPI memory . . . . . . . 76
Figure 52. Indirect write mode: programming QSPI memory using DMA . . . . . . . . . . . . . . . . . . . . . . 80
Figure 53. Indirect write mode: programming QSPI memory using interrupt . . . . . . . . . . . . . . . . . . . . 82
Figure 54. QSPI memory connection on the STM32F746G-DISCO discovery board . . . . . . . . . . . . . 85
Figure 55. QSPI memory connection on the STM32L476G-EVAL board . . . . . . . . . . . . . . . . . . . . . . 86
Figure 56. Deep power-down (DPD) sequence (command B9). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Figure 57. Release from deep power-down (RDP) sequence (command AB) . . . . . . . . . . . . . . . . . . 91
1 Overview
The QUADSPI is a serial interface that allows the communication on four data lines between
a host (STM32) and an external QSPI memory. The QUADSPI supports the traditional SPI
(serial peripheral interface) as well as the dual-SPI mode which allows to communicate on
two lines. QUADSPI uses up to six lines in quad mode: one line for chip select, one line for
clock and four lines for data in and data out.
This interface is integrated on the STM32 microcontroller to fit memory-hungry applications,
to simplify PCB (printed circuit board) designs and to reduce costs.
STM32F412 line
100 80
STM32F413/423 line(3)
STM32F446 line(4) 60
90
STM32F469/479 line
STM32F730xx devices
STM32F7x2 line(4)
STM32F750xx Yes 32
STM32F7x3 80
STM32F7x5 108
STM32F7x6
STM32F7x7
STM32F7x8
STM32F7x9
STM32H743/753
133 100
STM32H750 Value line
STM32L471xx
STM32L412xx 256 Mbytes 4 Gbytes
STM32L422xx
STM32L432xx
No
STM32L442xx
STM32L475xx
STM32L476xx
STM32L486xx
48
STM32L431xx 60 16
STM32L451xx
STM32L452xx
STM32L462xx Yes
STM32L4x3(5)
STM32L496xx
STM32L4A6xx
STM32WB55xx 50 No
STM32L4R5/S5
STM32L4R7/S7 86 60 Yes 32
STM32L4R9/S9(6)
1. Maximum QUADSPI speed from datasheet. For more details on the QUADSPI maximum speed refer to the relevant device
datasheet.
2. 32-bits address mode should be used to reach 256 Mbytes in Memory-mapped mode and 4 Gbytes in Indirect mode.
3. UFQFPN48 does not support QUADSPI.
4. LQFP64 supports only Bank1 and Single-SPI/Dual-SPI only.
5. For this set of products, Dual-Flash mode is supported only with LQFP100 and UFBGA100 packages.
6. This set of products contains two Octo-SPI interfaces, each one of them can connect one or two QSPI memories with
Single-Flash or Dual-Flash modes.
6%XV
,%XV
,&RGH
$&&(/
)ODVK
0DVWHUVDFFHVVLQJ
'&RGH PHPRU\ 48$'63,
48$'63,LQWHUIDFH
65$0
ELW$+%EXV
65$0 48$'63,UHJLVWHUV
DFFHVV
$+%SHULSKHUDO 48$'63,PHPRU\
PDSSHGUHJLRQDFFHVV
$+%SHULSKHUDO %XVPXWOLSOH[HU
)0&
5HJLVWHUV
0HPRU\PDSSHGUHJLRQ
)RU670/[[670/[[670/[[DQG670/[[GHYLFHV48$'63,DQG)0&VKDUHWKHVDPH$+%EXVRQWKHEXVPDWUL[
'0$'LVRQO\DYDLODEOHRQ670/[[DQG670/$[[GHYLFHV
)0&LVDYDLODEOHRQO\RQ670/[[[DQG670/[[[GHYLFHV
:KHQUHPDSSHG 06Y
27*+6
.E\WH &KURP
'0$
'0$
0$&
86%
/'7&
*3
*3
6EXV
'0$B3
'0$B3,
,EXV
'0$B0(0
'0$B0(0
)ODVK
$57
0DVWHUVDFFHVVLQJ PHPRU\
48$'63,
48$'63,LQWHUIDFH 65$0
65$0
ELW$+%EXV
65$0 $3%
48$'63,UHJLVWHUV
DFFHVV $+%SHULSKHUDO $3%
48$'63, $+%SHULSKHUDO
PHPRU\PDSSHG
UHJLRQDFFHVV )0&
%XVPXWOLSOH[HU 5HJLVWHUV
%XVPDWUL[6 0HPRU\PDSSHGUHJLRQ
)RU670)670)DQG670)OLQHV48$'63,DQG)0&VKDUHWKHVDPH$+%EXVRQWKHEXVPDWUL[
$YDLODEOHRQO\RQ670)OLQHGHYLFHV
86%27*+6LVDYDLODEOHRQO\LQWKH670)DQG670)OLQHV
06Y
'0$'
$UP&RUWH[0
'0$
'0$
86%
/'7&
0$&
*3
*3
/FDFKH '7&05$0
,7&05$0
'0$B0(0
'0$B0(0
'0$B3
$;,0 $+%3
'0$B3
$;,WRPXWL$+%
$3%
$3%
$57
)ODVK
PHPRU\
ELW$+%
ELWEXVPDWUL[ 0DVWHUVDFFHVVLQJ
48$'63,
65$0
48$'63,LQWHUIDFH
65$0
ELW$+%EXV
$+%SHULSKHUDO
ELW$+%EXV
$+%SHULSKHUDO
)0& 48$'63,UHJLVWHUV
DFFHVV
5HJLVWHUV
0HPRU\PDSSHGUHJLRQ 48$'63,
PHPRU\PDSSHG
UHJLRQDFFHVV
ELWEXVPDWUL[6
%XVPXWOLSOH[HU
0DF(WKHUQHW/&'7)7DQG'0$'DUHQRWDYDLODEOHRQ670)[[[DQG670)[[[GHYLFHV 06Y
$+%6
6'00&
86%+6
86%+6
(WKHUQHW
0$&
&RUWH[0 ,7&0
' '0$ '0$
,
'7&0 '0$B3(5,3+
'0$B3(5,3+
$+%3
'0$B0(0
'0$B0(0
$3% 65$0
5HJLVWHUV
$+% 65$0
)/$6+$ 65$0
)/$6+% $+%
$;,65$0 $+%
0HPRU\PDSSHGUHJLRQ $3%
)0& $3%
ELW$;,EXVPDWUL[
'WR'$+%
'GRPDLQ
ELW$+%EXVPDWUL[
'WR'$+% 'GRPDLQ
'WR'$+%
%'0$
48$'63,LQWHUIDFH 0'0$
0DVWHUVQRWKDYLQJ 0DVWHUVDFFHVVLQJ
DFFHVVWR48$'63, 48$'63,
$+% $3%
$;, 48$'63,UHJLVWHUVDFFHVV
$+%
65$0
48$'63,PHPRU\PDSSHGUHJLRQDFFHVV
$3%
7&0
ELW$+%EXVPDWUL[
ELWEXVZLGWK ELWEXVZLGWK 'GRPDLQ %DFNXS65$0
%XVPXWOLSOH[HU
0DF(WKHUQHW/&'7)7DQG'0$'DUHQRWDYDLODEOHRQ670)[DQG670)[GHYLFHV 06Y9
&38 &38
'0$
'0$
$UP&RUWH[0 $UP&RUWH[0
'EXV
,EXV
6EXV
,&RGH
'&RGH &), )ODVK
6&RGH DUELWHU PHPRU\
65$0
65$0
$+%SHULSKHUDO
$+%SHULSKHUDO
5HJLVWHUV
0HPRU\PDSSHGUHJLRQ
$+%
$+%
%XVPDWUL[
ELW$+%EXV
48$'63,LQWHUIDFH
48$'63,UHJLVWHUVDFFHVV
0DVWHUVQRWKDYLQJDFFHVVWR
48$'63,PHPRU\PDSSHGUHJLRQDFFHVV 48$'63,
%XVPXWOLSOH[HU 0DVWHUVDFFHVVLQJ48$'63,
:KHQUHPDSSHG 06Y9
Ŷ^
^><
/K Ϭ ϰ Ϭ ϰ Ϭ ϰ Ϭ ϰ Ϭ ϰ Ϭ ϰ Ϭ ϰ Ϭ
/K ϭ ϱ ϭ ϱ ϭ ϱ ϭ ϱ ϭ ϱ ϭ ϱ ϭ ϱ ϭ
/K Ϯ ϲ Ϯ ϲ Ϯ ϲ Ϯ ϲ Ϯ ϲ Ϯ ϲ Ϯ ϲ Ϯ
/K ϯ ϳ ϯ ϳ ϯ ϳ ϯ ϳ ϯ ϳ ϯ ϳ ϯ ϳ ϯ
ϮϯͲϭϲ ϭϱͲϴ ϳͲϬ DϳͲϬ LJƚĞϭ LJƚĞϮ
2QO\F\FOHV
FRPPDQG /KƐǁŝƚĐŚĨƌŽŵ
ŽƵƚƉƵƚƚŽŝŶƉƵƚ
06Y9
Ŷ^
><
Instruction on 1 <ϭͺ/KϬ ϳ ϲ ϱ ϰ ϯ Ϯ ϭ Ϭ ŽƵƚƉƵƚ
line: Single SPI IMODE[1:0] = 01
mode <ϭͺ/Kϭ ,ŝŐŚͲ
<ϭͺ/KϮ ,ŝŐŚͲ
<ϭͺ/Kϯ ,ŝŐŚͲ
06Y9
Ŷ^
<ϭͺ/KϮ ,ŝŐŚͲ
<ϭͺ/Kϯ ,ŝŐŚͲ
06Y9
Ŷ^
><
Instruction on 4
<ϭͺ/KϬ ϰ Ϭ KƵƚƉƵƚ
lines: Quad-SPI IMODE[1:0] = 11
mode <ϭͺ/Kϭ ϱ ϭ KƵƚƉƵƚ
<ϭͺ/KϮ ϲ Ϯ KƵƚƉƵƚ
Address is given
directly via the AHB
Address to be sent QUADSPI_AR[31:0] ADDRESS[31:0] from any master on
the bus matrix like
Cortex® or DMA
1-byte ADSIZE[1:0] =00
Note: In Dual-Flash memory mode when DFM = 1 the address to be sent to Flash1 is exactly the
same address to be sent to Flash2.
Depending on the software and the hardware configurations, the alternate byte can be sent
over one, two or four lines. If not needed, the alternate-byte phase can be skipped.
The table below summarizes different alternate-byte phase configurations.
Note: In Dual-Flash memory mode when DFM = 1, the alternate-byte to be sent to Flash1 is
exactly the same as the ones to be sent to Flash2.
ůƚĞƌŶĂƚĞͲďLJƚĞ
Ŷ^
1LEEOHWREHVHQW
><
<ϭͺ/KϬ Ϭ Ϭ KƵƚƉƵƚ
<ϭͺ/Kϭ Ϭ ϭ KƵƚƉƵƚ
<ϭͺ/KϮ Ϭ Ϭ ŶtW
<ϭͺ/Kϯ ϭ ϭ Ŷ,K>
06Y9
Figure 8. Dummy-cycle: IO2 maintained low and IO3 maintained high by hardware
ϮƵŵŵLJ ĐLJĐůĞƐ
Ŷ^
><
<ϭͺ/KϬ ,ŝŐŚͲ
<ϭͺ/Kϭ ,ŝŐŚͲ
<ϭͺ/KϮ Ϭ ŶtW
<ϭͺ/Kϯ ϭ Ŷ,K>
06Y9
Depending on the software and the hardware configurations, the data transfer can be done
in one, two or four lines. In some use cases where data is not needed such as erasing
operation, the data phase can be skipped.
The following table summarizes the data phase configuration in different functional modes.
CLK
Bank1 Bank2 BK1_IO0/SO
CLK CLK BK1_IO1/SI
Single/Dual SPI Used GPIOs BK1_IO0/SO BK2_IO0/SO BK2_IO0/SO
mode BK1_IO1/SI BK2_IO1/SI BK2_IO1/SI
BK1_nCS BK2_nCS BK1_nCS(1)
BK2_nCS(1)
GPIOs number 4 GPIOs 6 or 7 GPIOs
CLK
BK1_IO0/SO
Bank1 Bank2 BK1_IO1/SI
CLK CLK BK1_IO2
BK1_IO0/SO BK2_IO0/SO BK1_IO3
Used GPIOs BK1_IO1/SI BK2_IO1/SI BK2_IO0/SO
Quad-SPI mode
BK1_IO2 BK2_IO2 BK2_IO1/SI
BK1_IO3 BK2_IO3 BK2_IO2
BK1_nCS BK2_nCS BK2_IO3
BK1_nCS(1)
BK2_nCS(1)
GPIOs number 6 GPIOs 10 or 11 GPIOs
1. In Dual-Flash mode it is possible to use one chip select, either BK1_nCS or BK2_nCS. For more details on
dual-flash mode, refer to Section 2.2.4: Dual-Flash memory mode on page 25.
Note: If none of the phases are configured to use Quad-SPI mode, then the GPIOs corresponding
to IO2 and IO3 can be used for other functions even while QUADSPI is active.
&RQWURO
&/. &/. )ODVK FRPPXQLFDWLRQOLQHV
06Y9
%.B,26, 462
4XDG63, %.B,2 4Q:3
&RPPXQLFDWLRQOLQHV
%.BQ&6 Q&6
06Y9
%.BQ&6 Q&6
06Y9
The following figure shows an example of a read sequence in Dual-Flash memory Quad I/O
SDR mode.
Figure 12. Read sequence in dual-Flash memory Quad I/O SDR mode
Ŷ^ͺ<ϭ
Ŷ^ͺ<Ϯ
^><
<ϭͺ/KϬ ϰ Ϭ ϮϬ ϭϲ ϭϮ ϴ ϰ Ϭ ϰ Ϭ ϰ Ϭ ϰ Ϭ
)ODVK
<ϭͺ/Kϭ ϱ ϭ Ϯϭ ϭϳ ϭϯ ϵ ϱ ϭ ϱ ϭ ϱ ϭ ϱ ϭ
%\WHVDWHYHQ
DGGUHVV LJƚĞϭ LJƚĞϯ
<ϭͺ/KϮ ϲ Ϯ ϮϮ ϭϴ ϭϰ ϭϬ ϲ Ϯ ϲ Ϯ Ϯ Ϯ
ϲ ϲ
<ϭͺ/Kϯ ϳ ϯ Ϯϯ ϭϵ ϭϱ ϭϭ ϳ ϯ ϳ ϯ ϳ ϯ ϳ ϯ
<Ϯͺ/KϬ ϰ Ϭ ϮϬ ϭϲ ϭϮ ϴ ϰ Ϭ ϰ Ϭ ϰ Ϭ ϰ Ϭ
<Ϯͺ/Kϭ ϱ ϭ ϱ ϭ ϭ ϱ ϭ
)ODVK
Ϯϭ ϭϳ ϭϯ ϵ ϱ ϭ ϱ
%\WHVDWRGG
LJƚĞϮ LJƚĞϰ
DGGUHVV
<Ϯͺ/KϮ ϲ Ϯ ϮϮ ϭϴ ϭϰ ϭϬ ϲ Ϯ ϲ Ϯ ϲ Ϯ ϲ Ϯ
<Ϯͺ/Kϯ ϳ ϯ Ϯϯ ϭϵ ϭϱ ϭϭ ϳ ϯ ϳ ϯ ϳ ϯ ϳ ϯ
/KƐǁŝƚĐŚĨƌŽŵ
ŽƵƚƉƵƚƚŽŝŶƉƵƚ
06Y9
Note that all bytes at even addresses are stored in Flash 1 while all bytes at odd addresses
are stored in Flash 2. As described in Figure 12, in dual-Flash mode the same command,
address and alternate are sent to both Flash 1 and Flash 2. For example to read the first
four bytes in dual-Flash memory-mapped mode from 0x90000 000 to 0x9000 0003 the
following sequence is done by QUADSPI peripheral:
• The address 0x0000 0000 is sent to both Flashes and Byte 1 (at even address
0x9000 0000) is read from Flash 1 while Byte 2 (at odd address 0x9000 0001) is read
from Flash 2.
• Then the address 0x0000 0001 is sent to both Flashes and Byte 3 (at even address
0x9000 0002) is read from Flash 1 while Byte 2 (at odd address 0x9000 0003) is read
from Flash 2.
Cautions:
• In Dual-Flash memory mode both device models must be identical, because in this
mode the same commands and addresses are issued in parallel to both Flash
memories; this permits to double the available QUADSPI external Flash size. In the
case that the two Flash-memory devices are different, the Dual-Flash mode must be
disabled (DFM = 0) and each Flash memory could be used in standalone, allowing
either Flash 1 or Flash 2 to be enabled using QUADSPI_CR[7] FSEL bit.
• For all hardware configurations listed in the table below, each memory device is
configured in Quad-SPI mode. It is possible to connect each device in Single or Dual-
SPI mode. If DFM = 1, both devices must be configured in the same way. This permits
to double the available external data size and throughput.
• The Flash memory size, as specified in FSIZE[4:0] (QUADSPI_DCR[20:16]) should
reflect the total Flash memory capacity, which is the double of the size of one individual
component.
FSEL = 0
Flash 1 &/. &/. )ODVK
enabled %.B,262 46,
Single Flash
DFM = 0(1) FSEL = 1
%.B,26, 462
%.B,2 4Q:3
Flash 2
4 Q+2/'
Both nCS_BK1 enabled %.B,2
06Y9
%.B,26, 462
%.B,2 4Q:3
nCS_BK1 %.BQ&6
Dual-Flash memory DFM Q&6
connected to 48$'63,
=1
both devices &/. )ODVK
%.B,262 46,
%.B,26, 462
%.B,2 4Q:3
%.B,2 4 Q+2/'
Q&6
06Y9
1 nCS
enabled
&/. &/. )ODVK
%.B,262 46,
%.B,26, 462
%.B,2 4Q:3
nCS_BK2 Q&6
Dual-Flash memory DFM
connected to 48$'63,
=1
both devices &/. )ODVK
%.B,262 46,
%.B,26, 462
%.B,2 4Q:3
%.B,2 4 Q+2/'
%.BQ&6 Q&6
06Y9
1. When single-Flash memory mode is selected DFM = 0, the user can switch between Flash 1 or Flash 2 using FSEL bit.
Pink lines highlight the used chip select.
Q&6
&RPPDQG $GGUHVV 'XPP\ %\WH %\WH « %\WH1 &RPPDQG $GGUHVV 'XPP\ %\WH %\WH «
06Y9
Figure 14. Executing non-sequential code from QUADSPI with SIOO enabled
Q&6
06Y9
The SIOO feature is supported by many QSPI memory manufacturers such as Micron,
Spansion and Macronix, nevertheless before using it, the user has to check if the feature is
supported by the used memory.
To enable the SIOO mode, the user should:
• Configure the memory by entering the SIOO mode. Refer to relevant manufacturer’s
datasheet for more details on how to enter this mode (make sure that the read
command to be used does support this mode). Note that an alternate byte (mode Bits)
needs to be sent in order to keep the device in this mode. Refer to SIOO example on
Section 5.2 on page 67 for more details on enabling this feature.
• Configure the QUADSPI peripheral by setting the SIOO bit in QUADSPI_CCR register.
For more details on QUADSPI timing characteristics refer to the relevant products
datasheet.
The following table summarizes different cases when the BUSY bit is reset in different
QUADSPI operating modes:
– The QUADSPI has completed the requested command sequence and the
Indirect mode FIFO is empty
– Due to an abort
Automatic-polling – After the last periodic access is complete, due to a match when APMS =1
mode – Due to an abort
– On a timeout event
Memory-mapped
– Due to an abort
mode
– QUADSPI peripheral is disabled
ABORT bit
When an application is running, any ongoing QUADSPI operation can be aborted by setting
the ABORT bit in the QUADSPI_CR register. Once the abort is completed, the BUSY bit and
the ABORT bit are automatically reset and the FIFO is flushed. If an abort occurs on an
ongoing AXI/AHB burst operation, the QUADSPI allows the ongoing burst to complete
properly before reseting the BUSY bit and the ABORT bit.
Note: Some Flash memories might misbehave if a write operation to a status registers is aborted.
48$'63,
'/<%
GO\EBRXWBFN GO\EBLQBFN
5HJLVWHUVDFFHVV
RYHU$+%
GO\EBLQBFNGHOD\EORFNLQSXWFORFN
GO\EBRXWBFNGHOD\EORFNRXWSXWFORFN 06Y9
In indirect mode when configuring the DMA for data transfer from/to the QUADSPI, the
QUADSPI should be considered as a peripheral:
• Memory to peripheral mode in case of writing data to the QUADSPI from the internal
memory
• Peripheral to memory mode in case of reading data from the QUADSPI to be
transfered into the internal memory.
Also the address of the QUADSPI should be written into the peripheral address register
(DMA channel/stream x peripheral address).
The table below summarizes the different DMA requests and transfer directions versus the
STM32 series.
Table 14. DMA requests mapping and transfer directions versus STM32 series
Product (1) DMA1 DMA2 MDMA
Request 5 Request 3
STM32L4 Series NA
Channel 5 Channel 7
Stream 7
STM32F4 Series NA NA
Channel 3
Stream 7
STM32F7 Series NA NA
Channel 3
quadspi_ft_trg
NA NA channel
X[0..15]/Stream22
STM32H7 Series
quadspi_tc_trg
NA NA channel
X[0..15]/Stream23
1. For applicable devices of each series embedding a QUADSPI.
The DMAEN bit has no effect in Memory-mapped mode, the transfer is started as soon as
the DMA is accessing the QUADSPI address range (from 0x9000 0000 to 0x9FFF FFFF).
Once the DMA configured transfer is started by software, the DMA reads the data from the
QSPI memory exactly as an internal memory. The QUADSPI peripheral manages the
communication with the external memory and puts the read data in the FIFO.
The number of data items to be transferred is managed by the DMA so the user should
configure the number of data in the DMA’s register DMA_SxNDTR (or DMA_CNDTRx
register for STM32L4x6xx). There is no need to configure the QUADSPI_DLR register as it
has no effect in the Memory-mapped mode where the DMA is the flow controller.
Note: The DMA’s FIFO can be used for example if the DMA Burst mode is required to reduce the
transfer overhead on the bus matrix.
,7&0
&RUWH[0
, '
'7&0
0DVWHUVDFFHVVLQJ
48$'63,
0'0$ 6ODYHV
48$'63,
QUADSPI?FT?TRG UHJLVWHUVDFFHVV
#HANNEL 8;=3TREAM
QUADSPI?TC?TRG 48$'63,
#HANNEL 8;=3TREAM PHPRU\PDSSHG
UHJLRQDFFHVV
ELWEXVZLGWK
ELW$+%6
ELW$;,PDVWHUEXV ELWEXVZLGWK
$;,
BIT !(" 15!$30) REGISTERS ACCESS $+%
7&0
BIT !8) 15!$30) MEMORY MAPPED ACCESS
06YY
3 QUADSPI configuration
This section describes all QUADSPI configuration steps required to perform either read,
write or erase operations.
06Y9
If after selecting one hardware configuration (as shown in Figure 17) the used GPIOs does
not match with the memory connection board, the user can configure the alternate function
directly on the corresponding pins.
For more details on QUADSPI alternate functions availability versus GPIOs, refer to the
alternate function mapping table in the relevant datasheet.
The figure below shows how to configure manually a PF8 pin to QUADSPI_BK1_IO0
alternate function.
The used pins are highlighted in green once the GPIOs of the QUADSPI interface are
correctly configured.
D^ǀϲϭϭϵϬsϭ
06Y9
06Y9
In the STM32H7 Series devices the QUADSPI contains two different source clocks:
• quadspi_ker_ck
It is the source clock to generate QUADSPI CLK using the following relation
(QSPI_CLK=quadspi_ker_ck/(Prescaler + 1).
• quadspi_hclk (hclk3)
It is the source clock for the register interface. This clock has no impact on the
QUADSPI CLK.
STM32CubeMx permits the configuration of quadspi_ker_ck source clock in the clock
configuration section.
The following figure shows the multiple source clocks for quadspi_ker_ck using
STM32CubeMx.
06Y9
The source clock for quadspi_ker_ck can be selected by using the QUADSPI clock mux as
shown in the following figure.
06Y9
48$'63,B&5
48$'63,B'&5
48$'63,B&5
06Y9
3.3.4 CKMODE
The clock mode indicates the level that CLK takes between commands when nCS is high.
Two modes are supported when nCS is high: mode 0 where CLK stays low and mode 3
where CLK stays high.
Figure 27. Chip select high time: CSHT = two clock cycles
&6+7
Ŷ^
^>< &/.02'(
<ϭͺ/KϬ ϳ ϲ ϱ ϰ ϯ Ϯ ϭ Ϭ ϳ ϲ ϱ ϰ ϯ Ϯ ϭ Ϭ
<ϭͺ/Kϭ
<ϭͺ/KϮ
<ϭͺ/Kϯ
&RPPDQGQ &RPPDQGQ
06Y9
DŽĚĞϬ^><
DŽĚĞϯ^><
Ŷ^
^/ D^
^K D^
06Y9
This section describes how to program a QSPI Flash memory in the following use cases:
• For an end application development: in this case the QSPI memory is programmed
during the development of the product with static data or code to be used in the final
product. A dedicated Flash memory loader is needed in order to place the data or the
code to be used in the application. The Flash loaders provided by ST can be used for
programming if the user is using one of the ST EVAL or Discovery boards, otherwise
the user should develop its own Flash memory loader.
• On-the-fly when application is running: in this case the QSPI Flash memory is used
in a final product as an external mass-storage device, this permits the application to
store data any time that it is needed.
Note: For both cases the programming principle is the same. The only difference is that in the first
case, the programming operation is performed with a tool and a Flash memory loader during
the application’s development, while in the second case the programming operation is
performed during a running application in a final product. Only the Indirect mode should be
used for programming regardless if it is a writing or an erasing operation.
Depending on the used Flash memory brand, different programming commands are
available, so it is up to the user to configure the desired command supported by the device.
The instruction, address and data phases can be sent in one, two or four lines for command
phase depending on the device brand.
The 4-byte address mode can be used to program the QSPI Flashes with sizes up to
4 Gbytes.
The Automatic-polling mode can be used for waiting while the programming operation is
ongoing; when the operation is completed an interrupt can be generated.
%,1
+(;
48$'63,
463, 'HEXJ
670
IODVK 67/LQN
06Y9
4.1.1 Programming QSPI Flash memory using the STM32 ST-LINK utility
When the used IDE is not supporting the QSPI memory programming capability such as
System Workbench for STM32, the user can simply use the STM32 ST-LINK utility tool.
How to create a new QSPI Flash memory loader and add it to the ST-LINK
utility
For each hardware configuration and for each QSPI Flash memory brand, a dedicated
Flash memory loader should be developed. The user has to develop its own dedicated
Flash memory loader (.stldr file) if the hardware used is other than ST boards.
A project is provided in the ST-LINK utility install directory “STMicroelectronics\STM32 ST-
LINK Utility\ST-LINK Utility\ExternalLoader\N25Q256A_STM32L476G-EVAL_Cube”
allowing the user to develop an external loader for a N25Q256A Flash memory on the
STM32L476G-EVAL board. This project can be easily tailored to the user dedicated
hardware to generate the external loader.
For more details on how to develop an external QSPI Flash memory loader for the STM32
ST-LINK utility, refer to the user manual STM32 ST-LINK Utility software description
(UM0892), section “Developing custom loaders for external memory” available at
www.st.com.
Caution: The tool chain/compiler used to generate the HEX/BIN file to program the QSPI memory
must be exactly the same as the one used for the application development.
The dedicated Flash-memory loader has to be added to the ST-LINK utility in order to be
able to program a QSPI Flash memory.
Figure 30. STM32 ST-LINK utility: adding QSPI Flash memory loader
A window appears where the user should select their device. See an example below:
Figure 31. STM32 ST-LINK utility: selecting QSPI Flash memory loader
Note: Only one external loader can be added, otherwise the error message in the figure below
appears. The user can remove one external loader and replace it with another one if
needed.
3. The following window appears allowing the user to browse to the data file to be stored
in the Flash memory, which can be a binary file, an HEX file or Motorola S-record files
(.srec or .s19).
Figure 34. STM32 ST-LINK utility: selecting HEX file for programming
Figure 36. Adding QSPI Flash memory loader to Keil MDK-ARM project
The QSPI Flash memory loader is then added in the following window.
Figure 37. Adding QSPI Flash memory loader to Keil MDK-ARM project
In the following window, select from the list the corresponding Flash memory loader:
Once the corresponding Flash memory loader is added it appears in the programming
algorithm list as shown in the figure below.
Once the QSPI Flash memory loader is added, programming can be done by clicking on the
Load button or pressing the F8 key on the keyboard.
Note: The region to be programmed is defined by default in the external loader and can be
changed by changing the start address and the size fields.
The following figure shows an example of a page programming sequence where the page
size is 256 bytes.
Note: Data byte 1 is written first to the data register QUADSPI_DR then data byte 256 is the last.
When writing a 32-bit word to QUADSPI_DR register, note that the LSB byte is written first
to the FIFO then transmitted first.
Either CPU with interrupts or DMA can be used for programming QSPI memory as follow.
1. Programming QSPI memory using Indirect-write mode
When using Indirect-write mode, all programming operations are handled by software by
writing directly to the QUADSPI_DR register. An interrupt is generated when a transfer
complete is identified or if FIFO threshold is reached.
2. Programming QSPI memory using Indirect-write mode with DMA
It is generally recommended to use DMA to program the QSPI memory using Indirect-write
mode since it offloads the CPU, nevertheless the final recommendation depends on the
user application. In some cases, where the amount of data to be written to the memory is
relatively small, there is no need to use DMA. Once the DMA is configured and the
programming operation has started, no intervention from the CPU is needed and the
operation ends autonomously. For more details on DMA usage, refer to Section 2.5.2: DMA
usage.
3. Usage of Status-polling mode
The user can use this mode to poll the memory status register. The figure below shows an
example of a status-register reading sequence.
Sector-erase sequence
To erase a sector on the memory, a sector-erase command and a starting sector address
should be sent.
Example: to perform a sector-erase operation on the MICRON N25Q512A memory, the
QUADSPI_CCR register should be configured as below:
QUADSPI->CCR = 0x000025D8; /* Instruction= 0xD8; IMODE = 0x01; ADMODE=
0x01; ADSIZE = 0x02 */
QUADSPI->AR = 0x00000000; /* Address 0x00000000 is sent to erase the first
sector */
See below an example of a sector-erasing sequence:
This section provides some typical QUADSPI use case examples showing how to use the
interface in Indirect-mode, Status-flag polling mode and Memory-mapped mode.
Some of these examples are provided in the STM32Cube firmware package while others
are based on other application notes also available on the ST website. Some hardware
implementation examples are provided as well at the end of this section.
This section describes the following use cases:
• Memory-mapped mode: reading data in a graphical application
• Memory-mapped mode: executing code from the QSPI Flash memory
• Indirect mode: storing data on-the-fly during a running application
• Indirect mode: erasing data
• Hardware implementation example
/&'7)7
5*%
/7'&
6'5$0
IUDPHEXIIHU
&KURP$57
)0&
'0$'
4XDG63,
0%463,)ODVK
&KURP$57'0$'EXLOGLQJIUDPHEXIIHUFRQWHQW
/7'&GLVSOD\LQJLPDJHVRQWKH/&'
06Y9
As explained in Section 4.1.2: Programming QSPI Flash memory using IDE, to program the
QSPI memory using Keil MDK-ARM or IAR EWARM, a dedicated section for all the data to
be programmed should be created.
Following the QUADSPI section “.textqspi” in the Keil MDK-ARM scatter file:
LR_IROM2 0x90000000 0xFFFFFFF { ; load region size_region
ER_IROM2 0x90000000 0xFFFFFFF { ; load address = execution address
*.o (.textqspi)
}
}
To program data to QSPI Flash, the user should first check if the QSPI Flash loader is
added to the project (Keil MDK-ARM or IAR EWARM). If it is already added, the user can
simply build the project and program the memory. For more details on project configuration
refer to the readme file in the project directory.
Figure 45. DMA2D reading images from Quad-SPI to build frame buffer content
'7&0
,7&0
$+%6
27*+6
(WKHUQHW
'0$'
$UP&RUWH[0
'0$
'0$
86%
/'7&
0$&
*3
*3
/FDFKH '7&05$0
,7&05$0
'0$B0(0
'0$B0(0
'0$B3
$;,0 $+%3
'0$B3
$;,WRPXWL$+%
$3%
,7&0
$3%
0DVWHUVDFFHVVLQJ
48$'63,
$57
6ODYHV
)ODVK
PHPRU\ 48$'63,LQWHUIDFH
ELW$+%
ELW$+%EXV
ELWEXVPDWUL[
ELW$+%EXV
65$0 48$'63,UHJLVWHUV
DFFHVV
65$0 48$'63,PHPRU\
$+%SHULSKHUDO PDSSHGUHJLRQDFFHVV
%XVPXWOLSOH[HU
$+%SHULSKHUDO
/7'&IHWFKHVGDWDIURP
)0& IUDPHEXIIHUWRGLVSOD\LW
RQWKH/&'
5HJLVWHUV '0$'WUDQVIHUVGDWD
IURP463,PHPRU\WR
0HPRU\PDSSHGUHJLRQ 6'5$0
,QSDUDOOHO&38IHWFKHV
ELWEXVPDWUL[6 LQVWUXFWLRQVIURP)ODVK
$;,0
0DF(WKHUQHW/&'7)7DQG'0$'DUHQRWDYDLODEOHRQ670)[[[DQG670)[[[GHYLFHV 06Y9
48$'63,LQWHUIDFH
'0$'
'7&05$0
/7'&
$UP&RUWH[0
/FDFKH ,7&05$0 6ODYH
$;,0 ELW$+%EXV
$57
)ODVK
$;,WRPXWL$+% /7'&UHDGLQJ
PHPRU\ LPDJHIURP463,
PHPRU\
65$0 48$'63,UHJLVWHUV
DFFHVV
5HJLVWHUV 48$'63,
PHPRU\PDSSHG
0HPRU\PDSSHGUHJLRQ UHJLRQDFFHVV
%XVPXWOLSOH[HU
ELWEXVPDWUL[6
06Y9
Once the QUADSPI is configured, to display the image stored in the QSPI memory, the
following API is called in the LCDConf.c file: HAL_LTDC_ConfigLayer(&hltdc_F,
&pLayerCfg, 0).
pLayerCfg is the pointer to a LTDC_LayerCfgTypeDef structure that contains the address of
the image in the QSPI memory.
Figure 47. Project configurations: executing code from QSPI Flash memory
Projects configuration
For both project configurations, 6_1-QuadSPI_rwRAM-DTCM and 6_2-QuadSPI_rwRAM-
DTCM, the user can change the desired QUADSPI settings in the Options for Target box as
shown in the next figure.
Note that the operating system clock during system initialization is 16 MHz, so at this
moment the QSPI_CLK = fAHB/1 = 16 MHz (by default the prescaler = 0). Once the system
initialization is done, the CPU jumps to the main function (in arm_fft_bin_example_f32.c file)
where the system clock configuration is performed. The system clock is configured to run at
216 MHz.
Both project configurations have the following QUADSPI settings:
• QSPI_CLOCK_PRESCALER = 3
• System clock is 216 MHz => QSPI_CLK = 54 MHz
• QSPI_DDRMODE => DDR mode enabled
• QSPI_INSTRUCTION_1_LINE => instruction is issued in one line
• QSPI_XIP_MODE => execute in place with SIOO enabled.
GPIOs configuration
As shown in the following figure, the QSPI Flash memory is connected in Quad I/O mode,
so six GPIOs have to be configured for the QUADSPI interface.
/* Connect PF6, PF7, PF8 and PF9 pins to Quad-SPI Alternate function */
GPIOF->AFR[0] |= 0x99000000;
GPIOF->AFR[1] |= 0x000000AA;
/* Configure PFx pins in Alternate function mode */
GPIOF->MODER |= 0x000AA000;
/* Configure PFx pins speed to 100 MHz */
GPIOF->OSPEEDR |= 0x000FF000;
/* Configure PFx pins Output type to push-pull */
GPIOF->OTYPER = 0x00000000;
/* No pull-up, no pull-down for PFx pins */
GPIOF->PUPDR = 0x00000000;
'7&0
,7&0
$+%6
27*+6
(WKHUQHW
'0$'
$UP&RUWH[0
'0$
'0$
86%
/'7&
0$&
*3
*3
/FDFKH '7&05$0
,7&05$0
'0$B0(0
'0$B0(0
'0$B3
$;,0 $+%3
$;,WRPXWL$+%
,7&0
0DVWHUVDFFHVVLQJ
48$'63,
$OOUHPDLQLQJSURMHFW¶V
$57 FRGHGDWD 6ODYHV
48$'63,LQWHUIDFH
)ODVK
PHPRU\ ELW$+%EXV
ELW$+%
ELWEXVPDWUL[ ELW$+%EXV
48$'63,UHJLVWHUV
65$0 DFFHVV
48$'63,PHPRU\
463,)ODVK
PDSSHGUHJLRQDFFHVV
%XVPXWOLSOH[HU
$SSOLFDWLRQ¶VFRGH
FRQVWDQWGDWD &RGHH[HFXWLRQIURP
48$'63,ZLWK/&DFKH
5HJLVWHUV =,5:6WDFN+HDS
LQ'7&0
0HPRU\PDSSHGUHJLRQ
\ SS J
)ODVK,7&0$57RQ
ELWEXVPDWUL[6
06Y9
To place code and constant data in the QSPI memory a dedicated load region has to be
created as shown in the following Keil MDK-ARM scatter file:
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x00200000 0x00100000 { ; load region size_region
ER_IROM1 0x00200000 0x00100000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
; Place all remaining code and const data in Flash TCM.
.ANY (+RO)
}
}
Code placed in QSPI memory while constant data in Flash memory ITCM:
6_2-Quad-SPI_rwRAM-DTCM
In this project configuration, the application code is placed in the QSPI memory while its
related constant data is placed in the Flash ITCM. The Cortex®-M7 have to fetch code from
the QSPI memory and data from the Flash ITCM.
All remaining project codes as the peripheral drivers and the vector tables are placed in the
Flash memory ITCM. The figure below describes the 6_2-Quad-SPI_rwRAM-DTCM project
configuration.
27*+6
(WKHUQHW
'0$'
$UP&RUWH[0
'0$
'0$
86%
/'7&
0$&
*3
*3
/FDFKH '7&05$0
,7&05$0
'0$B0(0
'0$B0(0
'0$B3
$;,0 $+%3
$;,WRPXWL$+%
$OOUHPDLQLQJ
,7&0
0DVWHUVDFFHVVLQJ
SURMHFW¶VFRGHGDWD
48$'63,
$SSOLFDWLRQ¶V
FRQVWDQWGDWD 6ODYHV
$57
48$'63,LQWHUIDFH
)ODVK
PHPRU\ ELW$+%EXV
ELW$+%
ELWEXVPDWUL[ ELW$+%EXV
48$'63,UHJLVWHUV
65$0 DFFHVV
48$'63,PHPRU\
463,)ODVK
PDSSHGUHJLRQDFFHVV
%XVPXWOLSOH[HU
$SSOLFDWLRQ¶VFRGH &RGHH[HFXWLRQIURP
48$'63,ZLWK/&DFKH
5HJLVWHUV =,5:6WDFN+HDS
LQ'7&0
0HPRU\PDSSHGUHJLRQ
\ SS J
)ODVK,7&0$57RQ
ELWEXVPDWUL[6
06Y9
To place code and constant data in the QSPI memory a dedicated load region has to be
created as shown in the following Keil MDK-ARM scatter file:
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
Performances analysis
The results are obtained with the STM32756G-EVAL, the CPU is running at 216 MHz,
VDD=3.3 V and with seven wait-states access to the internal Flash memory. The QUADSPI
is configured in DDR 1-4-4 mode with SIOO enabled and QSPI_CLK = 54 MHz.
The table below shows the obtained results for FFT demonstration for MDK-ARM in each
configuration.
- 5-RAMITCM_rwRAM-DTCM 112428
I-cache + D-cache ON (constant data in QSPI memory) 6_1-Quad-SPI_rwRAM-DTCM 171056
I-cache + ART + ART-PF ON (constant data in Flash TCM) 6_2-Quad-SPI_rwRAM-DTCM 126900
1. The number of cycles may change from a version to another of the tool chain.
If the results of the case one and the case two of the “6-Quad SPI_rwRAM-DTCM”
configuration are compared, we note that there is a significant difference in terms of
performance since the demonstration uses a huge constant data.
• For the case one (6_1-Quad SPI_rwRAM-DTCM), since the read-only data and the
instructions are both located in the QSPI Flash memory, a latency occurs due to the
concurrency access of the instruction fetch and the read-only data on the QUADSPI
interface.
• For the case two (6_2-Quad SPI_rwRAM-DTCM), the read-only data and code are
separated. The read-only data is located in Flash-TCM, therefore, the concurrency of
the read-only data and the instruction fetch is avoided and the CPU can fetch the
instruction from AXI while the data is loaded from TCM at the same time. This is the
reason why the performance of the second case is clearly better than the first one.
By comparing the case 6_2-Quad-QPI_rwRAM-DTCM with the 5-RAMITCM_rwRAM-DTCM
(which gives the best performances at 112428 CPU cycles as per AN4667 document), it is
seen that it is they are close in terms of performances.
This is an example of how important it is to benefit from the STM32F7x5/F7x6 smart
architecture (in this example) in order to improve the execution performances from the
external QSPI memory. For more details on how to improve the execution performances
from QSPI memory, refer to Section 6.1: How to get the best performances.
As described in the figure below, the DMA reads the data “aTxBuffer” from the SRAM and
writes it to the QSPI memory, in the meanwhile the CPU can execute code from the internal
Flash.
Figure 52. Indirect write mode: programming QSPI memory using DMA
'7&0
,7&0
$+%6
27*+6
(WKHUQHW
'0$'
$UP&RUWH[0
'0$
'0$
86%
/'7&
0$&
*3
*3
/FDFKH '7&05$0
,7&05$0
'0$B0(0
'0$B0(0
'0$B3
$;,0 $+%3
'0$B3
$;,WRPXWL$+%
$3%
$3%
0DVWHUVDFFHVVLQJ
$57
48$'63,
)ODVK
48$'63,LQWHUIDFH
PHPRU\
ELW$+%
ELWEXVPDWUL[ 6ODYH
65$0 ELW$+%EXV
ELW$+%EXV
65$0
'DWDLVWUDQVIHUUHG
$+%SHULSKHUDO IURP65$0E\'0$
$+%SHULSKHUDO WREHZULWWHQWR
463,)ODVK
)0&
48$'63,UHJLVWHUV
5HJLVWHUV DFFHVV
48$'63,
0HPRU\PDSSHGUHJLRQ PHPRU\PDSSHG
UHJLRQDFFHVV
ELWEXVPDWUL[6
%XVPXWOLSOH[HU
06Y9
Figure 53. Indirect write mode: programming QSPI memory using interrupt
'7&0
,7&0
$+%6
27*+6
(WKHUQHW
'0$'
'0$
86%
/'7&
'0$
0$&
$UP&RUWH[0
*3
*3
/FDFKH '7&05$0
,7&05$0
'0$B0(0
'0$B0(0
'0$B3
$;,0 $+%3
'0$B3
$;,WRPXWL$+% $3%
$3%
0DVWHUVDFFHVVLQJ
$57
48$'63,
)ODVK
48$'63,LQWHUIDFH
PHPRU\
ELW$+%
ELWEXVPDWUL[ 6ODYH
65$0 ELW$+%EXV
ELW$+%EXV
65$0
'DWDLVWUDQVIHUUHG
$+%SHULSKHUDO IURP65$0E\'0$
$+%SHULSKHUDO WREHZULWWHQWR
463,)ODVK
)0&
48$'63,UHJLVWHUV
5HJLVWHUV DFFHVV
48$'63,
0HPRU\PDSSHGUHJLRQ PHPRU\PDSSHG
UHJLRQDFFHVV
ELWEXVPDWUL[6
%XVPXWOLSOH[HU
06Y9
All the provided QSPI examples in the STM32Cube firmware package include an erasing
operation example. For the STM32F7x5/F7x6 products EVAL board, the examples are
available in the following STM32Cube directory:
STM32Cube_FW_F7_VX.X.X\Projects\STM32756G_EVAL\Examples\QSPI.
Table 16. Different STM32 boards embedding QSPI Flash memory (continued)
Product families Board QSPI Flash model Size (Mbytes)
STM32F746G-DISCO N25Q128A13EF840E 16
STM32F746
STM32746G-EVAL MT25QL512ABA8ESF-0SIT 64
STM32F750 STM32F7508-DISCO - 16
STM32F756 STM32756G-EVAL N25Q512A13GSF40E 64
STM32F769I-EVAL MT25QL512ABA8ESF-0SIT 64
STM32F769 MT25QL512ABB1EW9
STM32F769I-DISCO 64
/MX25L51245G
STM32F779 STM32F779I-EVAL N25Q512A13GSF40E 64
STM32H743/STM32H753 STM32H7xxI-EVAL MT25TL 01GHBB8ESF-0SIT 128
STM32L476G-EVAL board
The figure below shows an example of how to connect MICRON QSPI Flash memory in
Quad I/O mode on the STM32L476G-EVAL discovery board.
This section presents some recommendations on how to improve performance and how to
decrease power consumption for applications using the QUADSPI interface.
• Use SIOO feature (Continuous read mode) for random and non-sequential accesses
For random and non-sequential accesses, the command overhead increases. As described
in Figure 13, a command and an address are sent to the memory every new read sequence.
In this case, the user should enable the SIOO feature in order to reduce the command
overhead (see Section 2.4.1: Send instruction only-once (SIOO)).
Note: Not all the read commands support the Continuous read mode (Enhance performance
mode) so the user should consider this information when selecting the read command.
Execution performance
To improve the execution performance from the QSPI Flash memory, the user should follow
the previously described read performance recommendations.
Executing from the QSPI memory is generally characterized by its random and non-
sequential accesses. As already mentioned, an important recommendation to boost
execution performance is enabling the SIOO feature.
As seen in Figure 50: 6_1-Quad-SPI_rwRAM-DTCM project configuration: code and data in
QSPI memory, placing both the code and the read-only data in the QSPI memory leads to
concurrency on the QUADSPI interface during execution.
In order to avoid this concurrency, the user can separate the read-only data and the code.
For example, the read-only data can be located in the QSPI memory while the code can be
located in the Flash-TCM. This action permits to avoid the concurrency of the read-only data
and the instruction fetch; therefore, the CPU can fetch the instructions from Flash-TCM
while the data is loaded from the QSPI memory at the same time.
When the application contains huge constants data, the user can separate constants and
code, each one in a dedicated section. If the code section size fit the internal Flash memory
size, the code can be loaded in the internal Flash memory while the constants are loaded in
the QSPI memory.
For the STM32F7x5/F7x6, it is recommended to enable the Cortex®-M7 L1-Cache.
General recommendations
• Use DMA for data transfers in order to offload the CPU.
• Use Flag-status polling mode rather than software flag checking.
• Use Memory-mapped mode to permit any AHB master to access the QSPI memory
without CPU intervention.
To exit DPD mode, the RELEASE FROM DEEP POWERDOWN command (0xAB) should
be sent. The figure below shows the RPD sequence:
Figure 57. Release from deep power-down (RDP) sequence (command AB)
Note: Not all the serial Flash memories support the Deep power-down mode. If the selected
external serial memory does not support the Deep power-down mode, the STM32 may
control an external-power switch through a GPIO to remove the power supply of the external
QSPI Flash memory and to cancel its current consumption.
7 Supported devices
The STM32 QUADSPI interface has a very flexible frame format that permits the following:
• Send up to five phases: instruction – address – alternate byte – dummy – data
• Skip any phase
• Send each phase in one, two or four lines
• Send address in one, two, three or four bytes
• Send one, two, three or four alternate-byte
• Send up to 31 dummy clock cycles.
In addition, STM32 QUADSPI interface permits sending any command, so the user can
program the desired command in the QUADSPI_CCR register in the INSTRUCTION[7:0]
field.
The STM32 QUADSPI interface is fully configurable in terms of frame format and hardware
and it supports most QSPI memory in the market.
There are several suppliers of QUADSPI compatible memories, such as Winbond,
Spansion, Macronix, MICRON (Numonyx), Microchip (SST) and others.
8 Conclusion
The STM32 MCUs provide a very flexible and useful QUADSPI interface, which fits memory
hungry applications at a lower development cost. The QUADSPI avoids the complexity of
design with external parallel Flash memories by reducing the pin count and offering better
performances. This application note demonstrates the STM32 QUADSPI interface
performances and flexibility, which allows lower development costs and faster time to
market.
9 Revision history
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and
improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on
ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order
acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or
the design of Purchasers’ products.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.