6. RAMs configuration controller (RAMCFG)

6.1 Introduction

The RAMCFG configures the features of the internal SRAMs (SRAM1 and SRAM2).

6.2 RAMCFG main features

The internal SRAMs support some of the features listed hereafter, configured in RAMCFG:

6.3 RAMCFG functional description

6.3.1 Internal SRAMs features

Two main SRAMs (SRAM1 and SRAM2) are embedded in the devices, together with 2.4 GHz RADIO RXTXRAM and Sequence SRAM, each with specific features:

Refer to Section 7: Embedded flash memory (FLASH) for more details.

Refer to Section 7: Embedded flash memory (FLASH) for more details.

Refer to Section 37: Tamper and backup registers (TAMP) for more details.

Refer to Section 6.3.2 and Section 6.3.3 for more details.

Refer to Section 6.3.4 and Section 6.3.5 for more details.

Table 33. SRAMs features

FeatureSRAM1SRAM22.4 GHz RADIO SRAMs (SRAM6)
BAM in Stop 0 modeXX-
Optional retention in Stop modeXX(1)
Optional retention in Standby modeXXX
Erased with RDP regressionXX-
Erased with tamper detection-X-
Backup domain reset---
Optionally erased with system resetXX-
Software eraseXX-
Parity-X-
Write protection-X-
Wait statesXX-

1. 2.4 GHz RADIO SRAMs are always retained in Stop modes.

6.3.2 Internal SRAM parity

Parity is supported by SRAM2 when enabled with the SRAM2_PE user option bit, and when, furthermore, either PEIE or PENMI is enabled. Refer to Section 7: Embedded flash memory (FLASH) for more details.

Four parity bits are added per 32 bits of SRAM (1 bit per byte) to increase memory robustness.

The parity bits are computed and stored when writing into the SRAM2, then they are automatically checked when reading. If one byte parity fails, an NMI or IRQ can be generated. The same error can also be linked to the break input (BRK_IN) of TIM1, TIM16, and TIM17, with the SYSCFG_CFGR2.SPL control bit.

Note: When enabling SRAM2 parity, initialize by software the whole RAM at the beginning of the code, to avoid getting parity errors when reading noninitialized addresses.

When a parity error is detected, the PED and CPED bits are set in RAMCFG SRAM2 interrupt status register (RAMCFG_M2ISR) and RAMCFG SRAM2 interrupt clear register (RAMCFG_M2ICR) . An interrupt or NMI can be generated if enabled by the PEIE or PENMI bits in the RAMCFG SRAM2 interrupt enable register (RAMCFG_M2IER) . When the ALE bit is set in RAMCFG SRAM2 control register (RAMCFG_M2CR) , the failing parity SRAM offset word address is stored in the RAMCFG SRAM2 parity error address register (RAMCFG_M2PEAR) , together with the failing byte(s) parity error flag and the AHB bus master ID.

When the PED and CPED bits are already set any subsequent parity failing access SRAM offset word address is no longer updated. A new parity error SRAM offset word address is only latched when PED and CPED are 0.

Unaligned word and half word accesses can generate a parity error on bytes not belonging to the accessed data (see Table 34 ).

Table 34. SRAM parity access error

AccessParity error on bytes not belonging to data
AlignedAll reported errors belong to the bytes read.
Unaligned word at byte address offset 0x1An error on word offset address byte 0 does not belong to the read data.
Unaligned word at byte address offset 0x2All reported errors belong to the bytes read.
Unaligned word at byte address offset 0x3An error on word offset address byte 3 does not belong to the read data.
Unaligned half word at byte address offset 0x1An error on word offset address byte 0 or 3 does not belong to the read data.
Unaligned half word at byte address offset 0x3All reported errors belong to the bytes read.

Table 35. SRAM parity error bus master ID

SRAMCPUDebuggerDMA port 0DMA port 1
SRAM20b0100b0110b1100b111

6.3.3 Internal SRAM write protection

The SRAM2 is made of 64 1-Kbyte write protect pages, each can be write-protected by setting its corresponding PxWP (x = 0 to 63) bit in the RAMCFG SRAM2 write protection register 1 (RAMCFG_M2WPR1) and RAMCFG SRAM2 write protection register 2 (RAMCFG_M2WPR2) .

When writing to a write-protected page, the write is ignored and a bus error is generated.

Any SRAM erase operation erases the write-protected pages as well.

6.3.4 Internal SRAM read access latency

To read correctly data, the number of wait states (WS) must be correctly programmed in the WSC[2:0] field of the RAM control register, depending upon the voltage scaling range for SRAM1 and SRAM2, and upon AHB hclk1 clock frequency (see Table 36 ).

Table 36. Number of wait states versus hclk frequency and voltage range scaling

Wait states (latency)AHB hclk1 (MHz)
V CORE range 1V CORE range 2
0 WS (1 AHB cycle)≤ 100≤ 12
1 WS (2 AHB cycle)-≤ 16

After reset, the SRAM1 and SRAM2 hclk1 frequency is 16 MHz, 1 wait state (WSC) is configured in RAMCFG_MxCR.

Before entering Stop 1 mode, the software must set SRAM1 and SRAM2 wait states to at least 1 in RAMCFG_MxCR, to comply with the SYSCLK 16 MHz and range 2 configuration when exiting the mode.

6.3.5 Internal SRAM erase

SRAM erase can be requested by executing this software sequence:

  1. 1. Write 0xCA in the RAMCFG SRAMx erase key register (RAMCFG_MxERKEYR) .
  2. 2. Write 0x53 in the RAMCFG SRAMx erase key register (RAMCFG_MxERKEYR) .
  3. 3. Write 1 in the SRAMER bit of the RAMCFG SRAM1 control register (RAMCFG_M1CR) .

SRAM erase can also start because of a tamper (see Section 37: Tamper and backup registers (TAMP) ), or upon a reset condition (see Section 7.4: FLASH option bytes ).

SRAMBUSY flag is set in the related SRAM interrupt status register as long as the erase is ongoing.

The total duration of each SRAM erase is N x AHB clock cycles, where N is the size of the SRAM in 32-bit words.

If the SRAM is read while an erase is ongoing, default zero data is read on the AHB bus.

If the SRAM is written while an erase is ongoing, wait states are inserted on the AHB bus until the end of the erase operation.

An SRAM erase operation also erases write-protected pages.

6.4 RAMCFG low-power modes

Table 37. Effect of low-power modes on RAMCFG

ModeDescription
SleepNo effect. RAMCFG interrupts cause the device to exit the Sleep mode.
StopThe content of RAMCFG registers is kept. The SRAM2 parity is functional and an interrupt or NMI causes the device to exit Stop 0 mode.
StandbyThe RAMCFG peripheral is powered down and must be reinitialized after exiting Standby mode.

6.5 RAMCFG interrupts

Table 38. RAMCFG interrupt requests

Interrupt acronymInterrupt eventEvent flagEnable control bitInterrupt clear methodExit Sleep modeExit Stop modeExit Standby mode
RAMCFGParity error detectionPEDPEIE and PENMI = 0Write 1 in CPEDYesYes (1)No
NMIPENMI

1. Stop 0 mode only.

6.6 RAMCFG registers

In the registers described below, x refers to SRAM index.

Access to all RAMCFG registers can be protected by GTZC_TZSC RAMCFGSEC and GTZC_TZSC RAMCFGSPRIV.

6.6.1 RAMCFG SRAM1 control register (RAMCFG_M1CR)

Address offset: 0x000

Reset value: 0x0001 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.WSC[2:0]
rwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.SRAMERRes.Res.Res.Res.Res.Res.Res.Res.
rs

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

Bits 18:16 WSC[2:0] : SRAM1 wait state configuration

This field is used to program the number of wait states inserted on the AHB when reading the SRAM1, depending on its access time.

000: Zero wait states

001: One wait state

...

111: Seven wait states

Note: Before entering Stop 1 mode, software must set SRAM1 wait states to at least 1.

Bits 15:9 Reserved, must be kept at reset value.

Bit 8 SRAMER : SRAM1 erase

This bit can be set by software only after writing the unlock sequence in the ERASEKEY field of the RAMCFG_M1ERKEYR register. Setting this bit starts the SRAM1 erase. This bit is automatically cleared by hardware at the end of the erase operation.

0: No erase operation ongoing

1: Erase operation ongoing

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

6.6.2 RAMCFG SRAM1 interrupt status register (RAMCFG_M1ISR)

Address offset: 0x008

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.SRAM BUSYRes.Res.Res.Res.Res.Res.Res.Res.
r

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

Bit 8 SRAMBUSY : SRAM busy with erase operation.

0: No memory erase operation ongoing

1: Memory erase operation ongoing

Note: Depending on the SRAM, the erase operation can be performed due to software request, system reset if the enabled by user option, tamper detection or RDP regression. Refer to Table 33.

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

6.6.3 RAMCFG SRAMx erase key register (RAMCFG_MxERKEYR)

Address offset: \( 0x028 + 0x040 * (x - 1) \) , ( \( x = 1 \) to \( 2 \) )

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.ERASEKEY[7:0]
wwwwwwww

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

Bits 7:0 ERASEKEY[7:0] : Erase write protection key

The following steps are required to unlock the write protection of the SRAMER bit in the RAMCFG_MxCR register.

  1. a) Write 0xCA into ERASEKEY[7:0]
  2. b) Write 0x53 into ERASEKEY[7:0]

Note: Writing a wrong key reactivates the write protection.

6.6.4 RAMCFG SRAM2 control register (RAMCFG_M2CR)

Address offset: 0x040

Reset value: 0x0001 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.WSC[2:0]
rwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.SRAMERRes.Res.Res.ALERes.Res.Res.Res.
rsrw

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

Bits 18:16 WSC[2:0] : SRAM2 wait state configuration

This field is used to program the number of wait states inserted on the AHB when reading the SRAM2, depending on its access time.

000: 0 wait state

001: 1 wait state

...

111: 7 wait states

Note: Before entering Stop 1 mode software must set SRAM2 wait states to at least 1.

Bits 15:9 Reserved, must be kept at reset value.

Bit 8 SRAMER : SRAM2 erase

This bit can be set by software only after writing the unlock sequence in the ERASEKEY field of the RAMCFG_M2ERKEYR register. Setting this bit starts the SRAM2 erase. This bit is automatically cleared by hardware at the end of the erase operation.

0: No erase operation ongoing

1: Erase operation ongoing

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

Bit 4 ALE : SRAM2 parity fail address latch enable

0: Failing address not stored in the SRAM2 parity error address register RAMCFG_M2PEAR

1: Failing address stored in the SRAM2 parity error address register RAMCFG_M2PEAR

Bits 3:0 Reserved, must be kept at reset value.

6.6.5 RAMCFG SRAM2 interrupt enable register (RAMCFG_M2IER)

Address offset: 0x044

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.PENMI
rs
Res.PEIE
rw
Res.

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

Bit 3 PENMI : Parity error NMI.

This bit is set by software and cleared only by a global RAMCFG reset

0: NMI not generated in case of parity error

1: NMI generated in case of parity error

Note: When PENMI bit is set, the RAMCFG maskable interrupt is not generated for a parity error whatever PEIE bit value.

Bit 2 Reserved, must be kept at reset value.

Bit 1 PEIE : Parity error interrupt enable

0: Parity error interrupt disabled

1: Parity error interrupt enabled

Bit 0 Reserved, must be kept at reset value.

6.6.6 RAMCFG SRAM2 interrupt status register (RAMCFG_M2ISR)

Address offset: 0x048

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.SRAM
BUSY
Res.Res.Res.Res.Res.Res.PEDRes.
rr

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

Bit 8 SRAMBUSY : SRAM2 busy with erase operation.

0: No memory erase operation ongoing

1: Memory erase operation ongoing

Note: Depending on the SRAM2, the erase operation can be performed due to software request, system reset if the enabled by user option, tamper detection or RDP regression. Refer to Table 33.

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

Bit 1 PED : Parity error detected

0: No parity error detected

1: Parity error detected

Bit 0 Reserved, must be kept at reset value.

6.6.7 RAMCFG SRAM2 parity error address register (RAMCFG_M2PEAR)

Address offset: 0x050

Reset value: 0x0000 0000

31302928272625242322212019181716
BYTE[3:0]ID[3:0]Res.Res.Res.Res.Res.Res.Res.Res.
rrrrrrrr
1514131211109876543210
PEA[15:0]
rrrrrrrrrrrrrrrr

Bits 31:28 BYTE[3:0] : Byte parity error flag.

When ALE bit is set in RAMCFG_M2CR register, this field is updated when PED and CPED are zero and a new parity error is detected, with:

1xxx: parity error detected on fourth byte in word aligned address

x1xx: parity error detected on third byte in word aligned address

xx1x: parity error detected on second byte in word aligned address

xxx1: parity error detected on first byte in word aligned address

Bits 27:24 ID[3:0] : Parity error AHB bus master ID.

When ALE bit is set in RAMCFG_M2CR register, this field is updated when PED and CPED are zero and a new parity error is detected, with:

010: parity error detected on CPU access
011: parity error detected on Debugger access
110: parity error detected on DMA master port 0 access
111: parity error detected on DMA master port 1 access
Others: reserved

Bits 23:16 Reserved, must be kept at reset value.

Bits 15:0 PEA[15:0] : Parity error SRAM word aligned address offset.PEA[1:0] read 0b00.

When ALE bit is set in RAMCFG_M2CR register, this field is updated when PED and CPED are zero and a new parity error is detected, with the SRAM word aligned address offset corresponding to the parity error.

6.6.8 RAMCFG SRAM2 interrupt clear register (RAMCFG_M2ICR)

Address offset: 0x054
Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CPED
rc_w1
Res.

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

Bit 1 CPED : Clear parity error detect bit

Writing 1 to this bit clears the PED bit in RAMCFG_M2ISR.

Reading this bit returns the value of the RAMCFG_M2ISR PED bit.

Bit 0 Reserved, must be kept at reset value.

6.6.9 RAMCFG SRAM2 write protection register 1 (RAMCFG_M2WPR1)

Address offset: 0x058
Reset value: 0x0000 0000

31302928272625242322212019181716
P31WPP30WPP29WPP28WPP27WPP26WPP25WPP24WPP23WPP22WPP21WPP20WPP19WPP18WPP17WPP16WP
rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrs
1514131211109876543210
P15WPP14WPP13WPP12WPP11WPP10WPP9WPP8WPP7WPP6WPP5WPP4WPP3WPP2WPP1WPP0WP
rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrs

Bits 31:0 PyWP : SRAM2 1-Kbyte write protect page y write protection (y = 31 to 0)

These bits are set by software and cleared only by a system reset.

0: Write protection of SRAM2 1-Kbyte write protect page y is disabled.

1: Write protection of SRAM2 1-Kbyte write protect page y is enabled.

6.6.10 RAMCFG SRAM2 write protection register 2 (RAMCFG_M2WPR2)

Address offset: 0x05C

Reset value: 0x0000 0000

31302928272625242322212019181716
P63WPP62WPP61WPP60WPP59WPP58WPP57WPP56WPP55WPP54WPP53WPP52WPP51WPP50WPP49WPP48WP
rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrs
1514131211109876543210
P47WPP46WPP45WPP44WPP43WPP42WPP41WPP40WPP39WPP38WPP37WPP36WPP35WPP34WPP33WPP32WP
rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrs

Bits 31:0 PyWP : SRAM2 1-Kbyte write protect page y write protection (y = 63 to 32)

These bits are set by software and cleared only by a system reset.

0: Write protection of SRAM2 1-Kbyte write protect page y is disabled.

1: Write protection of SRAM2 1-Kbyte write protect page y is enabled.

6.6.11 RAMCFG register map

Table 39. RAMCFG register map and reset values

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x000RAMCFG_M1CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.WSC[2:0]Res.Res.Res.Res.Res.Res.Res.SRAMERRes.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0010
0x004ReservedReserved
0x008RAMCFG_M1ISRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SRAMBUSYRes.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0
0x00C to 0x024ReservedReserved
0x028RAMCFG_M1ERKEYRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ERASEKEY[7:0]
Reset value000000000
0x02C to 0x03CReservedReserved
0x040RAMCFG_M2CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.WSC[2:0]Res.Res.Res.Res.Res.Res.Res.SRAMERRes.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value00100
0x044RAMCFG_M2IERRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.PENMIRes.PEIERes.
Reset value00
0x048RAMCFG_M2ISRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SRAMBUSYRes.Res.Res.Res.Res.Res.Res.PEDRes.
Reset value00
0x04CReservedReserved
0x050RAMCFG_M2PEARBYTE[3:0]ID[3:0]Res.Res.Res.Res.Res.Res.Res.Res.PEA[15:0]
Reset value000000000000000000000000
0x054RAMCFG_M2ICRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CPEDRes.
Reset value0
0x058RAMCFG_M2WPR1P31WPP30WPP29WPP28WPP27WPP26WPP25WPP24WPP23WPP22WPP21WPP20WPP19WPP18WPP17WPP16WPP15WPP14WPP13WPP12WPP11WPP10WPP9WPP8WPP7WPP6WPP5WPP4WPP3WPP2WPP1WPP0WP
Reset value00000000000000000000000000000000
0x05CRAMCFG_M2WPR2P63WPP62WPP61WPP60WPP59WPP58WPP57WPP56WPP55WPP54WPP53WPP52WPP51WPP50WPP49WPP48WPP47WPP46WPP45WPP44WPP43WPP42WPP41WPP40WPP39WPP38WPP37WPP36WPP35WPP34WPP33WPP32WP
Reset value00000000000000000000000000000000
0x060 to 0x064ReservedReserved
0x068RAMCFG_M2ERKEYRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ERASEKEY[7:0]
Reset value000000000
0x06C to 0x3FCReservedReserved
Refer to Section 2.3: Memory organization for the register boundary addresses.