Siemens S7-300 Memory: Load Memory vs Work Memory Power Loss

David Krause20 min read
PLC HardwareSiemensTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview of S7-300 Memory Architecture

The SIMATIC S7-300 CPU separates program and data storage into three distinct physical and logical regions defined by IEC 61131-3 and Siemens-specific extensions: load memory (Ladespeicher), work memory (Arbeitsspeicher), and system memory. The load memory is non-volatile and resides on a plug-in Micro Memory Card (MMC, order code 6ES7953-8xx11-0AA0). Work memory is volatile high-speed SRAM integrated into the CPU module and is the region the processor actively addresses during every scan cycle. System memory contains the I/O process images, bit memory (M), timers (T), counters (C), and the local stack of the currently executing OB/FB/FC.

The S7-300 architecture follows a strict unidirectional loading model: the contents of load memory are copied into work memory during a cold start or warm restart, and the CPU executes exclusively from work memory. The MMC is never directly executed by the scan cycle; it serves as the persistent repository that survives power removal.

Architectural constraint: In all production S7-300 CPUs from CPU 312 through CPU 319-3 PN/DP, work memory size is a fixed specification of the CPU (e.g., 16 KB, 32 KB, 64 KB, 128 KB, 256 KB, 512 KB, 1024 KB, 1408 KB) and is always smaller than any available MMC capacity. The smallest MMC is 64 KB and the largest is 8 MB, so under normal conditions the load memory can never be smaller than the work memory required to hold the active program.

This article examines the edge case of work memory exceeding load memory, the role of the backup battery, the dynamic DB creation SFCs (SFC 82, SFC 83, SFC 84, SFC 85), and how the same architectural pattern applies to S7-200 and S7-400 platforms. The S7-300 CPU 31xC operating instructions, available on the Siemens Industry Online Support portal at SIMATIC S7-300 CPU 31xC Operating Instructions, is the primary manufacturer reference for memory behavior. The S7-300 automation system manual is available at SIMATIC S7-300 Automation System Manual.

Load Memory (MMC) Technical Specifications

The load memory is implemented as a 3.3 V FEPROM (Flash-erasable programmable read-only memory) on the MMC. The MMC is a 14-pin module that locks into a socket on the CPU front panel. The MMC is required on the following S7-300 CPUs: 312, 312C, 313C, 313C-2 PtP, 313C-2 DP, 314, 314C-2 PtP, 314C-2 DP, 315-2 DP, 315-2 PN/DP, 317-2 DP, 317-2 PN/DP, 318-2 DP, 318-3 PN/DP, 319-3 PN/DP, and all F-CPUs (CPU 315F-2 DP, CPU 317F-2 DP, CPU 319F-3 PN/DP).

MMC Order Code Capacity Typical Application
6ES7953-8LF11-0AA0 64 KB CPU 312, small programs
6ES7953-8LH11-0AA0 128 KB CPU 313C
6ES7953-8LJ11-0AA0 512 KB CPU 314/315 with recipes
6ES7953-8LK11-0AA0 2 MB CPU 315-2 PN/DP, 317
6ES7953-8LL11-0AA0 4 MB CPU 317-2 PN/DP, 318
6ES7953-8LM11-0AA0 8 MB CPU 319-3 PN/DP, large F-systems

The MMC performs three functions: (1) it stores all program blocks (OB, FB, FC, DB, SFB, SFC, SDB) of the user program; (2) it stores the system data blocks generated by STEP 7 during hardware configuration (HW Config); (3) it stores recipe data and any DB explicitly written to load memory by SFC 84 (WRIT_DBL). The MMC has a guaranteed write endurance of typically 100,000 erase cycles per sector and a data retention of 10 years minimum with the CPU powered down at 40 °C.

Critical field caveat: Older S7-300 CPUs (CPU 312 IFM, CPU 314 IFM) used integrated EPROM and a separate backup battery; these predate the MMC architecture. From the 312C generation onward, the MMC is the only load memory. Without an MMC, the CPU will fault at startup with diagnostic event 16#4316 (no MMC inserted) and will not enter RUN mode.

Work Memory (RAM) Technical Details

Work memory is a static RAM (SRAM) block integrated into the CPU ASIC. It is divided into two sub-regions: code work memory and data work memory. Code work memory holds the executable code of OB, FB, FC, and the SFB/SFC library blocks. Data work memory holds the instance DBs of FBs and the global DBs that hold program variables. The split is fixed at CPU design time and cannot be reconfigured.

CPU Order Code Code Work Memory Data Work Memory Total Work Memory
CPU 312 6ES7312-1AE14-0AB0 16 KB 16 KB 16 KB (unified)
CPU 312C 6ES7312-5BF04-0AB0 32 KB 32 KB 32 KB
CPU 313C 6ES7313-5BG04-0AB0 64 KB 64 KB 64 KB
CPU 314 6ES7314-1AG14-0AB0 96 KB 96 KB 128 KB
CPU 314C-2 DP 6ES7314-6CH04-0AB0 96 KB 96 KB 192 KB
CPU 315-2 DP 6ES7315-2AH14-0AB0 192 KB 192 KB 384 KB
CPU 315-2 PN/DP 6ES7315-2EH14-0AB0 256 KB 256 KB 512 KB
CPU 317-2 DP 6ES7317-2AK14-0AB0 512 KB 512 KB 1024 KB
CPU 317-2 PN/DP 6ES7317-2EK14-0AB0 768 KB 1024 KB 1792 KB
CPU 319-3 PN/DP 6ES7319-3FL00-0AB0 1024 KB 1408 KB 2432 KB

The values above are typical for the 6ES7-xxx-2xx04-0AB0 / 6ES7-xxx-1AE14-0AB0 firmware generations. Newer firmware revisions (firmware V3.3 on CPU 319, V3.2 on CPU 317) have identical memory maps. Work memory is volatile, meaning all content is lost when the supply voltage (24 V DC on terminals 1L+/1M) drops below the CPU's brown-out threshold (typically 19.2 V for the PS 305/307 power supplies).

Retentive vs Non-Retentive Memory

Retentive memory is the portion of work memory and system memory whose content is preserved across power cycles. There are two mechanisms: (1) backup battery, which holds the entire work memory and selected system memory regions; (2) configurable retentive regions defined in STEP 7 HW Config, which determine the byte count of M, T, C, and DB that survive a power cycle.

Configure retentive memory in HW Config under CPU > Properties > Retentive Memory. Typical defaults for a CPU 315-2 PN/DP:

  • Number of retentive M bytes: 16 (MB0 to MB15)
  • Number of retentive T (timer) words: 8 (T0 to T7)
  • Number of retentive C (counter) words: 8 (C0 to C7)
  • Number of retentive DBs: 0 (all DBs non-retentive by default)

If a DB is to be retentive, mark it in the DB properties as "Non-retain = No" (i.e., retain). The bytes declared in the DB's "Retain" section are kept through power cycles if (a) the backup battery is healthy, or (b) the CPU supports the "automatic backup to MMC" feature, which on S7-300 is only available for DBs flagged for retain AND with the "Data block with backup in integrated EPROM" attribute set in the DB properties (only on older firmware; for S7-300 MMC, the battery is the primary mechanism).

Default behavior: Without a backup battery installed, the CPU can still retain a small number of bytes (16 M, 8 T, 8 C) through its internal supercapacitor for typically 1 to 3 days. Beyond that, the supercapacitor is exhausted and the retentive areas are lost. The backup battery (6ES7971-0BA00) extends this to the shelf life of the battery, typically 1 to 2 years.

Backup Battery: Role, Specification, and Detection

The backup battery in S7-300 is a 3.6 V lithium thionyl chloride (Li-SOCl2) cell in an AA form factor, order code 6ES7971-0BA00, with a nominal capacity of 2.3 Ah. It installs in a compartment on the bottom of the CPU module, accessible with a screwdriver. The battery's role is to hold the contents of work memory (and any retentive system memory areas) when the 24 V supply is removed.

Battery specification details:

  • Nominal voltage: 3.6 V
  • Nominal capacity: 2.3 Ah
  • Operating temperature: -25 °C to +70 °C
  • Typical backup duration: 1 to 2 years at 25 °C, 6 months at 60 °C
  • Replacement interval recommendation: every 2 years, regardless of diagnostic status

The CPU monitors the battery voltage continuously and writes a diagnostic event to the diagnostic buffer when the voltage drops below the warning threshold (approximately 2.8 V). The corresponding event IDs are:

Event ID (Hex) Event Meaning
16#4300 Battery voltage low or battery missing
16#4301 Battery exhausted - retentive memory no longer buffered
16#4302 Battery replaced (after insertion)
16#4303 Battery test failed (internal impedance check)
16#4304 Battery OK (initial self-test on power-up)

To read the battery status programmatically, use SFC 51 (RDSYSST) with SSL_ID W#16#0712 (battery status). The returned record contains the voltage in millivolts, the status flags, and the remaining runtime estimate. Sample ST code:

// Read battery status SSL W#16#0712
CALL SFC 51
REQ := TRUE
SZL_ID := W#16#0712
INDEX := W#16#0001
RET_VAL := MW100
BUSY := M101.0
SZL_HEADER := DB200.DBD0
DR := P#DB200.DBX4 BYTE 16

The SZL W#16#0712 record structure is: bytes 0-1: status flags (bit 0 = battery missing, bit 1 = battery low, bit 2 = battery exhausted); bytes 2-3: voltage in mV; bytes 4-7: estimated remaining time in hours; bytes 8-11: load current in µA.

Field-proven caveat: Some third-party replacement batteries (lower-cost Li-SOCl2 cells from non-OEM suppliers) report a higher initial voltage but sag dramatically after 6 months. The diagnostic buffer will not show a fault until the cell has already been exhausted, leaving a window where data retention is unreliable. Siemens recommends using the OEM 6ES7971-0BA00 or the equivalent listed in the CPU 31xC Operating Instructions Appendix A.

Power Failure Behavior and Restart Modes

The S7-300 supports four restart modes configured under CPU > Properties > Startup in HW Config:

  1. Cold restart (cold power-up): On power restoration, the CPU clears all non-retentive M, T, C, and DB; reloads program from MMC to work memory; executes OB102 (cold restart OB) if present; transitions to RUN.
  2. Warm restart: On power restoration, the CPU retains retentive M, T, C, and DB; reloads program from MMC to work memory; executes OB100 (warm restart OB) if present; transitions to RUN.
  3. Hot restart: Available only on CPU 318-2 and CPU 319-3 with firmware V3.x; the CPU continues from the exact point of power loss, including all dynamic states. On S7-300 (not S7-400), this requires the backup battery to be healthy.
  4. No restart (operating mode STOP after power-up): The CPU remains in STOP until commanded to RUN from STEP 7 or HMI.

The behavior of work memory on power failure is the key question. The CPU's power supply monitors the 24 V rail. When the voltage drops below the brown-out threshold, the CPU enters a controlled power-down sequence: it freezes the scan cycle, copies all live register states into a backup area, and powers off the SRAM controller. The backup battery (or supercapacitor) then takes over the SRAM refresh. If the battery is healthy, the entire work memory content is preserved. If the battery is exhausted or missing and the supercapacitor is also discharged, the SRAM is not refreshed and the work memory content decays to a random state within seconds.

On power-up, the CPU performs a CRC check on the work memory contents against the load memory contents (where applicable). If the work memory has been corrupted by an extended power loss without battery backup, the CPU discards the corrupted blocks and reinitializes them from the MMC. This is automatic; no operator intervention is required. The diagnostic buffer will record an entry such as "Work memory reset" with event ID 16#43E0 (memory inconsistency detected).

Dynamic DB Creation: SFC 82, SFC 83, SFC 84, SFC 85

The S7-300 provides four SFCs for runtime creation, reading, writing, and deletion of data blocks. These are the source of the rare edge case where work memory can hold content that does not exist in load memory.

SFC Name Function
SFC 82 CREAT_DB Creates a new DB in work memory at runtime
SFC 83 READ_DBL Reads a DB from load memory to work memory
SFC 84 WRIT_DBL Writes a DB from work memory back to load memory (MMC)
SFC 85 DEL_DB Deletes a DB from work memory (and optionally from load memory)

SFC 82 (CREAT_DB) creates a new DB that exists in work memory only. It is not written to the MMC by SFC 82. The block is therefore lost on a power cycle if the backup battery is not present. The SFC parameters are:

CALL SFC 82   // CREAT_DB
LOW_LIMIT := W#16#0010    // Lowest permissible DB number (10)
UP_LIMIT  := W#16#00FF    // Highest permissible DB number (255)
COUNT     := W#16#0001    // Number of DBs to create
RET_VAL   := MW200        // Return value
DB_NUMBER := MW202        // DB number of the created DB

Common RET_VAL codes:

RET_VAL (Hex) Meaning
0000 No error
8080 No free DB number available in the range
8081 COUNT parameter is 0
8082 Insufficient work memory to create the requested DB(s)
8083 Number of available DB numbers exhausted (max 16,384 simultaneously in work memory on CPU 319)
8085 DB with the returned number already exists
8090 LOW_LIMIT or UP_LIMIT invalid
8091 COUNT greater than (UP_LIMIT - LOW_LIMIT + 1)
80A1 Work memory access error
80B1 System error
80B2 MMC write error

SFC 84 (WRIT_DBL) is the inverse: it copies a DB from work memory to load memory (MMC). The SFC 84 parameters are:

CALL SFC 84   // WRIT_DBL
REQ    := TRUE
DBNUM   := 200            // DB number to write
RET_VAL := MW210
BUSY    := M211.0
DONE    := M211.1
ERROR   := M211.2

After SFC 84 completes successfully, the DB exists in both work memory and load memory, so a power cycle without backup battery will not destroy it. SFC 83 (READ_DBL) performs the opposite direction, copying a DB from MMC to work memory. SFC 85 (DEL_DB) deletes a DB, optionally also from the MMC if the DB exists there.

For the full reference of SFC parameters and error codes, see the STEP 7 System and Standard Functions reference manual, available on the Siemens support portal under reference manual "System Software for S7-300/400 System and Standard Functions" at STEP 7 System Software Reference Manual.

Field-proven caveat: SFC 82 DBs are created in work memory only and are not automatically persisted to the MMC. If the application depends on these DBs surviving a power cycle, the program must call SFC 84 immediately after SFC 82. Alternatively, declare the DB as retentive in its properties; the retentive attribute is honored by the CPU and the data block contents (not the block itself) are buffered by the battery through the power cycle. Note that the retentive attribute applies only to the initial values; newly created data within the DB at runtime is also retained as long as the block header is in work memory.

The Edge Case: Work Memory Greater than Load Memory

The question of whether work memory can be larger than load memory is the central edge case. The architectural answer is that the CPU design itself prevents this from happening through normal use, because the size of work memory is hard-wired into the CPU silicon and the load memory is the MMC, whose minimum capacity (64 KB) always exceeds the smallest work memory (16 KB on CPU 312). The CPU will fail to enter RUN if the MMC is too small to hold the program, with diagnostic event 16#4317 (MMC capacity insufficient).

However, a second-order edge case is reachable through the dynamic DB SFCs:

  1. The CPU starts with a small MMC (e.g., 64 KB) and a small user program that fits in 32 KB of code work memory plus 16 KB of DB work memory.
  2. At runtime, the application uses SFC 82 to create a large number of dynamic DBs that cumulatively consume 30 KB of work memory (in addition to the user program blocks).
  3. Total work memory consumption is now 62 KB. The MMC holds 64 KB total, of which 5 KB is the user program and 1 KB is system data. There is no MMC capacity remaining, but work memory is fine.
  4. On a power cycle, the work memory is preserved by the battery, and on the next startup the dynamic DBs are still present. The CPU is in a state where work memory is "fuller" than what the static MMC program would imply, but this is the normal SFC 82 use case.
  5. On a power cycle with a failed battery, the work memory is lost. The CPU reinitializes from the MMC. The dynamic DBs (which were never in the MMC) are gone. The CPU re-enters RUN with the static program only. The application must detect this (e.g., via a "first scan" marker MB100.0) and re-create the dynamic DBs.

What the S7-300 will never allow is the inverse: code work memory cannot be made to "exceed" the load memory because the CPU blocks (OB/FB/FC) are always loaded from the MMC and the MMC must contain all code blocks. The CPU diagnostic event 16#43E1 (work memory smaller than program) is generated at startup if this condition is somehow reached, typically via a corrupted MMC or a CPU downgrade that reduced work memory.

Comparison with S7-200 and S7-400

The same architectural pattern (load memory non-volatile, work memory volatile, battery-buffered for retention) is applied across the SIMATIC S7 family, with platform-specific differences.

Feature S7-200 S7-300 S7-400
Load memory medium EEPROM (internal) MMC (FEPROM) RAM (battery-backed) or FEPROM card
Work memory medium SRAM (battery-less via EEPROM backup) SRAM (battery-buffered) SRAM (battery-buffered)
Backup battery Not required (EEPROM persistence) Required for retention (6ES7971-0BA00) Required for RAM card (6ES7971-0BA00 or larger)
Retentive V/M/T/C EEPROM-backed ranges, configurable in system block Configurable in HW Config Configurable in HW Config
Dynamic DB creation Not supported SFC 82 / 83 / 84 / 85 SFC 82 / 83 / 84 / 85 (extended DB limit to 65,535)
MMC removal during RUN N/A (no MMC) Diagnostic event 16#4314, CPU goes to STOP N/A (RAM card not hot-swappable)
Memory write endurance 1,000,000 cycles (EEPROM) 100,000 cycles per sector (MMC FEPROM) N/A (RAM card, no endurance limit)

The S7-200 is fundamentally different: it stores the user program in an internal EEPROM and uses a battery-less retention mechanism. V memory (variable memory) and the M, T, C regions that are declared as retentive in the System Data Block are written to EEPROM on a power-down event, allowing retention without a battery. The trade-off is EEPROM write endurance: 1,000,000 cycles per byte. The S7-200 manual is at SIMATIC S7-200 Programmable Controller System Manual.

The S7-400 uses a similar architecture to the S7-300 but with two load memory options: a battery-backed RAM card (volatile, but no write endurance limit and fast writes) or an FEPROM card (non-volatile, slower writes, 100,000 cycle endurance). The S7-400 supports SFC 82/83/84/85 with an extended DB number range up to 65,535. The S7-400 system manual is at SIMATIC S7-400 Automation System Manual.

Diagnostic Buffer and SZL for Memory Health

The S7-300 diagnostic buffer is a 100-entry ring buffer in system memory. Each entry contains a timestamp, an event ID, and event-specific data. Memory-related events use the ID ranges 16#43xx (battery, MMC) and 16#E0xx (memory errors). To read the buffer, use SFC 51 (RDSYSST) with SSL_ID W#16#0A91. The number of entries is parameterized via INDEX (1-100). Sample ST code to read the most recent 10 entries:

// Read diagnostic buffer (10 most recent entries)
CALL SFC 51
REQ     := TRUE
SZL_ID  := W#16#0A91
INDEX   := 10         // Read 10 entries
RET_VAL := MW300
BUSY    := M301.0
SZL_HEADER := DB201.DBD0
DR      := P#DB201.DBX4 BYTE 200

Each entry is 20 bytes: 4 bytes timestamp (DATE_AND_TIME), 2 bytes event ID, 4 bytes event info, 10 bytes supplementary info. The STEP 7 "PLC > Module Information > Diagnostic Buffer" view decodes these and presents them in the engineering tool. For a full reference of diagnostic event IDs, see the S7-300 Automation System Manual Appendix A.

The most useful SZL entries for memory health monitoring are:

SSL_ID (Hex) Meaning Use Case
W#16#0F31 CPU serial number Asset tracking
W#16#0131 MMC serial number MMC replacement detection
W#16#0132 MMC type (capacity, OEM) Capacity verification
W#16#0712 Battery status Battery health
W#16#0111 Module identification CPU firmware version
W#16#0112 Module characteristics Work memory size verification

Memory Sizing and Commissioning Best Practices

When commissioning a new S7-300 application, follow this checklist to avoid the data loss scenarios discussed above.

  1. MMC capacity rule of thumb: select an MMC with at least 2x the user program size. The user program in STEP 7 reports a "Memory consumption" value in the "PLC > Module Information" view. Add 30% margin for engineering changes, then select the next standard MMC size.
  2. Battery installation: install the 6ES7971-0BA00 battery in the CPU module before applying 24 V. The CPU performs a self-test on the battery and posts event 16#4304 (battery OK) to the diagnostic buffer. Verify this in STEP 7 after first power-up.
  3. Configure retentive ranges: in HW Config, set the retentive M, T, C, and DB ranges to the minimum required for process continuity. Excessive retentive ranges increase the workload on the backup battery and lengthen the cold-restart initialization time.
  4. Avoid SFC 82 if persistence is needed: when a DB must survive a power cycle, declare it in the STEP 7 project and download it to the MMC, or call SFC 84 after SFC 82 to persist the runtime-created block. Do not rely on battery backup alone for DBs that change frequently, because each MMC write is a write cycle against the FEPROM endurance limit.
  5. Implement a power-loss recovery strategy: in OB100 (warm restart), check a retentive MB100.0 "first scan" marker. If clear, this is a power-loss recovery; the program should re-create any dynamic DBs (SFC 82) and reload any SFC 84-persisted data.
  6. Schedule battery replacement: replace the backup battery every 2 years, regardless of diagnostic status. Use STEP 7 to read SZL W#16#0712 monthly and trend the voltage. The OEM battery holds voltage above 2.8 V for 2 to 3 years at 25 °C; the failure mode is gradual voltage sag followed by a rapid drop in the last 6 months.
  7. Avoid removing the MMC with power applied: pulling the MMC during RUN causes diagnostic event 16#4314 and immediately stops the CPU. Always power down the rack before removing or inserting the MMC.
Safety implication: For F-CPUs (CPU 315F-2 DP, 317F-2 DP, 319F-3 PN/DP), the backup battery is a safety-critical component. A failed battery on an F-CPU is treated as a safety fault, and the F-runtime group is shut down via OB82. Replace batteries on F-systems on a fixed schedule (typically annual) and log the replacement in the safety case file. See SIMATIC Safety in S7-300/400 F-CPU Programming Manual for the safety lifecycle.

FAQ

Can the S7-300 work memory ever be larger than the load memory (MMC)?

Architecturally no. The CPU's work memory is a fixed-size SRAM block (e.g., 16 KB to 1408 KB depending on CPU model), and the smallest available MMC is 64 KB. The CPU rejects an MMC that is too small with diagnostic event 16#4317. The closest legitimate edge case is dynamic DB creation with SFC 82, which adds work memory content that is not mirrored to the MMC; this is a normal SFC 82 use case, not a "work memory larger than load memory" condition.

What happens to the user program if both the MMC and the backup battery fail simultaneously?

The program in the MMC survives because the MMC is non-volatile FEPROM. The work memory contents (and any retentive M, T, C, DB values) are lost if the battery and supercapacitor are both exhausted. On the next power-up, the CPU reloads the program from the MMC into work memory and re-initializes all non-retentive areas. Retentive areas are reset to their initial values. Dynamic DBs created with SFC 82 (and not persisted via SFC 84) are not re-created automatically.

Which SFC should I use to make dynamic DBs survive a power cycle?

Use SFC 82 to create the DB in work memory, then SFC 84 to copy the DB from work memory to the MMC. The DB will then be present in load memory and will be reloaded into work memory on every restart. Note that each SFC 84 call is a write cycle against the MMC's 100,000-cycle endurance limit; for frequently changing data, prefer a retentive DB with the "Retain" attribute over the SFC 82/84 path.

What is the difference between SFC 82 (CREAT_DB) and a normal DB declared in STEP 7?

A DB declared in STEP 7 is part of the user program and is downloaded to the MMC. It is loaded into work memory at startup and remains there until explicitly deleted with SFC 85. A DB created with SFC 82 is created at runtime in work memory only; it is not in the MMC, not in the offline project, and not in the STEP 7 symbol table. SFC 82 DBs are typically used for temporary data structures whose lifetime is bounded by the program execution.

Does the S7-200 require a backup battery?

No. The S7-200 stores the user program in an internal EEPROM and persists the V memory and retentive M, T, C ranges to the EEPROM on power-down. This makes the S7-200 effectively battery-less for retention purposes. The trade-off is the 1,000,000-cycle EEPROM write endurance, which limits the rate at which retentive V memory can be updated.

How do I read the battery voltage programmatically?

Use SFC 51 (RDSYSST) with SSL_ID W#16#0712 and INDEX W#16#0001. The returned record contains the battery voltage in millivolts (bytes 2-3), the estimated remaining runtime in hours (bytes 4-7), and the load current in microamps (bytes 8-11). A voltage below 2800 mV indicates the battery is approaching end-of-life and should be replaced within 30 days.

Back to blog