S7-1200 Floating Boundary Memory: Program vs Data Layout

David Krause11 min read
S7-1200SiemensTechnical 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 the S7-1200 Memory Architecture

The SIMATIC S7-1200 family uses a unified work memory pool in which both program code (OBs, FCs, FBs) and data block contents (DBs, M memory) coexist. The boundary between these two regions is described by Siemens as a floating boundary, meaning there is no fixed partition wall enforced by firmware. The CPU firmware dynamically allocates each block into the 50 KB (or 75/100/125/150 KB depending on CPU) work memory pool at download time and at every online block reallocation. This behavior is documented in the S7-1200 Programmable Controller System Manual (entry ID 36932465).

For an S7-1200 application, three memory areas matter during engineering:

  • Load memory — non-volatile storage of project blocks on the internal flash or external SIMATIC Memory Card.
  • work memory — volatile runtime area in which the CPU executes code and operates on DB contents.
  • Retentive memory — a configurable subset of work memory that survives power-down and warm restart.

The floating boundary applies only to the work memory pool. Load memory and retentive memory are governed by separate rules and are not part of the floating boundary concept.

What “Floating Boundary” Means in Firmware

In classic S7-300/400 firmware, the work memory was split into two fixed regions at project compile time:

  • A code area reserved exclusively for OB, FB, FC and SFC/SFB code.
  • A data area reserved for instance DBs, global DBs, and system data.

If a project ran out of code space, adding more DBs would not help — the unused data area was stranded. Conversely, a project with many DBs and little code could not use the surplus data area for additional logic.

S7-1200 firmware removes that static split. Inside the 50 KB work memory pool, the firmware places:

Block Class Stored In Volatile?
OB (Organization Block) Work memory Yes
FB (Function Block) Work memory Yes
FC (Function) Work memory Yes
DB (Data Block) — global Work memory Yes (unless tagged retentive)
DB (Data Block) — instance Work memory Yes (unless tagged retentive)
System data (SDB) Work memory Partially retentive

The boundary between code and data is “floating” because the firmware can allocate the last free byte of work memory to whichever block class still needs space. The TIA Portal download dialog reports usage as a single percentage, not as two separate bars.

Work Memory vs Load Memory vs Retentive Memory

Three distinct memory concepts are commonly confused. The following definitions come from the S7-1200 system manual and the TIA Portal help on PLC concepts > data types.

Memory Area Physical Location Size on CPU 1214C DC/DC/DC Behavior
Load memory Internal flash + optional SIMATIC Memory Card 2 MB internal, up to 32 GB on card Non-volatile; holds project, comments, symbols, recipes
Work memory RAM 50 KB Volatile; holds active blocks and current DB values
Retentive memory Battery-backed / NVRAM subset 10 KB (configurable) Survives power loss; selected M, DB tags, bit memory preserved
Critical: Only the work memory participates in the floating boundary. The 2 MB of load memory on a CPU 1214C is always available regardless of how much work memory is consumed. You cannot trade work memory for load memory or vice versa; the partition is fixed at hardware level.

Work Memory Sizes by CPU Model

The S7-1200 line spans CPUs 1211C, 1212C, 1214C, 1215C, 1217C and the second-generation 1212C/1214C/1215C/1217C variants. Work memory differs by model:

CPU Model Work Memory Load Memory (Internal) Retentive Memory (Max)
CPU 1211C 30 KB 1 MB 10 KB
CPU 1212C 50 KB 1 MB 10 KB
CPU 1214C 50 KB 2 MB 10 KB
CPU 1215C 100 KB 4 MB 10 KB
CPU 1217C 125 KB 4 MB 10 KB
CPU 1212C DC/DC/DC (FW 4.x) 75 KB 1 MB 10 KB
CPU 1214C DC/DC/DC (FW 4.x) 100 KB 2 MB 10 KB
CPU 1215C DC/DC/DC (FW 4.x) 125 KB 4 MB 10 KB
CPU 1217C DC/DC/DC (FW 4.x) 150 KB 4 MB 10 KB

Firmware 4.x CPUs released in 2018 roughly doubled work memory for the 1214C and 1215C. To check your CPU version, read the Module Information > Identification tab in TIA Portal Online & Diagnostics; the Version field shows the firmware build (e.g. V4.2.1).

How the Floating Boundary Behaves at Compile Time

When TIA Portal compiles a project, it walks every block in the program tree and computes the byte count of:

  1. Each OB header and body, including local stack requirements.
  2. Each FB and FC code plus the FC/FB interface descriptor.
  3. Each DB body. For FBs with multiple instance DBs, every instance is summed.

The compiler outputs a single Resource consumption summary in the project properties. If the sum exceeds the work memory of the target CPU, the download is rejected with diagnostic buffer entry 0x03E8 (resource exhaustion). The boundary is determined at compile time, not at runtime, even though the firmware can re-paginate blocks during online operations.

The TIA Portal Online & Diagnostics > Memory view shows three values for the active CPU:

  • Work memory used: percentage of RAM currently holding live blocks.
  • Load memory used: percentage of internal flash occupied by the project.
  • Retentive memory used: bytes of the retentive range currently declared.

There is no separate display of “code area” or “data area” usage — confirming the floating boundary in practice.

Configuring Memory: What You Can and Cannot Change

The floating boundary cannot be moved manually. There is no TIA Portal parameter, no SFC call, and no SDO index that lets you reserve 40 KB for code and 10 KB for data. The CPU firmware owns that decision.

What you can configure under PLC properties > General > Memory and retentive memory:

Setting Default Configurable Range Effect
Retentive memory for bit memory (M) 0 bytes 0–8192 bytes Bytes of MB0–MB8191 preserved across STOP/RUN and power cycle
Retentive memory for DB tags 0 bytes 0–10240 bytes (per CPU) Individual DB tags marked retentive consume from this pool
Number of memory objects Auto Limited by CPU object count Defines max simultaneous active block instances
PLC clock alarm OB count 1 1–4 Affects work memory, not retentive area
Field caveat: Increasing retentive memory reduces the volatile portion of work memory available for floating-boundary allocation. On a CPU 1211C with 30 KB total, declaring 8 KB retentive leaves only 22 KB of work memory for code and active DBs. This is often the hidden cause of an unexpected “insufficient work memory” error after a user enlarges the retentive range.

Optimizing Code and Data Size Inside the Boundary

Because the boundary cannot be steered, the only practical levers are block-by-block size reduction. The following techniques are taken from the S7-1200 system manual and Siemens application examples.

Compact Code Patterns

  • Replace multi-instance DBs with single-instance DBs when the calling FB depth is shallow — each multi-instance block adds a header overhead of roughly 60–120 bytes.
  • Use SCL ARRAY structures inside one DB instead of dozens of scalar tags, reducing the DB header per element.
  • Move rarely used FBs to a library that is only loaded when needed, or split the program into two CPUs networked over PROFINET.
  • Delete unused FC/FB stubs. The compiler keeps all referenced blocks; an unreferenced FB still consumes no work memory but the symbol table entry does not. Confirm with Project tree > Common data > Cross-references.

Compact Data Patterns

  • Prefer BOOL bit-packed tags inside a single DB rather than isolated M flags when the total tag count exceeds 32.
  • Use WORD/DWORD/LREAL over INT/REAL only when the precision is justified; every tag carries a 2-byte descriptor on top of its raw width.
  • Drop symbolic comments from DBs that are written to the SIMATIC Memory Card — the comment is stored in load memory, but descriptor growth still increases compile time and SDB size.

Disabling Block Interface Helpers

For each FB, the Properties > General > Interface parameters page contains options that consume work memory:

Option Memory Cost Recommendation
Optimized block access Slightly higher per tag Keep enabled; speeds symbolic access
IEC check on FB parameters Small per parameter Disable in production FB used inside hot loops
Pass DB by reference (multi-instance) ~60–120 B header Avoid chaining more than 3 levels deep
Default value initialization on every restart DB is rewritten on each STOP→RUN Disable for high-frequency DBs

Diagnosing Memory Pressure in TIA Portal

Use the following procedure to inspect memory consumption on a live CPU.

  1. Connect TIA Portal to the CPU and open Online & Diagnostics.
  2. Select the Memory tile. The panel reports bytes used / bytes total for work, load, and retentive areas.
  3. Click Save as text to log current consumption. Compare to the same report from the offline project to see the block that grew unexpectedly.
  4. Open the Diagnostic buffer and search for entries with error code 0x03E8 or 0x03E9; these indicate work memory exhaustion events.
  5. Run Project tree > PLC > Compile > Software (rebuild all blocks) and review the new resource report.

CPU diagnostic buffer entries that frequently accompany memory issues:

Event ID Meaning Typical Cause
0x03E8 Work memory overflow during block load Project grew past CPU spec
0x03E9 Cannot copy block from load to work memory Internal flash failure
0x03EA DB instance generation failed Instance count limit exceeded
0x0EF1 Retentive range exceeds configured size DB tag marked retentive outside allowed range
0x0EF2 Retentive data could not be restored Battery/CAP voltage low on CPU

Comparison With Older SIMATIC Families

Engineers migrating from S7-200, S7-300, or S7-400 are accustomed to fixed code/data splits. The table below summarizes the change.

CPU Family Code Memory Data Memory Boundary Type Retentive Storage
S7-200 (legacy) Fixed in EEPROM Fixed in EEPROM + RAM Hard partition EEPROM-backed V memory
S7-300 (e.g. CPU 315-2 PN/DP) 192 KB code, fixed 256 KB data, fixed Hard partition (MC7 map) Battery-backed RAM area
S7-400 (e.g. CPU 416-3) Up to 5.6 MB code Up to 5.6 MB data Hard partition Battery-backed RAM
S7-1200 (all models) Single work memory pool, floating boundary Soft boundary Configurable NVRAM slice
S7-1500 (e.g. CPU 1515-2 PN) Single work memory pool, floating boundary Soft boundary Configurable NVRAM slice

The S7-1500 family inherited the floating boundary from S7-1200 and applies the same model, but with a much larger work memory base (300 KB on CPU 1511 up to 6 MB on CPU 1518).

Edge Cases and Field-Proven Caveats

The following behaviors are reported in Siemens support notes and confirmed in system manual revision history.

  1. Library blocks inserted from the Siemens library are counted at compile time even if you never reference them in the active program. Remove the Library reference from the Libraries pane rather than just leaving the FB in the tree.
  2. Know-how protected blocks add roughly 256 bytes of SDB overhead each. On a CPU 1211C, protecting more than 30 FBs may push the project past 30 KB.
  3. Web server DB (generated automatically by TIA Portal when web server is enabled) consumes ~12 KB. Disable the web server for low-memory CPUs.
  4. Recipe DBs and data logs live in load memory on the SIMATIC Memory Card; they do not count against work memory, but their schemas must fit in DBs that do.
  5. Function block with very large TEMP interface (e.g. 4 KB of local stack) consumes work memory at every instance. Move large temporaries to a global DB and use POKE_BLK for buffer passing.

Verification Procedure After a Download

After a memory-sensitive download, run the following checklist:

  1. In Online & Diagnostics > Memory, confirm work memory used < 85% of total. The CPU is stable below this threshold; above 90%, STOP→RUN cycles can fragment work memory and trigger 0x03E8 on the next download.
  2. Cycle a power-off/on test. Verify that all retentive M bytes and DB tags retain their last value. If the diagnostic buffer shows 0x0EF2, the retentive range is larger than the NVRAM slice and must be reduced.
  3. Force a STOP→RUN transition ten times consecutively. Monitor the diagnostic buffer for memory warnings. A clean log after 10 cycles indicates headroom is adequate.
  4. Trigger a Download to device > Software (all blocks) while the plant is in safe state. A successful second download confirms the project is reproducible and the CPU flash is healthy.

FAQ

Does the floating boundary mean I can set a custom code/data split on the S7-1200?

No. The boundary is decided by the CPU firmware; TIA Portal exposes only a single work-memory utilization percentage. You can only adjust retentive memory and block-level settings.

How much work memory does a CPU 1214C have and how much is usable for code?

The CPU 1214C ships with 50 KB (firmware 3.x) or 100 KB (firmware 4.x) of work memory. The entire pool is available for code and data combined, minus any bytes assigned to the retentive range (up to 10 KB).

Why does my project show "insufficient work memory" even though load memory has free space?

Load memory (the 2 MB flash) and work memory (the 50 KB RAM) are independent. A project that compiles within 2 MB of flash may still exceed 50 KB of RAM at runtime. Reduce block count, shrink DB bodies, or move to a higher-tier CPU such as the 1215C with 100–125 KB.

Is data log memory counted inside the floating boundary?

No. Data logs and recipes are stored in load memory on the SIMATIC Memory Card, not in work memory. Their schema fields still consume a small amount of work memory for the holding DB.

Can I see how much of work memory is used for code versus data?

TIA Portal does not provide a per-class breakdown. You can estimate by deleting suspected blocks, recompiling, and comparing the work-memory used percentage; the difference approximates the deleted block's footprint. Siemens' S7-1200 system manual confirms no native code/data split reporting.

Back to blog