5. RAMs configuration controller (RAMCFG)

5.1 RAMCFG introduction

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

5.2 RAMCFG main features

The internal SRAM supports some of the features listed hereafter, configured in RAMCFG:

5.3 RAMCFG functional description

5.3.1 Internal SRAMs features

Two SRAMs are embedded in the device, each with specific features:

Table 14. SRAM density (Kbytes)

SRAM featureSRAM1SRAM2
STM32C53x/5423232
STM32C55x/5626464
STM32C59x/5A3128128

The table below summarizes the features supported by each internal SRAM

Table 15. Internal SRAMs features

SRAM featureSRAM1SRAM2
Optional retention in Standby mode--
Optional retention in Stop modeXX
Erased with RDP level regressionXX
Optionally erased with tamper detection-X
Optionally erased with system resetXX
Software eraseXX
ECC-X
Write protection-X

5.3.2 Error code correction (SRAM2)

The ECC is supported by SRAM2 when enabled with the SRAM2_ECC user option bits. Refer to Section 6: Embedded flash memory (FLASH) for more details.

Seven ECC bits are added per 32 bits of SRAM, allowing 2-bit error detection and 1-bit error correction on memory read access.

As the ECC is calculated and checked for a 32-bit word, byte and half-word write accesses are managed by the SRAM interface by first reading the whole word, then write the word again with the new byte/half-word value. ECC double errors are also detected during these bytes or half-word AHB write accesses (read/modify/write done by interface). The byte or half-word write access latency is two AHB clock cycles.

Caution: In case of a byte or half-word write on SRAM with ECC, the read/modify/write operation is done in a buffer. The buffer content is written into the SRAM two AHB clock cycles after the SRAM AHB is released (when the SRAM is no more accessed).

Single and double ECC errors

When a single error is detected, it is automatically corrected and the SEDC/CSEDC bits are set in RAMCFG_MxISR and RAMCFG_MxICR respectively. An interrupt is generated if enabled by the SEIE bit in RAMCFG_MxIER. The failing address is stored in RAMCFG_MxSEAR if the ALE bit is set in RAMCFG_MxCR.

Caution: Single errors cannot be detected when the SEDC bit is set.

When a double error is detected, the DED and CDED bits are set in RAMCFG_MxISR and RAMCFG_MxICR respectively. An interrupt or NMI is generated if enabled by the DEIE or ECCNMI bit in RAMCFG_MxIER. The failing address is stored in RAMCFG_MxDEAR if the ALE bit is set in RAMCFG_MxCR.

Caution: Double errors cannot be detected when the DED bit is set.

SRAM2 with ECC memory map

When the ECC is enabled for SRAM2, the full SRAM2 has ECC.

The figure below shows the SRAM areas, when ECC is enabled for both SRAM1 and SRAM2.

Table 16. SRAM with ECC memory map

ProductSRAMAddress over C-busAddress over S-busSRAM size
STM32C53x/542SRAM10x0A00 0000 - 0x0A00 7FFF0x2000 0000 - 0x2000 7FFF32 Kbytes
SRAM20x0A00 8000 - 0x0A00 FFFF0x2000 8000 - 0x2000 FFFF32 KbytesECC
STM32C55x/562SRAM10x0A00 0000 - 0x0A00 FFFF0x2000 0000 - 0x2000 FFFF64 Kbytes
SRAM20x0A01 0000 - 0x0A01 FFFF0x2001 0000 - 0x2001 FFFF64 KbytesECC
STM32C59x/5A3SRAM10x0A00 0000 - 0x0A01 FFFF0x2000 0000 - 0x2001 FFFF128 Kbytes
SRAM20x0A00 0002 - 0x0A03 FFFF0x2002 0000 - 0x2003 FFFF128 KbytesECC

When ECC is enabled by user option bits, the ECCE bit is automatically set after system reset in the related RAMCFG_MxCR.

The ECC can be deactivated by executing the following software sequence:

  1. 1. Write 0xAE in RAMCFG_MxECCKEYR.
  2. 2. Write 0x75 in RAMCFG_MxECCKEYR.
  3. 3. Write 0 in RAMCFG_MxCR.

Testing ECC mechanism

To test the ECC mechanism, 1 or 2 bits by word for single- or double-error test respectively.

The procedure to check ECC is the following:

  1. 1. On an erased memory, write data with ECC ON.
  2. 2. Disable ECC.
  3. 3. Write the same data with 1- or 2-bit modification (for single or double error test respectively).
  4. 4. Enable ECC.
  5. 5. Read the data. Enabled interrupt is generated because of a single or double error.

5.3.3 Write protection (SRAM2)

SRAM2 is made up of 1-Kbyte pages, each of which can be write-protected by setting its corresponding PxWP bit in RAMCFG_M2WPR1, RAMCFG_M2WPR2, RAMCFG_M2WPR3(a), and RAMCFG_M2WPR4(a).

5.3.4 Software erase

SRAM erase can be requested by executing this software sequence:

  1. 1. Write 0xCA in RAMCFG_MxERKEYR.
  2. 2. Write 0x53 in RAMCFG_MxERKEYR.
  3. 3. Write 1 to the SRAMER bit in RAMCFG_MxCR.

a. This register is available only on STM32C59x/5A3 devices. If not present, consider this register as reserved, and keep its bits at reset value.

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 AHB clock cycles, where N is the size of the SRAM in 32-bit words.

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

5.4 RAMCFG low-power modes

Table 17. Effect of low-power modes on RAMCFG

ModeDescription
SleepNo effect. RAMCFG interrupts cause the device to exit Sleep mode.
StopThe content of RAMCFG registers is kept.
StandbyThe RAMCFG peripheral is powered down and must be reinitialized after exiting Standby mode.

5.5 RAMCFG interrupts

The table below gives the list of RAMCFG interrupt requests.

Table 18. RAMCFG interrupt requests

Interrupt acronymInterrupt eventEvent flagEnable control bitInterrupt clear methodExit Sleep modeExit Stop modeExit Standby mode
RAMCFGECC single-error detection and correctionSEDCSEIEWrite 1 in CSEDCYesNoNo
ECC double-error detectionDEDDEIE = 1 and ECCNMI = 0Write 1 in CDEDYesNoNo
NMIECC double-error detectionDEDECCNMIWrite 1 in CDEDYesNoNo

5.6 RAMCFG registers

In the registers described below, x refers to:

5.6.1 RAMCFG memory x control register (RAMCFG_MxCR)

Address offset: 0x000+0x40*(x-1), (x = 1, 2)

Reset value: 0x0000 000X

ECCE reset value depends on the ECC enable user option bit.

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
ER
Res.Res.Res.ALERes.Res.Res.ECCE
rsrwrw

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

Bit 8 SRAMER: SRAM erase

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

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

Bit 4 ALE: Address latch enable

Note: This bit is reserved and must be kept at reset value in SRAM1 control register.

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

Bit 0 ECCE: ECC enable.

This bit reset value is defined by the user option bit configuration. When set, it can be cleared by software only after writing the unlock sequence in the RAMCFG_MxECCKEYR register.

Note: This bit is reserved and must be kept at reset value in SRAM1 control register.

5.6.2 RAMCFG memory x interrupt status register (RAMCFG_MxISR)

Address offset: 0x008+0x40*(x-1), (x = 1,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.SRAM
BUSY
Res.Res.Res.Res.Res.Res.DEDSEDC
rrr

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

Bit 8 SRAMBUSY: SRAM busy with erase operation

0: No erase operation ongoing

1: Erase operation ongoing

Note: Depending on the SRAM, the erase operation can be performed due to software request, system reset if the option bit is enabled, tamper detection or RDP level regression. Refer to Table 15: Internal SRAMs features.

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

Bit 1 DED: ECC double error detected

0: No double error

1: Double error detected

Note: This bit is reserved and must be kept at reset value in SRAM1 interrupt status register.

Bit 0 SEDC: ECC single error detected and corrected

0: No single error

1: Single error detected and corrected

Note: This bit is reserved and must be kept at reset value in SRAM1 interrupt status register.

5.6.3 RAMCFG memory x erase key register (RAMCFG_MxERKEYR)

Address offset: 0x028+0x40*(x-1), (x = 1,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 SRAMER in RAMCFG_MxCR.

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

Note: Writing a wrong key reactivates the write protection.

5.6.4 RAMCFG memory 2 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.ECCNMIRes.DEIESEIE
rsrwrw

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

Bit 3 ECCNMI: Double error NMI

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

Note: if ECCNMI is set, the RAMCFG maskable interrupt is not generated whatever DEIE bit value.

Bit 2 Reserved, must be kept at reset value.

Bit 1 DEIE: ECC double error interrupt enable

Bit 0 SEIE: ECC single error interrupt enable

5.6.5 RAMCFG memory 2 ECC single error address register (RAMCFG_M2SEAR)

Address offset: 0x04C

Reset value: 0x0000 0000

31302928272625242322212019181716
ESEA[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
ESEA[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 ESEA[31:0]: ECC single error address

When the ALE bit is set in RAMCFG_M2CR, this bitfield is updated with the address corresponding to the ECC single error.

5.6.6 RAMCFG memory 2 ECC double error address register (RAMCFG_M2DEAR)

Address offset: 0x050

Reset value: 0x0000 0000

31302928272625242322212019181716
EDEA[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
EDEA[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 EDEA[31:0]: ECC double error address

When the ALE bit is set in RAMCFG_M2CR, this bitfield is updated with the address corresponding to the ECC double error.

5.6.7 RAMCFG memory 2 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.CDEDCSEDC
rwrw

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

Bit 1 CDED: Clear ECC double error detected

Writing 1 to this flag clears the DED bit in RAMCFG_M2ISR. Reading this flag returns the DED value.

Bit 0 CSEDC: Clear ECC single error detected and corrected

Writing 1 to this flag clears the SEDC bit in RAMCFG_M2ISR. Reading this flag returns the SEDC value.

5.6.8 RAMCFG memory 2 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 page y write protection (y = 31 to 0)

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

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

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

5.6.9 RAMCFG memory 2 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 page y write protection (y = 63 to 32)

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

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

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

5.6.10 RAMCFG memory 2ECC key register
(RAMCFG_M2ECCKEYR)

Address offset: 0x064

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.ECCKEY[7:0]
wwwwwwww

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

Bits 7:0 ECCKEY[7:0]: ECC write protection key

The following steps are required to unlock the write protection of ECCE in RAMCFG_M2CR.

1) Write 0xAE into ECCKEY[7:0].

2) Write 0x75 into ECCKEY[7:0].

Note: Writing a wrong key reactivates the write protection.

5.6.11 RAMCFG memory 2 write protection register 3 (RAMCFG_M2WPR3)

Address offset: 0x070

Reset value: 0x0000 0000

31302928272625242322212019181716
P95WPP94WPP93WPP92WPP91WPP90WPP89WPP88WPP87WPP86WPP85WPP84WPP83WPP82WPP81WPP80WP
rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrs
1514131211109876543210
P79WPP78WPP77WPP76WPP75WPP74WPP73WPP72WPP71WPP70WPP69WPP68WPP67WPP66WPP65WPP64WP
rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrs

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

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

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

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

5.6.12 RAMCFG memory 2 write protection register 4 (RAMCFG_M2WPR4)

Address offset: 0x074

Reset value: 0x0000 0000

31302928272625242322212019181716
P127WPP126WPP125WPP124WPP123WPP122WPP121WPP120WPP119WPP118WPP117WPP116WPP115WPP114WPP113WPP112WP
rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrs
1514131211109876543210
P111WPP110WPP109WPP108WPP107WPP106WPP105WPP104WPP103WPP102WPP101WPP100WPP99WPP98WPP97WPP96WP
rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrs

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

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

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

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

5.6.13 RAMCFG register map

Table 19. RAMCFG register map and reset values

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x000RAMCFG_M1CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SRAMERRes.Res.Res.Res.Res.Res.Res.Res.
Reset value0
0x004Reserved
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.
Reset value0
0x00C -
0x024
Reserved
0x028RAMCFG_M1ERKEYRRes.Res.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 value00000000
0x02C -
0x03C
Reserved
0x040RAMCFG_M2CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SRAMERRes.Res.Res.ALERes.Res.Res.ECCE
Reset value00x
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.ECCNMIRes.DEIESEIE
Reset value000
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.DEDSEDC
Reset value000
0x04CRAMCFG_M2SEARESEA[31:0]
Reset value00000000000000000000000000000000
0x050RAMCFG_M2DEAREDEA[31:0]
Reset value00000000000000000000000000000000
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.CDEDCSEDC
Reset value00
0x058RAMCFG_M2WPR1P31WPP30WPP29WPP28WPP27WPP26WPP25WPP24WPP23WPP22WPP21WPP20WPP19WPP18WPP17WPP16WPP15WPP14WPP13WPP12WPP11WPP10WPP9WPP8WPP7WPP6WPP5WPP4WPP3WPP2WPP1WPP0WP
Reset value00000000000000000000000000000000

Table 19. RAMCFG register map and reset values

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x05CRAMCFG_M2WPR2P63WPP62WPP61WPP60WPP59WPP58WPP57WPP56WPP55WPP54WPP53WPP52WPP51WPP50WPP49WPP48WPP47WPP46WPP45WPP44WPP43WPP42WPP41WPP40WPP39WPP38WPP37WPP36WPP35WPP34WPP33WPP32WP
Reset value0000000000000000000000000000000
0x060Reserved
0x064RAMCFG_M2ECCKEYRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ECCKEY[7:0]
Reset value00000000
0x068RAMCFG_M2ERKEYRRes.Res.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 value00000000
0x070RAMCFG_M2WPR3P95WPP94WPP93WPP92WPP91WPP90WPP89WPP88WPP87WPP86WPP85WPP84WPP83WPP82WPP81WPP80WPP79WPP78WPP77WPP76WPP75WPP74WPP73WPP72WPP71WPP70WPP69WPP68WPP67WPP66WPP65WPP64WP
Reset value0000000000000000000000000000000
0x074RAMCFG_M2WPR4P127WPP126WPP125WPP124WPP123WPP122WPP121WPP120WPP119WPP118WPP117WPP116WPP115WPP114WPP113WPP112WPP111WPP110WPP109WPP108WPP107WPP106WPP105WPP104WPP103WPP102WPP101WPP100WPP99WPP98WPP97WPP96WP
Reset value0000000000000000000000000000000

Refer to Section 2.2: Memory organization for the register boundary addresses.