31. Flexible static memory controller (FSMC)

This section applies to the whole STM32F20x and STM32F21x only.

31.1 FSMC main features

The FSMC block is able to interface with synchronous and asynchronous memories and 16-bit PC memory cards. Its main purpose is to:

All external memories share the addresses, data and control signals with the controller. Each external device is accessed by means of a unique chip select. The FSMC performs only one access at a time to an external device.

The FSMC has the following main features:

The FSMC registers that define the external device type and associated characteristics are usually set at boot time and do not change until the next reset or power-up. However, it is possible to change the settings at any time.

31.2 Block diagram

The FSMC consists of four main blocks:

The block diagram is shown in Figure 397 .

Figure 397. FSMC block diagram

Figure 397. FSMC block diagram. The diagram shows the internal structure of the FSMC. On the left, an 'AHB bus' connects to 'Configuration registers' and 'NOR/PSRAM memory controller'. A 'From clock controller' provides 'HCLK' to the 'Configuration registers'. An 'FSMC interrupt to NVIC' is shown. The 'NOR/PSRAM memory controller' connects to 'NOR/PSRAM signals' (FSMC_NE[4:1], FSMC_NL(or NADV), FSMC_NBL[1:0], FSMC_CLK). The 'Configuration registers' connect to 'Shared signals' (FSMC_A[25:0], FSMC_D[15:0], FSMC_NOE, FSMC_NWE, FSMC_NWAIT). The 'NAND/PC Card memory controller' connects to 'NAND signals' (FSMC_NCE[3:2], FSMC_INT[3:2]) and 'PC Card signals' (FSMC_INTR, FSMC_NCE4_1, FSMC_NCE4_2, FSMC_NIORD, FSMC_NIOWR, FSMC_NREG, FSMC_CD).
Figure 397. FSMC block diagram. The diagram shows the internal structure of the FSMC. On the left, an 'AHB bus' connects to 'Configuration registers' and 'NOR/PSRAM memory controller'. A 'From clock controller' provides 'HCLK' to the 'Configuration registers'. An 'FSMC interrupt to NVIC' is shown. The 'NOR/PSRAM memory controller' connects to 'NOR/PSRAM signals' (FSMC_NE[4:1], FSMC_NL(or NADV), FSMC_NBL[1:0], FSMC_CLK). The 'Configuration registers' connect to 'Shared signals' (FSMC_A[25:0], FSMC_D[15:0], FSMC_NOE, FSMC_NWE, FSMC_NWAIT). The 'NAND/PC Card memory controller' connects to 'NAND signals' (FSMC_NCE[3:2], FSMC_INT[3:2]) and 'PC Card signals' (FSMC_INTR, FSMC_NCE4_1, FSMC_NCE4_2, FSMC_NIORD, FSMC_NIOWR, FSMC_NREG, FSMC_CD).

31.3 AHB interface

The AHB slave interface enables internal CPUs and other bus master peripherals to access the external static memories.

AHB transactions are translated into the external device protocol. In particular, if the selected external memory is 16 or 8 bits wide, 32-bit wide transactions on the AHB are split into consecutive 16- or 8-bit accesses. The FSMC Chip Select (FSMC_NEx) does not

toggle between consecutive accesses except when performing accesses in mode D with the extended mode enabled.

The FSMC generates an AHB error in the following conditions:

The effect of this AHB error depends on the AHB master which has attempted the R/W access:

The AHB clock (HCLK) is the reference clock for the FSMC.

31.3.1 Supported memories and transactions

General transaction rules

The requested AHB transaction data size can be 8-, 16- or 32-bit wide whereas the accessed external device has a fixed data width. This may lead to inconsistent transfers.

Therefore, some simple transaction rules must be followed:

Configuration registers

The FSMC can be configured using a register set. See Section 31.5.6 , for a detailed description of the NOR flash/PSRAM control registers. See Section 31.6.8 , for a detailed description of the NAND flash/PC Card registers.

31.4 External device address mapping

From the FSMC point of view, the external memory is divided into 4 fixed-size banks of 256 Mbytes each (Refer to Figure 398 ):

For each bank the type of memory to be used is user-defined in the Configuration register.

Figure 398. FSMC memory banks

AddressBanksSupported memory type
6000 0000hBank 1
4 × 64 MB
NOR / PSRAM
6FFF FFFFh
7000 0000hBank 2
4 × 64 MB
NAND Flash
7FFF FFFFh
8000 0000hBank 3
4 × 64 MB
8FFF FFFFh
9000 0000hBank 4
4 × 64 MB
PC Card
9FFF FFFFh

ai14719

31.4.1 NOR/PSRAM address mapping

HADDR[27:26] bits are used to select one of the four memory banks as shown in Table 169 .

Table 169. NOR/PSRAM bank selection

HADDR[27:26] (1)Selected bank
00Bank 1 - NOR/PSRAM 1
01Bank 1 - NOR/PSRAM 2
10Bank 1 - NOR/PSRAM 3
11Bank 1 - NOR/PSRAM 4
  1. 1. HADDR are internal AHB address lines that are translated to external memory.

HADDR[25:0] contain the external memory address. Since HADDR is a byte address whereas the memory is addressed in words, the address actually issued to the memory varies according to the memory data width, as shown in the following table.

Table 170. External memory address

Memory width (1)Data address issued to the memoryMaximum memory capacity (bits)
8-bitHADDR[25:0]64 Mbyte x 8 = 512 Mbit
16-bitHADDR[25:1] >> 164 Mbyte/2 x 16 = 512 Mbit
  1. 1. In case of a 16-bit external memory width, the FSMC internally uses HADDR[25:1] to generate the address for external memory FSMC_A[24:0].
    Whatever the external memory width (16-bit or 8-bit), FSMC_A[0] should be connected to external memory address A[0].

Wrap support for NOR flash/PSRAM

Wrap burst mode for synchronous memories is not supported. The memories must be configured in linear burst mode of undefined length.

31.4.2 NAND/PC Card address mapping

In this case, three banks are available, each of them divided into memory spaces as indicated in Table 171.

Table 171. Memory mapping and timing registers

Start addressEnd addressFSMC BankMemory spaceTiming register
0x9C00 00000x9FFF FFFFBank 4 - PC cardI/OFSMC_PIO4 (0xB0)
0x9800 00000x9BFF FFFFAttributeFSMC_PATT4 (0xAC)
0x9000 00000x93FF FFFFCommonFSMC_PMEM4 (0xA8)
0x8800 00000x8BFF FFFFBank 3 - NAND flashAttributeFSMC_PATT3 (0x8C)
0x8000 00000x83FF FFFFCommonFSMC_PMEM3 (0x88)
0x7800 00000x7BFF FFFFBank 2- NAND flashAttributeFSMC_PATT2 (0x6C)
0x7000 00000x73FF FFFFCommonFSMC_PMEM2 (0x68)

For NAND flash memory, the common and attribute memory spaces are subdivided into three sections (see in Table 172 below) located in the lower 256 Kbytes:

Table 172. NAND bank selections

Section nameHADDR[17:16]Address range
Address section1X0x020000-0x03FFFF
Command section010x010000-0x01FFFF
Data section000x000000-0x00FFFF

The application software uses the 3 sections to access the NAND flash memory:

Since the NAND flash memory automatically increments addresses, there is no need to increment the address of the data section to access consecutive memory locations.

31.5 NOR flash/PSRAM controller

The FSMC generates the appropriate signal timings to drive the following types of memories:

The FSMC outputs a unique chip select signal NE[4:1] per bank. All the other signals (addresses, data and control) are shared.

For synchronous accesses, the FSMC issues the clock (CLK) to the selected external device only during the read/write transactions. This clock is a submultiple of the HCLK clock. The size of each bank is fixed and equal to 64 Mbytes.

Each bank is configured by means of dedicated registers (see Section 31.5.6 ).

The programmable memory parameters include access timings (see Table 173 ) and support for wait management (for PSRAM and NOR flash accessed in burst mode).

Table 173. Programmable NOR/PSRAM access parameters

ParameterFunctionAccess modeUnitMin.Max.
Address setupDuration of the address setup phaseAsynchronousAHB clock cycle (HCLK)015
Address holdDuration of the address hold phaseAsynchronous, muxed I/OsAHB clock cycle (HCLK)115
Data setupDuration of the data setup phaseAsynchronousAHB clock cycle (HCLK)1256
Bus turnDuration of the bus turnaround phaseAsynchronous and synchronous read/writeAHB clock cycle (HCLK)015
Clock divide ratioNumber of AHB clock cycles (HCLK) to build one memory clock cycle (CLK)SynchronousAHB clock cycle (HCLK)216
Data latencyNumber of clock cycles to issue to the memory before the first data of the burstSynchronousMemory clock cycle (CLK)217

31.5.1 External memory interface signals

Table 174 , Table 175 and Table 176 list the signals that are typically used to interface NOR flash, SRAM and PSRAM.

Note: Prefix “N” specifies the associated signal as active low.

NOR flash, nonmultiplexed I/Os

Table 174. Nonmultiplexed I/O NOR flash

FSMC signal nameI/OFunction
CLKOClock (for synchronous access)
A[25:0]OAddress bus
D[15:0]I/OBidirectional data bus
NE[x]OChip select, x = 1..4
NOEOOutput enable
NWEOWrite enable
NL(=NADV)OLatch enable (this signal is called address valid, NADV, by some NOR flash devices)
NWAITINOR flash wait input signal to the FSMC

NOR flash memories are addressed in 16-bit words. The maximum capacity is 512 Mbit (26 address lines).

NOR flash, multiplexed I/Os

Table 175. Multiplexed I/O NOR flash

FSMC signal nameI/OFunction
CLKOClock (for synchronous access)
A[25:16]OAddress bus
AD[15:0]I/O16-bit multiplexed, bidirectional address/data bus
NE[x]OChip select, x = 1..4
NOEOOutput enable
NWEOWrite enable
NL(=NADV)OLatch enable (this signal is called address valid, NADV, by some NOR flash devices)
NWAITINOR flash wait input signal to the FSMC

NOR-flash memories are addressed in 16-bit words. The maximum capacity is 512 Mbit (26 address lines).

PSRAM/SRAM, nonmultiplexed I/Os

Table 176. Nonmultiplexed I/Os PSRAM/SRAM

FSMC signal nameI/OFunction
CLKOClock (only for PSRAM synchronous access)
A[25:0]OAddress bus
D[15:0]I/OData bidirectional bus
NE[x]OChip select, x = 1..4 (called NCE by PSRAM (Cellular RAM i.e. CRAM))
NOEOOutput enable
NWEOWrite enable
NL(= NADV)OAddress valid only for PSRAM input (memory signal name: NADV)
NWAITIPSRAM wait input signal to the FSMC
NBL[1]OUpper byte enable (memory signal name: NUB)
NBL[0]OLowed byte enable (memory signal name: NLB)

PSRAM memories are addressed in 16-bit words. The maximum capacity is 512 Mbit (26 address lines).

PSRAM, multiplexed I/Os

Table 177. Multiplexed I/O PSRAM

FSMC signal nameI/OFunction
CLKOClock (for synchronous access)
A[25:16]OAddress bus
AD[15:0]I/O16-bit multiplexed, bidirectional address/data bus
NE[x]OChip select, x = 1..4 (called NCE by PSRAM (Cellular RAM i.e. CRAM))
NOEOOutput enable
NWEOWrite enable
NL(= NADV)OAddress valid PSRAM input (memory signal name: NADV)
NWAITIPSRAM wait input signal to the FSMC
NBL[1]OUpper byte enable (memory signal name: NUB)
NBL[0]OLower byte enable (memory signal name: NLB)

PSRAM memories are addressed in 16-bit words. The maximum capacity is 512 Mbit (26 address lines).

31.5.2 Supported memories and transactions

Table 178 below displays an example of the supported devices, access modes and transactions when the memory data bus is 16-bit for NOR, PSRAM and SRAM. Transactions not allowed (or not supported) by the FSMC in this example appear in gray.

Table 178. NOR flash/PSRAM controller: example of supported memories and transactions

DeviceModeR/WAHB data sizeMemory data sizeAllowed/not allowedComments
NOR flash (muxed I/Os and nonmuxed I/Os)AsynchronousR816Y-
AsynchronousW816N-
AsynchronousR1616Y-
AsynchronousW1616Y-
AsynchronousR3216YSplit into two FSMC accesses
AsynchronousW3216YSplit into two FSMC accesses
Asynchronous pageR-16NMode is not supported
SynchronousR816N-
SynchronousR1616Y-
SynchronousR3216Y-

Table 178. NOR flash/PSRAM controller: example of supported memories and transactions

DeviceModeR/WAHB data sizeMemory data sizeAllowed/not allowedComments
PSRAM (multiplexed and nonmultiplexed I/Os)AsynchronousR816Y-
AsynchronousW816YUse of byte lanes NBL[1:0]
AsynchronousR1616Y-
AsynchronousW1616Y-
AsynchronousR3216YSplit into two FSMC accesses
AsynchronousW3216YSplit into two FSMC accesses
Asynchronous pageR-16NMode is not supported
SynchronousR816N-
SynchronousR1616Y-
SynchronousR3216Y-
SynchronousW816YUse of byte lanes NBL[1:0]
SynchronousW16 / 3216Y-
SRAM and ROMAsynchronousR8 / 1616Y-
AsynchronousW8 / 1616YUse of byte lanes NBL[1:0]
AsynchronousR3216YSplit into two FSMC accesses
AsynchronousW3216YSplit into two FSMC accesses. Use of byte lanes NBL[1:0]

31.5.3 General timing rules

Signals synchronization

31.5.4 NOR flash/PSRAM controller asynchronous transactions

Asynchronous static memories (NOR flash memory, PSRAM, SRAM)

Mode 1 - SRAM/PSRAM (CRAM)

The next figures show the read and write transactions for the supported modes followed by the required configuration of FSMC_BCRx, and FSMC_BTRx/FSMC_BWTRx registers.

Figure 399. Mode1 read accesses

Timing diagram for Mode 1 read accesses showing address, bus cycle, and data signals over time.

The diagram illustrates the timing for a Mode 1 read access. The signals shown are:

The timing is divided into two main phases relative to the HCLK clock:

The entire duration from the falling edge of NEx to the rising edge of NOE is labeled as the "Memory transaction".

Timing diagram for Mode 1 read accesses showing address, bus cycle, and data signals over time.
  1. 1. NBL[1:0] are driven low during read access.

Figure 400. Mode1 write accesses

Timing diagram for Mode1 write accesses showing signals A[25:0], NBL[1:0], NEx, NOE, NWE, and D[15:0] over time. The diagram illustrates the 'Memory transaction' period, 'ADDSET' in HCLK cycles, '(DATAST + 1)' in HCLK cycles, and '1HCLK' cycle duration. Data is shown as 'data driven by FSMC'.

The timing diagram shows the following signals and timing parameters:

Timing diagram for Mode1 write accesses showing signals A[25:0], NBL[1:0], NEx, NOE, NWE, and D[15:0] over time. The diagram illustrates the 'Memory transaction' period, 'ADDSET' in HCLK cycles, '(DATAST + 1)' in HCLK cycles, and '1HCLK' cycle duration. Data is shown as 'data driven by FSMC'.

The one HCLK cycle at the end of the write transaction helps guarantee the address and data hold time after the NWE rising edge. Due to the presence of this one HCLK cycle, the DATAST value must be greater than zero (DATAST > 0).

Table 179. FSMC_BCRx bit fields

Bit numberBit nameValue to set
31:20Reserved0x000
19CBURSTRW0x0 (no effect on asynchronous mode)
18:16CPSIZE0x0 (no effect on asynchronous mode)
15ASYNCWAITSet to 1 if the memory supports this feature. Otherwise keep at 0.
14EXTMOD0x0
13WAITEN0x0 (no effect on asynchronous mode)
12WRENAs needed
11WAITCFGDon't care
10WRAPMOD0x0
9WAITPOLMeaningful only if bit 15 is 1
8BURSTEN0x0
7Reserved0x1
6FACCENDon't care
5-4MWIDAs needed
3-2MTYP[0:1]As needed, exclude 0x2 (NOR flash)

Table 179. FSMC_BCRx bit fields (continued)

Bit numberBit nameValue to set
1MUXE0x0
0MBKEN0x1

Table 180. FSMC_BTRx bit fields

Bit numberBit nameValue to set
31:30Reserved0x0
29:28ACCMODDon't care
27:24DATLATDon't care
23:20CLKDIVDon't care
19:16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15:8DATASTDuration of the second access phase (DATAST+1 HCLK cycles for write accesses, DATAST HCLK cycles for read accesses).
7:4ADDHLDDon't care
3:0ADDSET[3:0]Duration of the first access phase (ADDSET HCLK cycles). Minimum value for ADDSET is 0.

Mode A - SRAM/PSRAM (CRAM) OE toggling

Figure 401. ModeA read accesses

Timing diagram for Mode A read accesses showing address, control, and data signals over time.

The diagram illustrates the timing for a read access in Mode A. The signals shown are:

The timing parameters are defined as:

The total duration of the memory transaction is the sum of ADDSET and DATAST HCLK cycles. The data driven by memory starts after the first access phase and continues until the end of the transaction.

ai15559

Timing diagram for Mode A read accesses showing address, control, and data signals over time.
  1. 1. NBL[1:0] are driven low during read access.

Figure 402. ModeA write accesses

Timing diagram for ModeA write accesses showing signals A[25:0], NBL[1:0], NEx, NOE, NWE, and D[15:0] over time. The diagram illustrates the 'Memory transaction' period, 'ADDSET' and '(DATAST + 1)' HCLK cycles, and the 'data driven by FSMC' phase. Signal transitions for address, bus cycle, and write enable are shown, with data being driven onto the bus during the write cycle.
Timing diagram for ModeA write accesses showing signals A[25:0], NBL[1:0], NEx, NOE, NWE, and D[15:0] over time. The diagram illustrates the 'Memory transaction' period, 'ADDSET' and '(DATAST + 1)' HCLK cycles, and the 'data driven by FSMC' phase. Signal transitions for address, bus cycle, and write enable are shown, with data being driven onto the bus during the write cycle.

The differences compared with mode1 are the toggling of NOE and the independent read and write timings.

Table 181. FSMC_BCRx bit fields

Bit numberBit nameValue to set
31-20Reserved0x000
19CBURSTRW0x0 (no effect on asynchronous mode)
18:16CPSIZE0x0 (no effect on asynchronous mode)
15ASYNCWAITSet to 1 if the memory supports this feature. Otherwise keep at 0.
14EXTMOD0x1
13WAITEN0x0 (no effect on asynchronous mode)
12WRENAs needed
11WAITCFGDon't care
10WRAPMOD0x0
9WAITPOLMeaningful only if bit 15 is 1
8BURSTEN0x0
7Reserved0x1
6FACCENDon't care
5-4MWIDAs needed
3-2MTYP[0:1]As needed, exclude 0x2 (NOR flash)
Table 181. FSMC_BCRx bit fields (continued)
Bit numberBit nameValue to set
1MUXEN0x0
0MBKEN0x1
Table 182. FSMC_BTRx bit fields
Bit numberBit nameValue to set
31:30Reserved0x0
29:28ACCMOD0x0
27:24DATLATDon't care
23:20CLKDIVDon't care
19:16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15:8DATASTDuration of the second access phase (DATAST HCLK cycles) for read accesses.
7:4ADDHLDDon't care
3:0ADDSET[3:0]Duration of the first access phase (ADDSET HCLK cycles) for read accesses.
Minimum value for ADDSET is 0.
Table 183. FSMC_BWTRx bit fields
Bit numberBit nameValue to set
31:30Reserved0x0
29:28ACCMOD0x0
27:24DATLATDon't care
23:20CLKDIVDon't care
19:16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15:8DATASTDuration of the second access phase (DATAST+1 HCLK cycles) for write accesses,
7:4ADDHLDDon't care
3:0ADDSET[3:0]Duration of the first access phase (ADDSET HCLK cycles) for write accesses.
Minimum value for ADDSET is 0.

Mode 2/B - NOR flash

Figure 403. Mode2 and mode B read accesses

Timing diagram for Mode2 and mode B read accesses showing address, control signals, and data bus over time.

This timing diagram illustrates a read access in Mode 2 or Mode B. The address A[25:0] is stable during the 'Memory transaction'. NADV and NEx are active-low signals that go low at the start and high at the end of the transaction. NOE is active-low and goes low to enable data output from the memory. NWE is high throughout. The data bus D[15:0] is driven by the memory during the 'DATAST' period. The 'ADDSET' period is the time from the start of the transaction until the address is stable. The diagram is labeled 'ai15561'.

Timing diagram for Mode2 and mode B read accesses showing address, control signals, and data bus over time.

Figure 404. Mode2 write accesses

Timing diagram for Mode2 write accesses showing address, control signals, and data bus over time.

This timing diagram illustrates a write access in Mode 2. The address A[25:0] is stable during the 'Memory transaction'. NADV and NEx are active-low signals that go low at the start and high at the end of the transaction. NOE is active-low and goes low at the start. NWE is active-low and goes low to enable data input to the memory. The data bus D[15:0] is driven by the FSMC during the '(DATAST + 1)' period. The 'ADDSET' period is the time from the start of the transaction until the address is stable. A '1HCLK' period is indicated between the start of the data drive and the start of the write. The diagram is labeled 'ai15562'.

Timing diagram for Mode2 write accesses showing address, control signals, and data bus over time.

Figure 405. Mode B write accesses

Timing diagram for Mode B write accesses showing address, control signals, and data over time.

The diagram illustrates the timing for Mode B write accesses. The address lines A[25:0] are stable during the memory transaction. The NADV signal is active-low and goes low at the start of the transaction. The NEx signal is also active-low and goes low at the start. The NOE signal is active-low and goes low at the start. The NWE signal is active-low and goes low at the start. The data lines D[15:0] are driven by the FSMC. The diagram shows the following timing parameters:

ai15563

Timing diagram for Mode B write accesses showing address, control signals, and data over time.

The differences with mode1 are the toggling of NWE and the independent read and write timings when extended mode is set (Mode B).

Table 184. FSMC_BCRx bit fields

Bit numberBit nameValue to set
31-20Reserved0x000
19CBURSTRW0x0 (no effect on asynchronous mode)
18:16Reserved0x0 (no effect on asynchronous mode)
15ASYNCWAITSet to 1 if the memory supports this feature. Otherwise keep at 0.
14EXTMOD0x1 for mode B, 0x0 for mode 2
13WAITEN0x0 (no effect on asynchronous mode)
12WRENAs needed
11WAITCFGDon't care
10WRAPMOD0x0
9WAITPOLMeaningful only if bit 15 is 1
8BURSTEN0x0
7Reserved0x1
6FACCEN0x1
5-4MWIDAs needed
Table 184. FSMC_BCRx bit fields (continued)
Bit numberBit nameValue to set
3-2MTYP[0:1]0x2 (NOR flash memory)
1MUXEN0x0
0MBKEN0x1
Table 185. FSMC_BTRx bit fields
Bit numberBit nameValue to set
31:30Reserved0x0
29-28ACCMOD0x1
27-24DATLATDon't care
23-20CLKDIVDon't care
19-16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15-8DATASTDuration of the second access phase (DATAST HCLK cycles) for read accesses.
7-4ADDHLDDon't care
3-0ADDSET[3:0]Duration of the first access phase (ADDSET HCLK cycles) for read accesses.
Minimum value for ADDSET is 0.
Table 186. FSMC_BWTRx bit fields
Bit numberBit nameValue to set
31:30Reserved0x0
29-28ACCMOD0x1
27-24DATLATDon't care
23-20CLKDIVDon't care
19-16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15-8DATASTDuration of the second access phase (DATAST+1 HCLK cycles) for write accesses,
7-4ADDHLDDon't care
3-0ADDSET[3:0]Duration of the first access phase (ADDSET HCLK cycles) for write accesses.
Minimum value for ADDSET is 0.

Note: The FSMC_BWTRx register is valid only if extended mode is set (mode B), otherwise all its content is don't care.

Mode C - NOR flash - OE toggling

Figure 406. Mode C read accesses

Timing diagram for Mode C read accesses showing signals A[25:0], NADV, NEx, NOE, NWE, and D[15:0] over time. The diagram illustrates the memory transaction phases: ADDSET and DATAST in HCLK cycles. NOE is toggled by the memory to drive data onto the bus.

This timing diagram shows the sequence of signals for a read access in Mode C. The address A[25:0] is stable during the entire transaction. NADV and NEx are active-low signals that go low at the start and high at the end of the transaction. NOE is initially high and is pulled low by the memory at the start of the DATAST phase to drive data onto the D[15:0] bus. NWE remains high throughout. The data bus D[15:0] is initially high-impedance, then becomes 'data driven by memory' during the DATAST phase. The transaction is divided into ADDSET (address setup) and DATAST (data setup) phases measured in HCLK cycles.

Timing diagram for Mode C read accesses showing signals A[25:0], NADV, NEx, NOE, NWE, and D[15:0] over time. The diagram illustrates the memory transaction phases: ADDSET and DATAST in HCLK cycles. NOE is toggled by the memory to drive data onto the bus.

ai15564

Figure 407. Mode C write accesses

Timing diagram for Mode C write accesses showing signals A[25:0], NADV, NEx, NOE, NWE, and D[15:0] over time. The diagram illustrates the memory transaction phases: ADDSET and (DATAST + 1) in HCLK cycles. Data is driven by the FSMC onto the bus.

This timing diagram shows the sequence of signals for a write access in Mode C. The address A[25:0] is stable. NADV and NEx are active-low signals that go low at the start and high at the end. NOE is initially high and is pulled low by the memory at the end of the transaction. NWE is pulled low by the FSMC one HCLK cycle before the data is driven onto the bus. The data bus D[15:0] is driven by the FSMC during the (DATAST + 1) phase. The transaction includes an ADDSET phase and a (DATAST + 1) phase in HCLK cycles.

Timing diagram for Mode C write accesses showing signals A[25:0], NADV, NEx, NOE, NWE, and D[15:0] over time. The diagram illustrates the memory transaction phases: ADDSET and (DATAST + 1) in HCLK cycles. Data is driven by the FSMC onto the bus.

ai15565

The differences compared with mode1 are the toggling of NOE and the independent read and write timings.

Table 187. FSMC_BCRx bit fields

Bit No.Bit nameValue to set
31-20Reserved0x000
19CBURSTRW0x0 (no effect on asynchronous mode)
18:16CPSIZE0x0 (no effect on asynchronous mode)
15ASYNCWAITSet to 1 if the memory supports this feature. Otherwise keep at 0.
14EXTMOD0x1
13WAITEN0x0 (no effect on asynchronous mode)
12WRENAs needed
11WAITCFGDon't care
10WRAPMOD0x0
9WAITPOLMeaningful only if bit 15 is 1
8BURSTEN0x0
7Reserved0x1
6FACCEN0x1
5-4MWIDAs needed
3-2MTYP[0:1]0x2 (NOR flash memory)
1MUXEN0x0
0MBKEN0x1

Table 188. FSMC_BTRx bit fields

Bit numberBit nameValue to set
31:30Reserved0x0
29:28ACCMOD0x2
27:24DATLAT0x0
23:20CLKDIV0x0
19:16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15-8DATASTDuration of the second access phase (DATAST HCLK cycles) for read accesses.
7-4ADDHLDDon't care
3-0ADDSET[3:0]Duration of the first access phase (ADDSET HCLK cycles) for read accesses.
Minimum value for ADDSET is 0.

Table 189. FSMC_BWTRx bit fields

Bit numberBit nameValue to set
31:30Reserved0x0
29:28ACCMOD0x2
27:24DATLATDon't care
23:20CLKDIVDon't care
19:16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15:8DATASTDuration of the second access phase (DATAST+1 HCLK cycles for write accesses,
7:4ADDHLDDon't care
3:0ADDSET[3:0]Duration of the first access phase (ADDSET HCLK cycles) for write accesses.
Minimum value for ADDSET is 0.

Mode D - asynchronous access with extended address

Figure 408. Mode D read accesses

Timing diagram for Mode D read accesses showing address (A[25:0]), NADV, NEx, NOE, NWE, and data (D[15:0]) signals over time. The diagram illustrates the memory transaction phases: ADDSET, ADDHLD, and DATAST in HCLK cycles. The data is driven by memory during the DATAST phase.

The timing diagram shows the following signals and phases:

Phases and durations:

ai15566

Timing diagram for Mode D read accesses showing address (A[25:0]), NADV, NEx, NOE, NWE, and data (D[15:0]) signals over time. The diagram illustrates the memory transaction phases: ADDSET, ADDHLD, and DATAST in HCLK cycles. The data is driven by memory during the DATAST phase.

Figure 409. Mode D write accesses

Timing diagram for Mode D write accesses showing signals A[25:0], NADV, NEx, NOE, NWE, and D[15:0] over time. The diagram illustrates the 'Memory transaction' period and various timing parameters: ADDSET, ADDHLD, and (DATAST+ 1) in HCLK cycles. Data is driven by the FSMC during the transaction.

The diagram shows the timing for a write access in Mode D. The address A[25:0] is stable during the 'Memory transaction'. NADV (Address Valid) goes low to indicate valid address. NEx (External memory write enable) goes low to enable the write. NOE (Output Enable) is high throughout. NWE (Write Enable) goes low to initiate the write. D[15:0] is driven by the FSMC. Timing parameters are defined as: ADDSET (time from NADV falling edge to data driving start), ADDHLD (time from NADV falling edge to data driving stop), and (DATAST+ 1) (time from data driving start to NWE rising edge). A 1HCLK cycle is also indicated between NWE rising edge and NOE falling edge.

Timing diagram for Mode D write accesses showing signals A[25:0], NADV, NEx, NOE, NWE, and D[15:0] over time. The diagram illustrates the 'Memory transaction' period and various timing parameters: ADDSET, ADDHLD, and (DATAST+ 1) in HCLK cycles. Data is driven by the FSMC during the transaction.

The differences with mode1 are the toggling of NOE that goes on toggling after NADV changes and the independent read and write timings.

Table 190. FSMC_BCRx bit fields

Bit No.Bit nameValue to set
31-20Reserved0x000
19CBURSTRW0x0 (no effect on asynchronous mode)
18:16CPSIZE0x0 (no effect on asynchronous mode)
15ASYNCWAITSet to 1 if the memory supports this feature. Otherwise keep at 0.
14EXTMOD0x1
13WAITEN0x0 (no effect on asynchronous mode)
12WRENAs needed
11WAITCFGDon't care
10WRAPMOD0x0
9WAITPOLMeaningful only if bit 15 is 1
8BURSTEN0x0
7Reserved0x1
6FACCENSet according to memory support
5-4MWIDAs needed
Table 190. FSMC_BCRx bit fields (continued)
Bit No.Bit nameValue to set
3-2MTYP[0:1]As needed
1MUXEN0x0
0MBKEN0x1
Table 191. FSMC_BTRx bit fields
Bit No.Bit nameValue to set
31:30Reserved0x0
29-28ACCMOD0x3
27-24DATLATDon't care
23-20CLKDIVDon't care
19-16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15-8DATASTDuration of the second access phase (DATAST HCLK cycles) for read accesses.
7-4ADDHLDDuration of the middle phase of the read access (ADDHLD HCLK cycles)
3-0ADDSET[3:0]Duration of the first access phase (ADDSET HCLK cycles) for read accesses. Minimum value for ADDSET is 1.
Table 192. FSMC_BWTRx bit fields
Bit No.Bit nameValue to set
31:30Reserved0x0
29-28ACCMOD0x3
27-24DATLAT0x0
23-20CLKDIV0x0
19-16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15-8DATASTDuration of the second access phase
7-4ADDHLDDuration of the middle phase of the write access (ADDHLD HCLK cycles)
3-0ADDSET[3:0]Duration of the first access phase . Minimum value for ADDSET is 1.

Muxed mode - multiplexed asynchronous access to NOR flash memory

Figure 410. Multiplexed read accesses

Timing diagram for multiplexed read accesses showing signals A[25:16], NADV, NEx, NOE, NWE, and AD[15:0] over time, with parameters ADDSET, ADDHLD, and DATAST in HCLK cycles.

This timing diagram illustrates a multiplexed read access to NOR flash memory. The signals shown are A[25:16] (address), NADV (address valid), NEx (external memory write), NOE (output enable), NWE (write enable), and AD[15:0] (data/address bus). The NWE signal is held high throughout the transaction. The AD[15:0] bus initially carries the 'Lower address' and later becomes 'data driven by memory'. The 'Memory transaction' duration is marked from the falling edge of NADV to the rising edge of NEx. Timing parameters are defined in HCLK cycles: ADDSET (address setup), ADDHLD (address hold), and DATAST (data setup).

Timing diagram for multiplexed read accesses showing signals A[25:16], NADV, NEx, NOE, NWE, and AD[15:0] over time, with parameters ADDSET, ADDHLD, and DATAST in HCLK cycles.

ai15568

Figure 411. Multiplexed write accesses

Timing diagram for multiplexed write accesses showing signals A[25:16], NADV, NEx, NOE, NWE, and AD[15:0] over time, with parameters ADDSET, ADDHLD, and (DATAST + 1) in HCLK cycles.

This timing diagram illustrates a multiplexed write access to NOR flash memory. The signals shown are A[25:16] (address), NADV (address valid), NEx (external memory write), NOE (output enable), NWE (write enable), and AD[15:0] (data/address bus). The NOE signal is held high throughout the transaction. The AD[15:0] bus initially carries the 'Lower address' and later becomes 'data driven by FSMC'. The 'Memory transaction' duration is marked from the falling edge of NADV to the rising edge of NEx. Timing parameters are defined in HCLK cycles: ADDSET (address setup), ADDHLD (address hold), and (DATAST + 1) (data setup). A 1HCLK cycle delay is shown between the falling edge of NWE and the start of the data drive.

Timing diagram for multiplexed write accesses showing signals A[25:16], NADV, NEx, NOE, NWE, and AD[15:0] over time, with parameters ADDSET, ADDHLD, and (DATAST + 1) in HCLK cycles.

ai15569

The difference with mode D is the drive of the lower address byte(s) on the databus.

Table 193. FSMC_BCRx bit fields

Bit No.Bit nameValue to set
31-21Reserved0x000
19CBURSTRW0x0 (no effect on asynchronous mode)
18:16CPSIZE0x0 (no effect on asynchronous mode)
15ASYNCWAITSet to 1 if the memory supports this feature. Otherwise keep at 0.
14EXTMOD0x0
13WAITEN0x0 (no effect on asynchronous mode)
12WRENAs needed
11WAITCFGDon't care
10WRAPMOD0x0
9WAITPOLMeaningful only if bit 15 is 1
8BURSTEN0x0
7Reserved0x1
6FACCEN0x1
5-4MWIDAs needed
3-2MTYP[0:1]0x2 (NOR flash memory)
1MUXEN0x1
0MBKEN0x1

Table 194. FSMC_BTRx bit fields

Bit No.Bit nameValue to set
31:30Reserved0x0
29:28ACCMOD0x0
27:24DATLATDon't care
23:20CLKDIVDon't care
19:16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15-8DATASTDuration of the second access phase (DATAST HCLK cycles for read accesses and DATAST+1 HCLK cycles for write accesses).
7-4ADDHLDDuration of the middle phase of the access (ADDHLD HCLK cycles).
3-0ADDSET[3:0]Duration of the first access phase (ADDSET HCLK cycles). Minimum value for ADDSET is 1.

WAIT management in asynchronous accesses

If the asynchronous memory asserts a WAIT signal to indicate that it is not yet ready to accept or to provide data, the ASYNCWAIT bit has to be set in FSMC_BCRx register.

If the WAIT signal is active (high or low depending on the WAITPOL bit), the second access phase (Data setup phase) programmed by the DATAST bits, is extended until WAIT becomes inactive. Unlike the data setup phase, the first access phases (Address setup and Address hold phases), programmed by the ADDSET[3:0] and ADDHLD bits, are not WAIT sensitive and so they are not prolonged.

The data setup phase (DATAST in the FSMC_BTRx register) must be programmed so that WAIT can be detected 4 HCLK cycles before the end of memory transaction. The following cases must be considered:

  1. 1. DATAST in FSMC_BTRx register) Memory asserts the WAIT signal aligned to NOE/NWE which toggles:

\[ \text{DATAST} \geq (4 \times \text{HCLK}) + \text{max\_wait\_assertion\_time} \]

  1. 2. Memory asserts the WAIT signal aligned to NEx (or NOE/NWE not toggling):
    if

\[ \text{max\_wait\_assertion\_time} > \text{address\_phase} + \text{hold\_phase} \]

then

\[ \text{DATAST} \geq (4 \times \text{HCLK}) + (\text{max\_wait\_assertion\_time} - \text{address\_phase} - \text{hold\_phase}) \]

otherwise

\[ \text{DATAST} \geq 4 \times \text{HCLK} \]

where max_wait_assertion_time is the maximum time taken by the memory to assert the WAIT signal once NEx/NOE/NWE is low.

Figure 412 and Figure 413 show the number of HCLK clock cycles that are added to the memory access after WAIT is released by the asynchronous memory (independently of the above cases).

Figure 412. Asynchronous wait during a read access

Timing diagram for asynchronous wait during a read access. It shows signals A[25:0], NEx, NWAIT, NOE, and D[15:0] over time. The diagram is divided into 'address phase' and 'data setup phase'. NWAIT is shown as 'don't care' in both phases. Data is driven by memory during the data setup phase, with a 4HCLK timing parameter indicated.

The diagram illustrates the timing for an asynchronous wait during a read access. The signals shown are:

Timing parameters shown include 4HCLK for the data setup phase duration.

ai18471b

Timing diagram for asynchronous wait during a read access. It shows signals A[25:0], NEx, NWAIT, NOE, and D[15:0] over time. The diagram is divided into 'address phase' and 'data setup phase'. NWAIT is shown as 'don't care' in both phases. Data is driven by memory during the data setup phase, with a 4HCLK timing parameter indicated.
  1. 1. NWAIT polarity depends on WAITPOL bit setting in FSMC_BCRx register.

Figure 413. Asynchronous wait during a write access

Timing diagram for asynchronous wait during a write access. It shows signals A[25:0], NEx, NWAIT, NWE, and D[15:0] over time. The diagram is divided into 'address phase' and 'data setup phase'. NWAIT is shown as 'don't care' in both phases. Data is driven by FSMC during the data setup phase, with a 3HCLK timing parameter indicated.

The diagram illustrates the timing for an asynchronous wait during a write access. The signals shown are:

Timing parameters shown include 3HCLK for the data setup phase duration and 1HCLK for the NWE pulse width.

ai15797c

Timing diagram for asynchronous wait during a write access. It shows signals A[25:0], NEx, NWAIT, NWE, and D[15:0] over time. The diagram is divided into 'address phase' and 'data setup phase'. NWAIT is shown as 'don't care' in both phases. Data is driven by FSMC during the data setup phase, with a 3HCLK timing parameter indicated.
  1. 1. NWAIT polarity depends on WAITPOL bit setting in FSMC_BCRx register.

31.5.5 Synchronous transactions

The memory clock, CLK, is a submultiple of HCLK according to the value of parameter CLKDIV.

NOR flash memories specify a minimum time from NADV assertion to CLK high. To meet this constraint, the FSMC does not issue the clock to the memory during the first internal clock cycle of the synchronous access (before NADV assertion). This guarantees that the rising edge of the memory clock occurs in the middle of the NADV low pulse.

Data latency versus NOR flash latency

The data latency is the number of cycles to wait before sampling the data. The DATLAT value must be consistent with the latency value specified in the NOR flash configuration register. The FSMC does not include the clock cycle when NADV is low in the data latency count.

Caution: Some NOR flash memories include the NADV Low cycle in the data latency count, so the exact relation between the latency and the FSMC DATLAT parameter can be either of:

Some recent memories assert NWAIT during the latency phase. In such cases DATLAT can be set to its minimum value. As a result, the FSMC samples the data and waits long enough to evaluate if the data are valid. Thus the FSMC detects when the memory exits latency and real data are taken.

Other memories do not assert NWAIT during latency. In this case the latency must be set correctly for both the FSMC and the memory, otherwise invalid data are mistaken for good data, or valid data are lost in the initial phase of the memory access.

Single-burst transfer

When the selected bank is configured in burst mode for synchronous accesses, if for example an AHB single-burst transaction is requested on 16-bit memories, the FSMC performs a burst transaction of length 1 (if the AHB transfer is 16-bit), or length 2 (if the AHB transfer is 32-bit) and de-assert the chip select signal when the last data is strobed.

Clearly, such a transfer is not the most efficient in terms of cycles (compared to an asynchronous read). Nevertheless, a random asynchronous access would first require to re-program the memory access mode, which would altogether last longer.

Cross boundary page for Cellular RAM 1.5

Cellular RAM 1.5 does not allow burst access to cross the page boundary. The FSMC controller allows to split automatically the burst access when the memory page size is reached by configuring the CPSIZE bits in the FSMC_BCR1 register following the memory page size.

Wait management

For synchronous NOR flash memories, NWAIT is evaluated after the programmed latency period, (DATLAT+2) CLK clock cycles.

If NWAIT is sensed active (low level when WAITPOL = 0, high level when WAITPOL = 1), wait states are inserted until NWAIT is sensed inactive (high level when WAITPOL = 0, low level when WAITPOL = 1).

When NWAIT is inactive, the data is considered valid either immediately (bit WAITCFG = 1) or on the next clock edge (bit WAITCFG = 0).

During wait-state insertion via the NWAIT signal, the controller continues to send clock pulses to the memory, keeping the chip select and output enable signals valid, and does not consider the data valid.

There are two timing configurations for the NOR flash NWAIT signal in burst mode:

These two NOR flash wait state configurations are supported by the FSMC, individually for each chip select, thanks to the WAITCFG bit in the FSMC_BCRx registers (x = 0..3).

Figure 414. Wait configurations

Timing diagram for Figure 414. Wait configurations. The diagram shows a memory transaction as a burst of 4 half words. It includes signals HCLK, CLK, A[25:16] (addr[25:16]), NADV, NWAIT (WAITCFG = 0), NWAIT (WAITCFG = 1), and A/D[15:0] (aaddr[15:0], data1, data2, data3). The NWAIT signal for WAITCFG = 0 is asserted one cycle before the wait state, while for WAITCFG = 1 it is asserted during the wait state. The inserted wait state is shown between data2 and data3.

The diagram illustrates the timing for a memory transaction consisting of a burst of 4 half words. The signals shown are:

The diagram shows the sequence of events: address addr[25:16] is valid, then aaddr[15:0] is valid. Data data 1 and data 2 are transferred. An inserted wait state occurs between data 2 and data 3 . The NWAIT signal is asserted according to the WAITCFG bit setting during this wait state.

ai15798b

Timing diagram for Figure 414. Wait configurations. The diagram shows a memory transaction as a burst of 4 half words. It includes signals HCLK, CLK, A[25:16] (addr[25:16]), NADV, NWAIT (WAITCFG = 0), NWAIT (WAITCFG = 1), and A/D[15:0] (aaddr[15:0], data1, data2, data3). The NWAIT signal for WAITCFG = 0 is asserted one cycle before the wait state, while for WAITCFG = 1 it is asserted during the wait state. The inserted wait state is shown between data2 and data3.

Figure 415. Synchronous multiplexed read mode - NOR, PSRAM (CRAM)

Timing diagram for synchronous multiplexed read mode. It shows signals HCLK, CLK, A[25:16], NEx, NOE, NWE, NADV, NWAIT, and A/D[15:0] over time. The diagram illustrates the sequence of address, data, and wait states during a burst of 4 half words. Address A[25:16] is valid during the first clock cycle. Data is output on A/D[15:0] in subsequent cycles, with data strobes. An inserted wait state is shown between the second and third data cycles. The total memory transaction duration is 4 clock cycles.
Timing diagram for synchronous multiplexed read mode. It shows signals HCLK, CLK, A[25:16], NEx, NOE, NWE, NADV, NWAIT, and A/D[15:0] over time. The diagram illustrates the sequence of address, data, and wait states during a burst of 4 half words. Address A[25:16] is valid during the first clock cycle. Data is output on A/D[15:0] in subsequent cycles, with data strobes. An inserted wait state is shown between the second and third data cycles. The total memory transaction duration is 4 clock cycles.
  1. 1. Byte lane outputs BL are not shown; for NOR access, they are held high, and, for PSRAM (CRAM) access, they are held low.
  2. 2. NWAIT polarity is set to 0.

Table 195. FSMC_BCRx bit fields

Bit No.Bit nameValue to set
31-20Reserved0x000
19CBURSTRWNo effect on synchronous read
18-16CPSIZEAs needed (0x1 for CRAM 1.5)
15ASCYWAIT0x0
14EXTMOD0x0
13WAITENSet to 1 if the memory supports this feature, otherwise keep at 0.
12WRENno effect on synchronous read
11WAITCFGto be set according to memory
10WRAPMOD0x0
9WAITPOLto be set according to memory
8BURSTEN0x1
7Reserved0x1
6FACCENSet according to memory support (NOR flash memory)
5-4MWIDAs needed
Table 195. FSMC_BCRx bit fields (continued)
Bit No.Bit nameValue to set
3-2MTYP[0:1]0x1 or 0x2
1MUXENAs needed
0MBKEN0x1
Table 196. FSMC_BTRx bit fields
Bit No.Bit nameValue to set
31:30Reserved0x0
29:28ACCMOD0x0
27-24DATLATData latency
23-20CLKDIV0x0 to get CLK = HCLK (not supported)
0x1 to get CLK = 2 × HCLK
..
19-16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15-8DATASTDon't care
7-4ADDHLDDon't care
3-0ADDSET[3:0]Don't care

Figure 416. Synchronous multiplexed write mode - PSRAM (CRAM)

Timing diagram for Synchronous multiplexed write mode - PSRAM (CRAM). It shows a memory transaction consisting of a burst of 2 half words. Signals include HCLK (internal clock), CLK (external clock), A[25:16] (address bits), NEx (chip select), NOE (output enable, Hi-Z), NWE (write enable), NADV (address valid), NWAIT (wait signal, WAITCFG = 0), and A/D[15:0] (multiplexed address/data bus). The diagram illustrates address latching followed by two data phases separated by an inserted wait state. Timing markers show '1 clock' periods and a latency period of '(DATLAT + 2) CLK cycles'.

Memory transaction = burst of 2 half words

HCLK

CLK

A[25:16]

addr[25:16]

NEx

Hi-Z

NOE

NWE

NADV

NWAIT

(WAITCFG = 0)

A/D[15:0]

Addr[15:0]

data

data

(DATLAT + 2)
CLK cycles

inserted wait state

1 clock 1 clock

ai14731f

Timing diagram for Synchronous multiplexed write mode - PSRAM (CRAM). It shows a memory transaction consisting of a burst of 2 half words. Signals include HCLK (internal clock), CLK (external clock), A[25:16] (address bits), NEx (chip select), NOE (output enable, Hi-Z), NWE (write enable), NADV (address valid), NWAIT (wait signal, WAITCFG = 0), and A/D[15:0] (multiplexed address/data bus). The diagram illustrates address latching followed by two data phases separated by an inserted wait state. Timing markers show '1 clock' periods and a latency period of '(DATLAT + 2) CLK cycles'.
  1. 1. Memory must issue NWAIT signal one cycle in advance, accordingly WAITCFG must be programmed to 0.
  2. 2. NWAIT polarity is set to 0.
  3. 3. Byte Lane (NBL) outputs are not shown, they are held low while NEx is active.

Table 197. FSMC_BCRx bit fields

Bit No.Bit nameValue to set
31-20Reserved0x000
19CBURSTRW0x1
18-16CPSIZEAs needed (0x1 for CRAM 1.5)
15ASCYCWAIT0x0
14EXTMOD0x0
13WAITENSet to 1 if the memory supports this feature, otherwise keep at 0.
12WREN0x1
11WAITCFG0x0
10WRAPMOD0x0
Table 197. FSMC_BCRx bit fields (continued)
Bit No.Bit nameValue to set
9WAITPOLto be set according to memory
8BURSTENno effect on synchronous write
7Reserved0x1
6FACCENSet according to memory support
5-4MWIDAs needed
3-2MTYP[0:1]0x1
1MUXENAs needed
0MBKEN0x1
Table 198. FSMC_BTRx bit fields
Bit No.Bit nameValue to set
31:30Reserved0x0
29:28ACCMOD0x0
27-24DATLATData latency
23-20CLKDIV0x0 to get CLK = HCLK (not supported)
0x1 to get CLK = 2 × HCLK
19-16BUSTURNTime between NEx high to NEx low (BUSTURN HCLK)
15-8DATASTDon't care
7-4ADDHLDDon't care
3-0ADDSET[3:0]Don't care

31.5.6 NOR/PSRAM control registers

The NOR/PSRAM control registers have to be accessed by words (32 bits).

SRAM/NOR-flash chip-select control registers 1..4 (FSMC_BCR1..4)

Address offset: \( 0xA000\ 0000 + 8 * (x - 1) \) , \( x = 1..4 \)

Reset value: 0x0000 30DB for Bank1 and 0x0000 30D2 for Bank 2 to 4

This register contains the control information of each memory bank, used for SRAMs, PSRAM and NOR flash memories.

313029282726252423222120191817161514131211109876543210
ReservedCBURSTRWCPSIZE[2:0]ASYNCWAITEXTMODWAITENWRENWAITCFGWRAPMODWAITPOLBURSTENReservedFACCENMWID[1:0]MTYP[1:0]MUXENMBKEN
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31: 20 Reserved, must be kept at reset value.

Bit 19 CBURSTRW : Write burst enable.

For Cellular RAM (PSRAM) memories, this bit enables the synchronous burst protocol during write operations. The enable bit for synchronous read accesses is the BURSTEN bit in the FSMC_BCRx register.

0: Write operations are always performed in asynchronous mode

1: Write operations are performed in synchronous mode.

Bits 18: 16 CPSIZE[2:0] : CRAM page size.

These are used for Cellular RAM 1.5 which does not allow burst access to cross the address boundaries between pages. When these bits are configured, the FSMC controller splits automatically the burst access when the memory page size is reached (refer to memory datasheet for page size).

000: No burst split when crossing page boundary (default after reset)

001: 128 bytes

010: 256 bytes

011: 512 bytes

100: 1024 bytes

Others: reserved.

Bit 15 ASYNCWAIT : Wait signal during asynchronous transfers

This bit enables/disables the FSMC to use the wait signal even during an asynchronous protocol.

0: NWAIT signal is not taken into account when running an asynchronous protocol (default after reset)

1: NWAIT signal is taken into account when running an asynchronous protocol

Bit 14 EXTMOD: Extended mode enable.

This bit enables the FSMC to program the write timings for non-multiplexed asynchronous accesses inside the FSMC_BWTR register, thus resulting in different timings for read and write operations.

0: values inside FSMC_BWTR register are not taken into account (default after reset)

1: values inside FSMC_BWTR register are taken into account

Note: When the extended mode is disabled, the FSMC can operate in Mode1 or Mode2 as follows:

Bit 13 WAITEN: Wait enable bit.

This bit enables/disables wait-state insertion via the NWAIT signal when accessing the flash memory in synchronous mode.

0: NWAIT signal is disabled (its level not taken into account, no wait state inserted after the programmed flash latency period)

1: NWAIT signal is enabled (its level is taken into account after the programmed flash latency period to insert wait states if asserted) (default after reset)

Bit 12 WREN: Write enable bit.

This bit indicates whether write operations are enabled/disabled in the bank by the FSMC:

0: Write operations are disabled in the bank by the FSMC, an AHB error is reported,

1: Write operations are enabled for the bank by the FSMC (default after reset).

Bit 11 WAITCFG: Wait timing configuration.

The NWAIT signal indicates whether the data from the memory are valid or if a wait state must be inserted when accessing the flash memory in synchronous mode. This configuration bit determines if NWAIT is asserted by the memory one clock cycle before the wait state or during the wait state:

0: NWAIT signal is active one data cycle before wait state (default after reset),

1: NWAIT signal is active during wait state (not used for PRAM).

Bit 10 WRAPMOD: Wrapped burst mode support.

Defines whether the controller splits or not an AHB burst wrap access into two linear accesses. Valid only when accessing memories in burst mode

0: Direct wrapped burst is not enabled (default after reset),

1: Direct wrapped burst is enabled.

Note: This bit has no effect as the CPU and DMA cannot generate wrapping burst transfers.

Bit 9 WAITPOL: Wait signal polarity bit.

Defines the polarity of the wait signal from memory. Valid only when accessing the memory in burst mode:

0: NWAIT active low (default after reset),

1: NWAIT active high.

Bit 8 BURSTEN: Burst enable bit.

This bit enables/disables synchronous accesses during read operations. It is valid only for synchronous memories operating in burst mode:

0: Burst mode disabled (default after reset). Read accesses are performed in asynchronous mode.

1: Burst mode enable. Read accesses are performed in synchronous mode.

Bit 7 Reserved, must be kept at reset value.

Bit 6 FACCEN : Flash access enable

Enables NOR flash memory access operations.

0: Corresponding NOR flash memory access is disabled

1: Corresponding NOR flash memory access is enabled (default after reset)

Bits 5:4 MWID[1:0] : Memory databus width.

Defines the external memory device width, valid for all type of memories.

00: 8 bits,

01: 16 bits (default after reset),

10: reserved, do not use,

11: reserved, do not use.

Bits 3:2 MTYP[1:0] : Memory type.

Defines the type of external memory attached to the corresponding memory bank:

00: SRAM (default after reset for Bank 2...4)

01: PSRAM (CRAM)

10: NOR flash/OneNAND flash (default after reset for Bank 1)

11: reserved

Bit 1 MUXEN : Address/data multiplexing enable bit.

When this bit is set, the address and data values are multiplexed on the databus, valid only with NOR and PSRAM memories:

0: Address/Data nonmultiplexed

1: Address/Data multiplexed on databus (default after reset)

Bit 0 MBKEN : Memory bank enable bit.

Enables the memory bank. After reset Bank1 is enabled, all others are disabled.

Accessing a disabled bank causes an ERROR on AHB bus.

0: Corresponding memory bank is disabled

1: Corresponding memory bank is enabled

SRAM/NOR-flash chip-select timing registers 1..4 (FSMC_BTR1..4)

Address offset: \( 0xA000\ 0000 + 0x04 + 8 * (x - 1) \) , \( x = 1..4 \)

Reset value: 0x0FFF FFFF

FSMC_BTRx bits are written by software to add a delay at the end of a read /write transaction. This delay allows matching the minimum time between consecutive transactions ( \( t_{EHEL} \) from NEx high to FSMC_NEx low) and the maximum time required by the memory to free the data bus after a read access ( \( t_{EHQZ} \) ).

This register contains the control information of each memory bank, used for SRAMs, PSRAM and NOR flash memories. If the EXTMOD bit is set in the FSMC_BCRx register, then this register is partitioned for write and read access, that is, 2 registers are available: one to configure read accesses (this register) and one to configure write accesses (FSMC_BWTRx registers).

313029282726252423222120191817161514131211109876543210
ReservedACCMOD[1:0]DATLAT[3:0]CLKDIV[3:0]BURSTURN[3:0]DATAST[7:0]ADDHLD[3:0]ADDSET[3:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:30 Reserved, must be kept at reset value.

Bits 29:28 ACCMOD[1:0] : Access mode

Specifies the asynchronous access modes as shown in the timing diagrams. These bits are taken into account only when the EXTMOD bit in the FSMC_BCRx register is 1.

Bits 27:24 DATLAT[3:0] : Data latency for synchronous NOR flash memory (see note below bit description table)

For synchronous NOR flash memory with burst mode enabled, defines the number of memory clock cycles (+2) to issue to the memory before reading/writing the first data.

This timing parameter is not expressed in HCLK periods, but in FSMC_CLK periods. In case of PSRAM (CRAM), this field must be set to 0. In asynchronous NOR flash or SRAM or PSRAM, this value is don't care.

Bits 23:20 CLKDIV[3:0] : Clock divide ratio (for FSMC_CLK signal)

Defines the period of FSMC_CLK clock output signal, expressed in number of HCLK cycles:

In asynchronous NOR flash, SRAM or PSRAM accesses, this value is don't care.

Bits 19:16 BUSTURN[3:0] : Bus turnaround phase duration

These bits are written by software to add a delay at the end of a write-to-read (and read-to write) transaction. The programmed bus turnaround delay is inserted between an asynchronous read (muxed or D mode) or a write transaction and any other asynchronous/synchronous read or write to/from a static bank (for a read operation, the bank can be the same or a different one; for a write operation, the bank can be different except in muxed or D mode).

In some cases, the bus turnaround delay is fixed, whatever the programmed BUSTURN values:

0000: BUSTURN phase duration = 0 HCLK clock cycle added

...

1111: BUSTURN phase duration = 15 × HCLK clock cycles (default value after reset)

Bits 15:8 DATAST[7:0] : Data-phase duration

These bits are written by software to define the duration of the data phase (refer to Figure 399 to Figure 411 ), used in asynchronous accesses:

0000 0000: Reserved

0000 0001: DATAST phase duration = 1 × HCLK clock cycles

0000 0010: DATAST phase duration = 2 × HCLK clock cycles

...

1111 1111: DATAST phase duration = 255 × HCLK clock cycles (default value after reset)

For each memory type and access mode data-phase duration, refer to the respective figure ( Figure 399 to Figure 411 ).

Example: Mode1, write access, DATAST=1: Data-phase duration= DATAST+1 = 2 HCLK clock cycles.

Note: In synchronous accesses, this value is don't care.

Bits 7:4 ADDHLD[3:0] : Address-hold phase duration

These bits are written by software to define the duration of the address hold phase (refer to Figure 408 to Figure 411 ), used in mode D and multiplexed accesses:

0000: Reserved

0001: ADDHLD phase duration = 1 × HCLK clock cycle

0010: ADDHLD phase duration = 2 × HCLK clock cycle

...

1111: ADDHLD phase duration = 15 × HCLK clock cycles (default value after reset)

For each access mode address-hold phase duration, refer to the respective figure ( Figure 408 to Figure 411 ).

Note: In synchronous accesses, this value is not used, the address hold phase is always 1 memory clock period duration.

Bits 3:0 ADDSET[3:0] : Address setup phase duration

These bits are written by software to define the duration of the address setup phase (refer to Figure 399 to Figure 411 ), used in SRAMs, ROMs and asynchronous NOR flash and PSRAM accesses:

0000: ADDSET phase duration = 0 × HCLK clock cycle

...

1111: ADDSET phase duration = 15 × HCLK clock cycles (default value after reset)

For each access mode address setup phase duration, refer to the respective figure (refer to Figure 399 to Figure 411 ).

Note: In synchronous NOR flash and PSRAM accesses, this value is don't care.

Note: PSRAMs (CRAMs) have a variable latency due to internal refresh. Therefore these memories issue the NWAIT signal during the whole latency phase to prolong the latency as needed.

With PSRAMs (CRAMs) the DATLAT field must be set to 0, so that the FSMC exits its latency phase soon and starts sampling NWAIT from memory, then starts to read or write when the memory is ready.

This method can be used also with the latest generation of synchronous flash memories that issue the NWAIT signal, unlike older flash memories (check the datasheet of the specific flash memory being used).

SRAM/NOR-flash write timing registers 1..4 (FSMC_BWTR1..4)

Address offset: 0xA000 0000 + 0x104 + 8 * (x - 1), x = 1...4

Reset value: 0x0FFF FFFF

This register contains the control information of each memory bank, used for SRAMs, PSRAMs and NOR flash memories. This register is active for write asynchronous access only when the EXTMOD bit is set in the FSMC_BCRx register.

313029282726252423222120191817161514131211109876543210
Res.ACCMOD[2:0]ReservedBUSTURN[3:0]DATAST[7:0]ADDHLD[3:0]ADDSET[3:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:30 Reserved, must be kept at reset value.

Bits 29:28 ACCMOD[2:0] : Access mode.

Specifies the asynchronous access modes as shown in the next timing diagrams. These bits are taken into account only when the EXTMOD bit in the FSMC_BCRx register is 1.

Bits 27:20 Reserved, must be kept at reset value.

Bits 19:16 BUSTURN[3:0] : Bus turnaround phase duration

The programmed bus turnaround delay is inserted between a an asynchronous write transfer and any other asynchronous/synchronous read or write transfer to/from a static bank (for a read operation, the bank can be the same or a different one; for a write operation, the bank can be different except in r muxed or D mode).

In some cases, the bus turnaround delay is fixed, whatever the programmed BUSTURN values:

0000: BUSTURN phase duration = 0 HCLK clock cycle added

...

1111: BUSTURN phase duration = 15 HCLK clock cycles added (default value after reset)

Bits 15:8 DATAST[7:0] : Data-phase duration.

These bits are written by software to define the duration of the data phase (refer to Figure 399 to Figure 411 ), used in asynchronous SRAM, PSRAM and NOR flash memory accesses:

0000 0000: Reserved

0000 0001: DATAST phase duration = 1 × HCLK clock cycles

0000 0010: DATAST phase duration = 2 × HCLK clock cycles

...

1111 1111: DATAST phase duration = 255 × HCLK clock cycles (default value after reset)

Note: In synchronous accesses, this value is don't care.

Bits 7:4 ADDHLD[3:0] : Address-hold phase duration.

These bits are written by software to define the duration of the address hold phase (refer to Figure 408 to Figure 411 ), used in asynchronous multiplexed accesses:

0000: Reserved

0001: ADDHLD phase duration = 1 × HCLK clock cycle

0010: ADDHLD phase duration = 2 × HCLK clock cycle

...

1111: ADDHLD phase duration = 15 × HCLK clock cycles (default value after reset)

Note: In synchronous NOR flash accesses, this value is not used, the address hold phase is always 1 flash clock period duration.

Bits 3:0 ADDSET[3:0] : Address setup phase duration.

These bits are written by software to define the duration of the address setup phase in HCLK cycles (refer to Figure 408 to Figure 411 ), used in asynchronous accessed:

0000: ADDSET phase duration = 0 × HCLK clock cycle

...

1111: ADDSET phase duration = 15 × HCLK clock cycles (default value after reset)

Note: In synchronous NOR flash and PSRAM accesses, this value is don't care.

31.6 NAND flash/PC Card controller

The FSMC generates the appropriate signal timings to drive the following types of device:

The NAND/PC Card controller can control three external banks. Bank 2 and bank 3 support NAND flash devices. Bank 4 supports PC Card devices.

Each bank is configured by means of dedicated registers ( Section 31.6.8 ). The programmable memory parameters include access timings (shown in Table 199 ) and ECC configuration.

Table 199. Programmable NAND/PC Card access parameters
ParameterFunctionAccess modeUnitMin.Max.
Memory setup timeNumber of clock cycles (HCLK) to set up the address before the command assertionRead/WriteAHB clock cycle (HCLK)1255
Memory waitMinimum duration (HCLK clock cycles) of the command assertionRead/WriteAHB clock cycle (HCLK)2256
Memory holdNumber of clock cycles (HCLK) to hold the address (and the data in case of a write access) after the command de-assertionRead/WriteAHB clock cycle (HCLK)1254
Memory databus high-ZNumber of clock cycles (HCLK) during which the databus is kept in high-Z state after the start of a write accessWriteAHB clock cycle (HCLK)0255

31.6.1 External memory interface signals

The following tables list the signals that are typically used to interface NAND flash and PC Card.

Note: Prefix “N”. specifies the associated signal as active low.

8-bit NAND flash

Table 200. 8-bit NAND flash
FSMC signal nameI/OFunction
A[17]ONAND flash address latch enable (ALE) signal
A[16]ONAND flash command latch enable (CLE) signal
D[7:0]I/O8-bit multiplexed, bidirectional address/data bus
NCE[x]OChip select, x = 2, 3
NOE(= NRE)OOutput enable (memory signal name: read enable, NRE)
NWEOWrite enable
NWAIT/INT[3:2]INAND flash ready/busy input signal to the FSMC

There is no theoretical capacity limitation as the FSMC can manage as many address cycles as needed.

16-bit NAND flash

Table 201. 16-bit NAND flash

FSMC signal nameI/OFunction
A[17]ONAND flash address latch enable (ALE) signal
A[16]ONAND flash command latch enable (CLE) signal
D[15:0]I/O16-bit multiplexed, bidirectional address/data bus
NCE[x]OChip select, x = 2, 3
NOE(= NRE)OOutput enable (memory signal name: read enable, NRE)
NWEOWrite enable
NWAIT/INT[3:2]INAND flash ready/busy input signal to the FSMC

There is no theoretical capacity limitation as the FSMC can manage as many address cycles as needed.

16-bit PC Card

Table 202. 16-bit PC Card

FSMC signal nameI/OFunction
A[10:0]OAddress bus
NIORDOOutput enable for I/O space
NIOWROWrite enable for I/O space
NREGORegister signal indicating if access is in Common or Attribute space
D[15:0]I/OBidirectional databus
NCE4_1OChip select 1
NCE4_2OChip select 2 (indicates if access is 16-bit or 8-bit)
NOEOOutput enable in Common and in Attribute space
NWEOWrite enable in Common and in Attribute space
NWAITIPC Card wait input signal to the FSMC (memory signal name IORDY)
INTRIPC Card interrupt to the FSMC (only for PC Cards that can generate an interrupt)
CDIPC Card presence detection. Active high. If an access is performed to the PC Card banks while CD is low, an AHB error is generated. Refer to Section 31.3: AHB interface

31.6.2 NAND flash / PC Card supported memories and transactions

Table 203 below shows the supported devices, access modes and transactions. Transactions not allowed (or not supported) by the NAND flash / PC Card controller appear in gray.

Table 203. Supported memories and transactions

DeviceModeR/WAHB data sizeMemory data sizeAllowed/ not allowedComments
NAND 8-bitAsynchronousR88Y-
AsynchronousW88Y-
AsynchronousR168YSplit into 2 FSMC accesses
AsynchronousW168YSplit into 2 FSMC accesses
AsynchronousR328YSplit into 4 FSMC accesses
AsynchronousW328YSplit into 4 FSMC accesses
NAND 16-bitAsynchronousR816Y-
AsynchronousW816N-
AsynchronousR1616Y-
AsynchronousW1616Y-
AsynchronousR3216YSplit into 2 FSMC accesses
AsynchronousW3216YSplit into 2 FSMC accesses

31.6.3 Timing diagrams for NAND and PC Card

Each PC Card/CompactFlash and NAND flash memory bank is managed through a set of registers:

Each timing configuration register contains three parameters used to define number of HCLK cycles for the three phases of any PC Card/CompactFlash or NAND flash access, plus one parameter that defines the timing for starting driving the databus in the case of a write. Figure 417 shows the timing parameter definitions for common memory accesses, knowing that Attribute and I/O (only for PC Card) memory space access timings are similar.

Figure 417. NAND/PC Card controller timing for common memory access

Timing diagram for NAND/PC Card controller common memory access. The diagram shows the relationship between HCLK, address lines A[25:0], active-low chip select NCEx, active-low read strobe NREG, NIOR, NIEW, NIEO, active-low write strobe NWE, NOE, write data bus, and read data bus. Timing parameters shown are MEMxSET + 1, MEMxWAIT + 1, MEMxHOLD + 1, and MEMxHIZ. The read data bus is shown as 'Valid' during the read phase.
Timing diagram for NAND/PC Card controller common memory access. The diagram shows the relationship between HCLK, address lines A[25:0], active-low chip select NCEx, active-low read strobe NREG, NIOR, NIEW, NIEO, active-low write strobe NWE, NOE, write data bus, and read data bus. Timing parameters shown are MEMxSET + 1, MEMxWAIT + 1, MEMxHOLD + 1, and MEMxHIZ. The read data bus is shown as 'Valid' during the read phase.
  1. 1. NOE remains high (inactive) during write access. NWE remains high (inactive) during read access.
  2. 2. For write accesses, the hold phase delay is \( (\text{MEMHOLD}) \times \text{HCLK} \) cycles, while it is \( (\text{MEMHOLD} + 2) \times \text{HCLK} \) cycles for read accesses.

31.6.4 NAND flash operations

The command latch enable (CLE) and address latch enable (ALE) signals of the NAND flash device are driven by some address signals of the FSMC controller. This means that to send a command or an address to the NAND flash memory, the CPU has to perform a write to a certain address in its memory space.

A typical page read operation from the NAND flash device is as follows:

  1. 1. Program and enable the corresponding memory bank by configuring the FSMC_PCRx and FSMC_PMEMx (and for some devices, FSMC_PATTx, see Section 31.6.5 ) registers according to the characteristics of the NAND flash (PWID bits for the databus width of the NAND flash, PTYP = 1, PWAITEN = 0 or 1 as needed, see Common memory space timing register 2..4 (FSMC_PMEM2..4) for timing configuration).
  2. 2. The CPU performs a byte write in the common memory space, with data byte equal to one flash command byte (for example 0x00 for Samsung NAND flash devices). The CLE input of the NAND flash is active during the write strobe (low pulse on NWE), thus the written byte is interpreted as a command by the NAND flash. Once the command is latched by the NAND flash device, it does not need to be written for the following page read operations.
  3. 3. The CPU can send the start address (STARTAD) for a read operation by writing the required bytes (for example four bytes or three for smaller capacity devices), STARTAD[7:0], STARTAD[15:8], STARTAD[23:16] and finally STARTAD[25:24] for 64 Mb x 8 bit NAND flash) in the common memory or attribute space. The ALE input of the NAND flash device is active during the write strobe (low pulse on NWE), thus the

written bytes are interpreted as the start address for read operations. Using the attribute memory space makes it possible to use a different timing configuration of the FSMC, which can be used to implement the prewait functionality needed by some NAND flash memories (see details in Section 31.6.5 ).

  1. 4. The controller waits for the NAND flash to be ready (R/NB signal high) to become active, before starting a new access (to same or another memory bank). While waiting, the controller maintains the NCE signal active (low).
  2. 5. The CPU can then perform byte read operations in the common memory space to read the NAND flash page (data field + Spare field) byte by byte.
  3. 6. The next NAND flash page can be read without any CPU command or address write operation, in three different ways:
    • – by simply performing the operation described in step 5
    • – a new random address can be accessed by restarting the operation at step 3
    • – a new command can be sent to the NAND flash device by restarting at step 2

31.6.5 NAND flash prewait functionality

Some NAND flash devices require that, after writing the last part of the address, the controller wait for the R/NB signal to go low as shown in Figure 418 .

Figure 418. Access to non 'CE don't care' NAND-Flash

Timing diagram for Figure 418 showing signals NCE, CLE, ALE, NWE, NOE, I/O[7:0], and R/NB over time. The diagram illustrates the sequence of operations for writing an address to a NAND flash device. NCE is active low. CLE is a pulse for command. ALE is a pulse for address. NWE is a pulse for write. NOE is high (inactive). I/O[7:0] shows data bytes: 0x00, A7-A0, A15-A8, A23-A16, A25-A14. R/NB is the ready/busy signal. The diagram is divided into five steps: (1) CPU wrote byte 0x00 at address 0x7001 0000; (2) CPU wrote byte A7-A0 at address 0x7002 0000; (3) CPU wrote byte A15-A8 at address 0x7002 0000; (4) CPU wrote byte A23-A16 at address 0x7002 0000; (5) CPU wrote byte A25-A24 at address 0x7802 0000. A horizontal arrow labeled 'NCE must stay low' spans from the start of step 5 until the end of the sequence. A horizontal arrow labeled 'tR' spans from the start of step 5 to the falling edge of R/NB. A horizontal arrow labeled 'tWB' spans from the falling edge of R/NB to the start of the next operation.
Timing diagram for Figure 418 showing signals NCE, CLE, ALE, NWE, NOE, I/O[7:0], and R/NB over time. The diagram illustrates the sequence of operations for writing an address to a NAND flash device. NCE is active low. CLE is a pulse for command. ALE is a pulse for address. NWE is a pulse for write. NOE is high (inactive). I/O[7:0] shows data bytes: 0x00, A7-A0, A15-A8, A23-A16, A25-A14. R/NB is the ready/busy signal. The diagram is divided into five steps: (1) CPU wrote byte 0x00 at address 0x7001 0000; (2) CPU wrote byte A7-A0 at address 0x7002 0000; (3) CPU wrote byte A15-A8 at address 0x7002 0000; (4) CPU wrote byte A23-A16 at address 0x7002 0000; (5) CPU wrote byte A25-A24 at address 0x7802 0000. A horizontal arrow labeled 'NCE must stay low' spans from the start of step 5 until the end of the sequence. A horizontal arrow labeled 'tR' spans from the start of step 5 to the falling edge of R/NB. A horizontal arrow labeled 'tWB' spans from the falling edge of R/NB to the start of the next operation.
  1. 1. CPU wrote byte 0x00 at address 0x7001 0000.
  2. 2. CPU wrote byte A7-A0 at address 0x7002 0000.
  3. 3. CPU wrote byte A15-A8 at address 0x7002 0000.
  4. 4. CPU wrote byte A23-A16 at address 0x7002 0000.
  5. 5. CPU wrote byte A25-A24 at address 0x7802 0000: FSMC performs a write access using FSMC_PATT2 timing definition, where \( ATTHOLD \geq 7 \) (providing that \( (7+1) \times HCLK = 112 \text{ ns} > t_{WB} \text{ max} \) ). This guarantees that NCE remains low until R/NB goes low and high again (only requested for NAND flash memories where NCE is not don't care).

When this functionality is needed, it can be guaranteed by programming the MEMHOLD value to meet the \( t_{WB} \) timing. However CPU read accesses to the NAND flash memory have a hold delay of \( (\text{MEMHOLD} + 2) \times \text{HCLK} \) cycles, while CPU write accesses have a hold delay of \( (\text{MEMHOLD}) \times \text{HCLK} \) cycles.

To overcome this timing constraint, the attribute memory space can be used by programming its timing register with an ATTHOLD value that meets the \( t_{WB} \) timing, and leaving the MEMHOLD value at its minimum. Then, the CPU must use the common memory space for all NAND flash read and write accesses, except when writing the last address byte to the NAND flash device, where the CPU must write to the attribute memory space.

31.6.6 Computation of the error correction code (ECC) in NAND flash memory

The FSMC PC-Card controller includes two error correction code computation hardware blocks, one per memory bank. They are used to reduce the host CPU workload when processing the error correction code by software in the system.

These two registers are identical and associated with bank 2 and bank 3, respectively. As a consequence, no hardware ECC computation is available for memories connected to bank 4.

The error correction code (ECC) algorithm implemented in the FSMC can perform 1-bit error correction and 2-bit error detection per 256, 512, 1 024, 2 048, 4 096 or 8 192 bytes read from or written to NAND flash memory. It is based on the Hamming coding algorithm and consists in calculating the row and column parity.

The ECC modules monitor the NAND flash databus and read/write signals (NCE and NWE) each time the NAND flash memory bank is active.

The functional operations are:

Once the desired number of bytes has been read from/written to the NAND flash by the host CPU, the FSMC_ECCR2/3 registers must be read in order to retrieve the computed value. Once read, they should be cleared by resetting the ECCEN bit to zero. To compute a new data block, the ECCEN bit must be set to one in the FSMC_PCR2/3 registers.

To perform an ECC computation:

  1. 1. Enable the ECCEN bit in the FSMC_PCR2/3 register.
  2. 2. Write data to the NAND flash memory page. While the NAND page is written, the ECC block computes the ECC value.
  3. 3. Read the ECC value available in the FSMC_ECCR2/3 register and store it in a variable.
  4. 4. Clear the ECCEN bit and then enable it in the FSMC_PCR2/3 register before reading back the written data from the NAND page. While the NAND page is read, the ECC block computes the ECC value.
  5. 5. Read the new ECC value available in the FSMC_ECCR2/3 register.
  6. 6. If the two ECC values are the same, no correction is required, otherwise there is an ECC error and the software correction routine returns information on whether the error can be corrected or not.

31.6.7 PC Card/CompactFlash operations

Address spaces and memory accesses

The FSMC supports Compact Flash storage or PC Cards in Memory Mode and I/O Mode (True IDE mode is not supported).

The Compact Flash storage and PC Cards are made of 3 memory spaces:

The nCE2 and nCE1 pins (FSMC_NCE4_2 and FSMC_NCE4_1 respectively) select the card and indicate whether a byte or a word operation is being performed: nCE2 accesses the odd byte on D15-8 and nCE1 accesses the even byte on D7-0 if A0=0 or the odd byte on D7-0 if A0=1. The full word is accessed on D15-0 if both nCE2 and nCE1 are low.

The memory space is selected by asserting low nOE for read accesses or nWE for write accesses, combined with the low assertion of nCE2/nCE1 and nREG.

The I/O Space is selected by asserting low nIORD for read accesses or nIOWR for write accesses [instead of nOE/nWE for memory Space], combined with nCE2/nCE1. Note that nREG must also be asserted low during accesses to I/O Space.

Three type of accesses are allowed for a 16-bit PC Card:

Note that 8-bit accesses at odd addresses are not supported and do not lead to the low assertion of nCE2. A 32-bit AHB request is translated into two 16-bit memory accesses.

Note that a 16-bit AHB access is converted into a single 8-bit memory transfer: nCE1 is asserted low, nCE2 is asserted high and only the even Byte on D7-D0 is valid. Instead

a 32-bit AHB access is converted into two 8-bit memory transfers at even addresses: nCE1 is asserted low, NCE2 is asserted high and only the even bytes are valid.

Table 204. 16-bit PC-Card signals and access type

nCE2nCE1nREGnOE/nWEnIORD/nIOWRA10A9A7-1A0SpaceAccess TypeAllowed/not Allowed
10101XXX-XXCommon Memory SpaceRead/Write byte on D7-D0YES
01101XXX-XXRead/Write byte on D15-D8Not supported
00101XXX-X0Read/Write word on D15-D0YES
X000101X-X0Attribute SpaceRead or Write Configuration registersYES
X000100X-X0Read or Write CIS (Card Information Structure)YES
10001XXX-X1Attribute SpaceInvalid Read or Write (odd address)YES
01001XXX-XxInvalid Read or Write (odd address)YES
10010XXX-X0I/O spaceRead Even Byte on D7-0YES
10010XXX-X1Read Odd Byte on D7-0YES
10010XXX-X0Write Even Byte on D7-0YES
10010XXX-X1Write Odd Byte on D7-0YES
00010XXX-X0Read Word on D15-0YES
00010XXX-X0Write word on D15-0YES
01010XXX-XXRead Odd Byte on D15-8Not supported
01010XXX-XXWrite Odd Byte on D15-8Not supported
01010XXX-XX

The FSMC Bank 4 gives access to those 3 memory spaces as described in Section 31.4.2: NAND/PC Card address mapping and Table 171: Memory mapping and timing registers .

Wait Feature

The CompactFlash Storage or PC Card may request the FSMC to extend the length of the access phase programmed by MEMWAITx/ATTWAITx/IOWAITx bits, asserting the nWAIT signal after nOE/nWE or nIORD/nIOWR activation if the wait feature is enabled through the PWAITEN bit in the FSMC_PCRx register. In order to detect the nWAIT assertion correctly, the MEMWAITx/ATTWAITx/IOWAITx bits must be programmed as follows:

\( xxWAITx \geq 4 + \text{max\_wait\_assertion\_time}/HCLK \)

Where \( \text{max\_wait\_assertion\_time} \) is the maximum time taken by NWAIT to go low once nOE/nWE or nIORD/nIOWR is low.

After the de-assertion of nWAIT, the FSMC extends the WAIT phase for 4 HCLK clock cycles.

31.6.8 NAND flash/PC Card control registers

The NAND flash/PC Card control registers have to be accessed by words (32 bits).

PC Card/NAND flash control registers 2..4 (FSMC_PCR2..4)

Address offset: \( 0xA0000000 + 0x40 + 0x20 \cdot (x - 1) \) , \( x = 2..4 \)

Reset value: 0x0000 0018

313029282726252423222120191817161514131211109876543210
ReservedECCPS[2:0]TAR[2:0]TCLR[2:0]Res.ECCENPWID[1:0]PTYPPBKENPWAITENReserved
rwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 Reserved, must be kept at reset value.

Bits 19:17 ECCPS[2:0] : ECC page size.

Defines the page size for the extended ECC:

Bits 16:13 TAR[2:0] : ALE to RE delay.

Sets time from ALE low to RE low in number of AHB clock cycles (HCLK).

Time is: \( t\_ar = (TAR + SET + 2) \times THCLK \) where THCLK is the HCLK clock period

Note: SET is MEMSET or ATTSET according to the addressed space.

Bits 12:9 TCLR[2:0] : CLE to RE delay.

Sets time from CLE low to RE low in number of AHB clock cycles (HCLK).

Time is: \( t\_clr = (TCLR + SET + 2) \times THCLK \) where THCLK is the HCLK clock period

Note: SET is MEMSET or ATTSET according to the addressed space.

Bits 8:7 Reserved, must be kept at reset value.

Bit 6 ECCEN : ECC computation logic enable bit

Bits 5:4 PWID[1:0] : Databus width.

Defines the external memory device width.

00: 8 bits

01: 16 bits (default after reset). This value is mandatory for PC Cards.

10: reserved, do not use

11: reserved, do not use

Bit 3 PTYP : Memory type.

Defines the type of device attached to the corresponding memory bank:

0: PC Card, CompactFlash, CF+ or PCMCIA

1: NAND flash (default after reset)

Bit 2 PBKEN : PC Card/NAND flash memory bank enable bit.

Enables the memory bank. Accessing a disabled memory bank causes an ERROR on AHB bus

0: Corresponding memory bank is disabled (default after reset)

1: Corresponding memory bank is enabled

Bit 1 PWAITEN : Wait feature enable bit.

Enables the Wait feature for the PC Card/NAND flash memory bank:

0: disabled

1: enabled

Note: For a PC Card, when the wait feature is enabled, the MEMWAITx/ATTWAITx/IOWAITx bits must be programmed to a value as follows:

\( xxWAITx \geq 4 + \max\_wait\_assertion\_time/HCLK \)

Where max_wait_assertion_time is the maximum time taken by NWAIT to go low once nOE/nWE or nIORD/nIOWR is low.

Bit 0 Reserved, must be kept at reset value.

FIFO status and interrupt register 2..4 (FSMC_SR2..4)

Address offset: 0xA000 0000 + 0x44 + 0x20 * (x-1), x = 2..4

Reset value: 0x0000 0040

This register contains information about FIFO status and interrupt. The FSMC has a FIFO that is used when writing to memories to store up to 16 words of data from the AHB.

This is used to quickly write to the AHB and free it for transactions to peripherals other than the FSMC, while the FSMC is draining its FIFO into the memory. This register has one of its bits that indicates the status of the FIFO, for ECC purposes.

The ECC is calculated while the data are written to the memory, so in order to read the correct ECC the software must wait until the FIFO is empty.

313029282726252423222120191817161514131211109876543210
ReservedF
EMPT
I
FEN
I
LEN
I
REN
I
FS
I
LS
I
RS
rrwrwrwrwrwrw

Bits 31:7 Reserved, must be kept at reset value.

Note: This bit is set by programming it to 1 by software.

Note: This bit is set by programming it to 1 by software.

Common memory space timing register 2..4 (FSMC_PMEM2..4)

Address offset: Address: 0xA000 0000 + 0x48 + 0x20 * (x – 1), x = 2..4

Reset value: 0xFCFC FCFC

Each FSMC_PMEMx (x = 2..4) read/write register contains the timing information for PC Card or NAND flash memory bank x, used for access to the common memory space of the 16-bit PC Card/CompactFlash, or to access the NAND flash for command, address write access and data read/write access.

313029282726252423222120191817161514131211109876543210
MEMHIZ[7:0]MEMHOLD[7:0]MEMWAIT[7:0]MEMSET[7:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:24 MEMHIZx[7:0] : Common memory x databus HiZ time

Defines the number of HCLK clock cycles during which the databus is kept in HiZ after the start of a PC Card/NAND flash write access to common memory space on socket x. Only valid for write transaction:

0000 0000: 1 HCLK cycle
1111 1110: 255 HCLK cycles
1111 1111: Reserved

Bits 23:16 MEMHOLDx[7:0] : Common memory x hold time

For NAND flash read accesses to the common memory space, these bits define the number of \( (HCLK+2) \) clock cycles during which the address is held after the command is deasserted (NWE, NOE).

For NAND flash write accesses to the common memory space, these bits define the number of HCLK clock cycles during which the data are held after the command is deasserted (NWE, NOE).

0000 0000: Reserved
0000 0001: 1 HCLK cycle for write accesses, 3 HCLK cycles for read accesses
1111 1110: 254 HCLK cycle for write accesses, 256 HCLK cycles for read accesses
1111 1111: Reserved

Bits 15:8 MEMWAITx[7:0] : Common memory x wait time

Defines the minimum number of HCLK \( (+1) \) clock cycles to assert the command (NWE, NOE), for PC Card/NAND flash read or write access to common memory space on socket x. The duration for command assertion is extended if the wait signal (NWAIT) is active (low) at the end of the programmed value of HCLK:

0000 0000: Reserved
0000 0001: 2 HCLK cycles (+ wait cycle introduced by deasserting NWAIT)
1111 1110: 255 HCLK cycles (+ wait cycle introduced by deasserting NWAIT)
1111 1111: Reserved.

Bits 7:0 MEMSETx[7:0] : Common memory x setup time

Defines the number of HCLK \( (+1) \) clock cycles to set up the address before the command assertion (NWE, NOE), for PC Card/NAND flash read or write access to common memory space on socket x:

0000 0000: 1 HCLK cycle
1111 1110: 255 HCLK cycles
1111 1111: Reserved

Attribute memory space timing registers 2..4 (FSMC_PATT2..4)

Address offset: 0xA000 0000 + 0x4C + 0x20 * (x – 1), x = 2..4

Reset value: 0xFCFC FCFC

Each FSMC_PATTx (x = 2..4) read/write register contains the timing information for PC Card/CompactFlash or NAND flash memory bank x. It is used for 8-bit accesses to the attribute memory space of the PC Card/CompactFlash or to access the NAND flash for the last address write access if the timing must differ from that of previous accesses (for Ready/Busy management, refer to Section 31.6.5: NAND flash prewait functionality ).

313029282726252423222120191817161514131211109876543210
ATTHIZ[7:0]ATTHOLD[7:0]ATTWAIT[7:0]ATTSET[7:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:24 ATTHIZ[7:0] : Attribute memory x databus HiZ time

Defines the number of HCLK clock cycles during which the databus is kept in HiZ after the start of a PC CARD/NAND flash write access to attribute memory space on socket x. Only valid for write transaction:
0000 0000: 0 HCLK cycle
1111 1110: 255 HCLK cycles
1111 1111: Reserved.

Bits 23:16 ATTHOLD[7:0] : Attribute memory x hold time

For PC Card/NAND flash read accesses to attribute memory space on socket x, these bits define the number of HCLK clock cycles (HCLK +2) clock cycles during which the address is held after the command is deasserted (NWE, NOE).
For PC Card/NAND flash write accesses to attribute memory space on socket x, these bits define the number of HCLK clock cycles during which the data are held after the command is deasserted (NWE, NOE).
0000 0000: reserved
0000 0001: 1 HCLK cycle for write access, 3 HCLK cycles for read accesses
1111 1110: 254 HCLK cycle for write access, 256 HCLK cycles for read accesses
1111 1111: Reserved

Bits 15:8 ATTWAIT[7:0] : Attribute memory x wait time

Defines the minimum number of HCLK (+1) clock cycles to assert the command (NWE, NOE), for PC Card/NAND flash read or write access to attribute memory space on socket x. The duration for command assertion is extended if the wait signal (NWAIT) is active (low) at the end of the programmed value of HCLK:
0000 0000: Reserved
0000 0001: 2 HCLK cycles (+ wait cycle introduced by deassertion of NWAIT)
1111 1110: 255 HCLK cycles (+ wait cycle introduced by deasserting NWAIT)
1111 1111: Reserved.

Bits 7:0 ATTSET[7:0] : Attribute memory x setup time

Defines the number of HCLK (+1) clock cycles to set up address before the command assertion (NWE, NOE), for PC CARD/NAND flash read or write access to attribute memory space on socket x:
0000 0000: 1 HCLK cycle
1111 1110: 255 HCLK cycles
1111 1111: Reserved.

I/O space timing register 4 (FSMC_PIO4)

Address offset: 0xA000 0000 + 0xB0
Reset value: 0xFCFCFCFC

The FSMC_PIO4 read/write registers contain the timing information used to gain access to the I/O space of the 16-bit PC Card/CompactFlash.

313029282726252423222120191817161514131211109876543210
IOHIZ[7:0]IOHOLD[7:0]IOWAIT[7:0]IOSET[7:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:24 IOHIZ[7:0] : I/O x databus HiZ time

Defines the number of HCLK clock cycles during which the databus is kept in HiZ after the start of a PC Card write access to I/O space on socket x. Only valid for write transaction:

0000 0000: 0 HCLK cycle

1111 1111: 255 HCLK cycles (default value after reset)

Bits 23:16 IOHOLD[7:0] : I/O x hold time

Defines the number of HCLK clock cycles to hold address (and data for write access) after the command deassertion (NWE, NOE), for PC Card read or write access to I/O space on socket x:

0000 0000: reserved

0000 0001: 1 HCLK cycle

1111 1111: 255 HCLK cycles (default value after reset)

Bits 15:8 IOWAIT[7:0] : I/O x wait time

Defines the minimum number of HCLK (+1) clock cycles to assert the command (SMNWE, SMNOE), for PC Card read or write access to I/O space on socket x. The duration for command assertion is extended if the wait signal (NWAIT) is active (low) at the end of the programmed value of HCLK:

0000 0000: reserved, do not use this value

0000 0001: 2 HCLK cycles (+ wait cycle introduced by deassertion of NWAIT)

1111 1111: 256 HCLK cycles (+ wait cycle introduced by the Card deasserting NWAIT) (default value after reset)

Bits 7:0 IOSET[7:0] : I/O x setup time

Defines the number of HCLK (+1) clock cycles to set up the address before the command assertion (NWE, NOE), for PC Card read or write access to I/O space on socket x:

0000 0000: 1 HCLK cycle

1111 1111: 256 HCLK cycles (default value after reset)

ECC result registers 2/3 (FSMC_ECCR2/3)

Address offset: \( 0xA000\ 0000 + 0x54 + 0x20 * (x - 1) \) , x = 2 or 3

Reset value: 0x0000 0000

These registers contain the current error correction code value computed by the ECC computation modules of the FSMC controller (one module per NAND flash memory bank). When the CPU reads the data from a NAND flash memory page at the correct address (refer to Section 31.6.6 ), the data read from or written to the NAND flash are processed automatically by ECC computation module. At the end of X bytes read (according to the ECCPS field in the FSMC_PCRx registers), the CPU must read the computed ECC value from the FSMC_ECCx registers, and then verify whether these computed parity data are the same as the parity value recorded in the spare area, to determine whether a page is valid, and, to correct it if applicable. The FSMC_ECCRx registers should be cleared after being read by setting the ECCEN bit to zero. For computing a new data block, the ECCEN bit must be set to one.

313029282726252423222120191817161514131211109876543210
ECCx[31:0]
r

Bits 31:0 ECCx[31:0] : ECC result

This field provides the value computed by the ECC computation logic. Table 205 hereafter describes the contents of these bit fields.

Table 205. ECC result relevant bits

ECCPS[2:0]Page size in bytesECC bits
000256ECC[21:0]
001512ECC[23:0]
0101024ECC[25:0]
0112048ECC[27:0]
1004096ECC[29:0]
1018192ECC[31:0]

31.6.9 FSMC register map

The following table summarizes the FSMC registers.

Table 206. FSMC register map

OffsetRegister313029282726252423222120191817161514131211109876543210
0000FSMC_BCR1ReservedCBURSTRWCPSIZE[2:0]ASYNCWAITEXTMODWAITENWRENWAITCFGWRAPMODWAITPOLBURSTENReservedFACCENMWID[1:0]MTYP[0:1]MUXENMBKEN
0008FSMC_BCR2ReservedCBURSTRWCPSIZE[2:0]ASYNCWAITEXTMODWAITENWRENWAITCFGWRAPMODWAITPOLBURSTENReservedFACCENMWID[1:0]MTYP[0:1]MUXENMBKEN
0010FSMC_BCR3ReservedCBURSTRWCPSIZE[2:0]ASYNCWAITEXTMODWAITENWRENWAITCFGWRAPMODWAITPOLBURSTENReservedFACCENMWID[1:0]MTYP[0:1]MUXENMBKEN
0018FSMC_BCR4ReservedCBURSTRWCPSIZE[2:0]ASYNCWAITEXTMODWAITENWRENWAITCFGWRAPMODWAITPOLBURSTENReservedFACCENMWID[1:0]MTYP[0:1]MUXENMBKEN
0004FSMC_BTR1Res.ACCMOD[1:0]DATLAT[3:0]CLKDIV[3:0]BUSTURN[3:0]DATAST[7:0]ADDHL[3:0]ADDSET[3:0]
000CFSMC_BTR2Res.ACCMOD[1:0]DATLAT[3:0]CLKDIV[3:0]BUSTURN[3:0]DATAST[7:0]ADDHL[3:0]ADDSET[3:0]
0014FSMC_BTR3Res.ACCMOD[1:0]DATLAT[3:0]CLKDIV[3:0]BUSTURN[3:0]DATAST[7:0]ADDHL[3:0]ADDSET[3:0]
001CFSMC_BTR4Res.ACCMOD[1:0]DATLAT[3:0]CLKDIV[3:0]BUSTURN[3:0]DATAST[7:0]ADDHL[3:0]ADDSET[3:0]
0104FSMC_BWTR 1Res.ACCMOD[1:0]Res.BUSTURN[3:0]DATAST[7:0]ADDHL[3:0]ADDSET[3:0]
010CFSMC_BWTR 2Res.ACCMOD[1:0]Res.BUSTURN[3:0]DATAST[7:0]ADDHL[3:0]ADDSET[3:0]

Table 206. FSMC register map (continued)

OffsetRegister313029282726252423222120191817161514131211109876543210
0114FSMC_BWTR 3Res.ACC
MOD
[1:0]
Res.
011CFSMC_BWTR 4Res.ACC
MOD
[1:0]
Res.
0xA000
0060
FSMC_PCR2Reserved
0xA000
0080
FSMC_PCR3Reserved
0xA000
00A0
FSMC_PCR4Reserved
0xA000
0064
FSMC_SR2Reserved
0xA000
0084
FSMC_SR3Reserved
0xA000
00A4
FSMC_SR4Reserved
0xA000
0068
FSMC_PMEM 2MEMHIZ[7:0]MEMHOLD[7:0]MEMWAIT[7:0]MEMSET[7:0]
0xA000
0088
FSMC_PMEM 3MEMHIZ[7:0]MEMHOLD[7:0]MEMWAIT[7:0]MEMSET[7:0]
0xA000
00A8
FSMC_PMEM 4MEMHIZ[7:0]MEMHOLD[7:0]MEMWAIT[7:0]MEMSET[7:0]
0xA000
006C
FSMC_PATT2ATTHIZ[7:0]ATTHOLD[7:0]ATTWAIT[7:0]ATTSET[7:0]
0xA000
008C
FSMC_PATT3ATTHIZ[7:0]ATTHOLD[7:0]ATTWAIT[7:0]ATTSET[7:0]
0xA000
00AC
FSMC_PATT4ATTHIZ[7:0]ATTHOLD[7:0]ATTWAIT[7:0]ATTSET[7:0]
0xA000
00B0
FSMC_PIO4IOHIZ[7:0]IOHOLD[7:0]IOWAIT[7:0]IOSET[7:0]
0xA000
0074
FSMC_ECCR2ECC[31:0]
0xA000
0094
FSMC_ECCR3ECC[31:0]

Refer to Section 2.3: Memory map for the register boundary addresses.