S7-1200 System and Clock Memory Not Working in TIA Portal PLCSIM
Configuring System memory bits and Clock memory bits in the CPU properties of a SIMATIC S7-1200 is a five-second operation, but the bits often appear "dead" inside PLCSIM (the TIA Portal simulator) even when the enable checkbox is clearly ticked. This article documents the exact root cause, the verification path, and the architectural alternatives that eliminate the symptom permanently.
1. Problem Description
The reported symptoms are consistent across multiple field cases:
- The user opens CPU Properties → System and clock memory in the TIA Portal device configuration.
- The user enables the checkboxes "Enable system memory byte" and "Enable clock memory byte", optionally changing the byte address from the default (typically MB0 / MB1 on S7-1200).
- The program is compiled and downloaded to PLCSIM.
- The bits at the configured addresses never toggle, the FirstScan bit never returns TRUE, and the clock bits stay FALSE indefinitely.
The hardware configuration download is the most frequent missing step; the program blocks alone do not carry the CPU properties that govern system/clock memory. PLCSIM emulates the firmware behavior of a real CPU, and without a coherent system data block the firmware never allocates the clock generator or the first-scan latch.
2. Root Cause Analysis
Three root causes account for >95% of "clock memory not working" tickets in the S7-1200 platform:
| # | Root cause | Detection | Impact |
|---|---|---|---|
| 1 | Only program blocks downloaded to PLCSIM; hardware configuration (SDB 100 / system data) not transferred. | PLCSIM starts in "STOP" or runs an older object set; Online → Accessible nodes shows the CPU, but Online → Diagnostics reports no active system memory. | Firmware clock generator is never instantiated, so all clock bits stay FALSE. |
| 2 | User's M area starts at MB0/MB1, which is the default address of system memory and clock memory respectively, and falls within the retentive range defined in CPU Properties → Retentive memory. | Online watch table shows bits toggling, but program-side evaluation reads stale values retained from a previous session. | FirstScan bit may stay latched; clock bits appear stuck because they overlap with application markers. |
| 3 | PLCSIM session was started before the download completed, leaving the simulator with a stale OB1. | CPU diagnostic buffer entry "Startup; cause: Software reset" or "Download of configuration incomplete". | OB1 is not re-executed; system memory never gets refreshed. |
3. System Memory vs Clock Memory - Technical Foundation
System memory and clock memory are two independent byte resources. The CPU firmware generates them on every cycle of OB1 regardless of user code; they exist in the process image and are refreshed before OB1 reads them.
3.1 System memory byte (S7-1200, fixed bit map)
| Bit | Function | Frequency / behavior |
|---|---|---|
| 0 | FirstScan | TRUE on the first cycle after power-on or STOP→RUN transition; FALSE thereafter. |
| 1 | DiagStatusChanged | Latched TRUE if any diagnostic status has changed since the last reset; user code must reset it. |
| 2 | AlwaysTRUE | Logic 1 in every cycle. |
| 3 | AlwaysFALSE | Logic 0 in every cycle. |
| 4 | Clock 200 ms | 5 Hz, 50% duty cycle. |
| 5 | Clock 100 ms | 10 Hz, 50% duty cycle. |
| 6 | Clock 50 ms | 20 Hz, 50% duty cycle. |
| 7 | Clock 20 ms | 50 Hz, 50% duty cycle (highest available on S7-1200). |
3.2 Clock memory byte (S7-1200 / S7-1500, standard pattern)
| Bit | Period (s) | Frequency (Hz) | Typical use |
|---|---|---|---|
| 0 | 0.10 | 10.0 | Fast blinking, debounce strobe. |
| 1 | 0.20 | 5.0 | Heartbeat LED. |
| 2 | 0.40 | 2.5 | Slow indicator. |
| 3 | 0.50 | 2.0 | Two-second tick. |
| 4 | 0.80 | 1.25 | Slow flashing lamp. |
| 5 | 1.00 | 1.00 | One-second clock. |
| 6 | 1.60 | 0.625 | Long-period scheduling. |
| 7 | 2.00 | 0.50 | Two-second cycle for operator visibility. |
3.3 Inline timing diagram
Figure 1. Clock memory bit waveforms over a 3-second window. Bit 0 of the clock byte toggles ten times per second; bit 5 is a 1 Hz heartbeat; bit 7 produces a 2-second period used for human-visible status lamps.
4. Prerequisites
- Installed and licensed TIA Portal V16 or later (V17 / V18 / V19 supported).
- Installed PLCSIM V16+ (PLCSIM V2 is end-of-life since TIA V15.1 and does not implement system/clock memory in the same way).
- Configured S7-1200 CPU in the project tree (the system/clock memory checkboxes are part of the device configuration, not the program blocks).
- PG/PC interface route to PLCSIM either via PLCSIM Virtual Ethernet Adapter (PLCSIM V16+) or the TCP/IP route SIEMENS PLCSIM.
5. Step-by-Step Resolution
Execute the following sequence. Step 4 is the canonical fix for the "PLCSIM clock memory not working" symptom.
- Open the device configuration. In the TIA Portal project tree, double-click Devices & networks → CPU_1 [CPU 1214C DC/DC/DC].
- Open CPU properties. Select the Properties tab in the inspector, then navigate to System and clock memory (or in older TIA versions, System and clock memory under the General node).
-
Enable the bytes and select addresses. Tick "Enable the use of system memory byte" and "Enable the use of clock memory byte". Set the system memory byte to a non-retentive address (e.g.
MB1000) and the clock memory byte toMB1001. Avoid the defaultMB0 / MB1on S7-1200 because the first two bytes fall inside the retentive range typically set in PLC → Retentive memory. - Compile the hardware configuration. Right-click the CPU in the project tree and select Compile → Hardware (rebuild all). This regenerates the system data blocks (SDB 100, SDB 0, and the IO configuration) that PLCSIM needs to instantiate the clock generator.
- Start PLCSIM and download the entire device. Click Online → Download to device. In the dialog, select PG/PC interface = PLCSIM, choose Configured interface = TCP/IP, click Start search, and select the discovered PLCSIM instance. Ensure the "Download to device" group has both Hardware configuration and Software (all blocks) selected. Press Load and confirm the dialog that says "Download of hardware configuration to device".
- Restart PLCSIM if the CPU is already RUN. If PLCSIM was running before step 5, do Online → Stop CPU, then Online → Run CPU. The system memory and clock memory bits are only re-initialized on STOP→RUN or power-on.
-
Verify in a watch table. Open a new watch table, enter
"Clock_Memory_Byte"(default name: Clock_1 or your custom tag) and the FirstScan bit at%MB1000.0. Toggle the value format to Binary. The FirstScan bit will be TRUE for one cycle after restart; the Clock 200 ms bit at%MB1000.4will toggle at 5 Hz.
6. Alternative Architecture: Clock Bits in a Global DB with Cyclic Interrupt OBs
For projects that follow a strict no-M-area coding style, the system/clock memory can be replaced by a Global Data Block driven by a Cyclic Interrupt OB. The benefit is full type-safety, searchability (Ctrl+F finds "Heartbeat" in seconds), and zero overlap risk with retentive memory.
6.1 DB definition
DATA_BLOCK "GlobalClock"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
NON_RETAIN
STRUCT
Heartbeat_10Hz : BOOL; // 100 ms period
Heartbeat_5Hz : BOOL; // 200 ms period
Heartbeat_2Hz : BOOL; // 500 ms period
Heartbeat_1Hz : BOOL; // 1 s period
FirstScan : BOOL;
AlwaysTRUE : BOOL;
AlwaysFALSE : BOOL;
DiagStatusChanged: BOOL;
END_STRUCT;
END_DATA_BLOCK
6.2 OB30 - 100 ms cyclic interrupt (configurable in CPU properties → Cyclic interrupts)
// OB30 - Cyclic interrupt, 100 ms
"GlobalClock".Heartbeat_10Hz := NOT "GlobalClock".Heartbeat_10Hz;
IF "GlobalClock".Heartbeat_10Hz THEN
"GlobalClock".Heartbeat_5Hz := NOT "GlobalClock".Heartbeat_5Hz;
IF "GlobalClock".Heartbeat_5Hz THEN
"GlobalClock".Heartbeat_2Hz := NOT "GlobalClock".Heartbeat_2Hz;
IF "GlobalClock".Heartbeat_2Hz THEN
"GlobalClock".Heartbeat_1Hz := NOT "GlobalClock".Heartbeat_1Hz;
END_IF;
END_IF;
END_IF;
6.3 OB100 - FirstScan handling
// OB100 - Startup (warm restart)
"GlobalClock".FirstScan := TRUE;
// OB1 user code must reset it on the first cycle:
// "GlobalClock".FirstScan := FALSE;
When this architecture is adopted, the system/clock memory canisters in the CPU properties can stay disabled, freeing the M area for a dedicated, well-documented Global DB that holds all data exchange between machine sections, HMI, alarms, and setpoints.
7. Memory Layout, Retentivity, and Overlap Hazards
On every S7-1200 CPU the M area default retentive range starts at MB0 and has a length of 8 bytes (MB0..MB7) on a CPU 1211C/1212C, 14 bytes on a CPU 1214C, and more on the larger variants. If the system memory byte is placed in that range, the following overlap hazards exist:
| Address operand | Granularity | Overlaps with | Failure mode |
|---|---|---|---|
| M0.0 | 1 bit | MB0, MW0, MD0 | Writing to MW0 overwrites the FirstScan bit and clock bits. |
| MB0 | 8 bits | M0.0..M0.7, MW0, MD0, MB1 | Writing to MB0 corrupts the entire system memory byte; MB1 corruption cascades into clock memory. |
| MW0 | 16 bits | MB0, MB1, M0.0..M1.7, MD0 | A 16-bit MOV instruction overwrites both system and clock memory in one cycle. |
| MD0 | 32 bits | MB0..MB3 | Any 32-bit instruction at the M area base is a silent destroyer of clock memory. |
Recommended placement on S7-1200. CPU 1214C provides 8 KB of M area (0..8191). Place system memory at MB1000 and clock memory at MB1001; the symbolic tags can be defined as "SysMemByte" and "ClockMemByte" in the PLC tag table. This range sits well above the default retentive cutoff and is far from the IEC timer/counter, I/O process image, and DB base areas.
8. Verification and Commissioning
After the fix, run the following verification sequence on every project:
- Watch table check. Add the configured clock memory byte as binary. The pattern should be a stable, 50% duty-cycle square wave. The period at bit 5 must measure 1000 ms ± 1 ms in the online trace.
-
FirstScan check. Force a STOP→RUN transition. In OB1, the FirstScan bit must be TRUE for exactly one OB1 cycle. Use a one-shot
FP(rising-edge) on the tag to confirm. - OB1 cyclic time check. Use Online → Diagnostics → Cycle time to confirm OB1 is running. A CPU that is stuck in STOP will leave clock memory frozen at the last state.
- Hardware configuration consistency check. In PLCSIM V16+, use Online → Accessible nodes → Flash LED on the simulated CPU to confirm the system data blocks were applied.
- Retentivity boundary check. Place a breakpoint in OB1 on a marker just above the retentive range. Cold restart, warm restart, and STOP→RUN should all yield the same FirstScan=TRUE on the first cycle.
9. Troubleshooting Matrix
| Observed symptom | Likely cause | Diagnostic command / location | Remediation |
|---|---|---|---|
| All clock bits stuck at 0. | Hardware configuration not downloaded. | Online → Compare offline/online; if mismatched, SDBs are missing. | Re-download with Download to device dialog, both Hardware and Software selected. |
| Clock bits toggle but FirstScan is always TRUE. | System memory byte inside retentive range, PLCSIM retains it. | CPU Properties → Retentive memory; check overlap with system memory address. | Move system memory byte above retentive cutoff (e.g. MB1000). |
| Bits appear to toggle, but program reads FALSE. | Watch table view vs. process image view mismatch; PIB vs PEB. |
Force the tag in the watch table; if program still sees 0, the program references the wrong address. | Re-symbolize the address via the PLC tag table; avoid raw M references. |
| Clock bits toggle but a 32-bit instruction clears them. | User code at MD0/MD1 area. | Cross-reference on MD0 / MD1 / MW0 / MW1. | Move the application markers out of the system/clock range. |
| FirstScan fires on every download. | PLCSIM retains state across warm restart; Online → Stop CPU does not clear. | Online → MRES to do a full memory reset. | Either accept the behavior and use FirstScanOB semantics, or disable retain for the system memory byte. |
| PLCSIM V2 is used, clock memory does not update. | PLCSIM V2 is deprecated and does not implement S7-1200 V4 firmware behavior. | Check installed SIMATIC software packages. | Upgrade to PLCSIM V16 or later; S7-1200 is supported natively in PLCSIM V16+. |
| Clock bits update, but the HMI sees stale values. | HMI polling cycle longer than the bit period. | Check the HMI connection's update time; default 1 s in TIA Portal. | For visualization, use a slower bit (e.g. 1 Hz, M1.5) to match the HMI poll rate. |
10. Best Practices for M-Area Usage
- Treat the M area as transient scratch memory. Anything that needs to survive STOP→RUN, power off, or cold restart belongs in a retain-tag DB.
-
Use symbolic names from day one. Define
Clock_1Hz,Clock_5Hz,FirstScanin the PLC tag table; raw M references are not searchable and not refactorable. - Reserve a memory map. Document the M area usage in a project-wide Memory Map sheet. The first 100 bytes for "high-speed markers", 100..200 for "handshake flags", 1000..1001 for "system/clock memory".
- Disable retentivity for the M area unless the application genuinely needs it. The default on S7-1200 is retentive for MB0..MBx; a tighter retentive range reduces "stuck bits" issues during PLCSIM debugging.
- Prefer a Global DB architecture for any project above ~10 kB of program memory. The CPU's M area is a finite resource (8 KB on CPU 1214C, 16 KB on CPU 1217C), and the symbolic DB approach scales into the S7-1500 port.
-
Never start a 32-bit instruction at MB0. A single
L MD0in OB1 will silently corrupt system/clock memory; this is the single most common overlap bug in field code. - Cross-reference before every download. Project tree → CPU_1 → Cross-references; filter for System and clock memory to see what user code touches those addresses.
11. Specifications Reference
| Parameter | S7-1200 value | S7-1500 value |
|---|---|---|
| System memory byte (default) | Configurable; user can disable. | Configurable; up to 16 bits in V2.0+ firmware. |
| Clock memory byte (default) | Configurable; user can disable. | Configurable; up to 16 bits. |
| Highest clock frequency (system) | 50 Hz (20 ms period, bit 7) | 1000 Hz (1 ms period, S7-1500 specific bit) |
| Highest clock frequency (clock byte) | 10 Hz (100 ms period, bit 0) | 10 Hz (100 ms period, bit 0) |
| M-area size, CPU 1214C | 8192 bytes | n/a |
| Retentive M range, default | MB0..MB13 (14 bytes on CPU 1214C) | Defined per project, default 0 bytes. |
| PLCSIM support | PLCSIM V16+ required for S7-1200 V4.x | All PLCSIM versions |
| Update timing | Updated before OB1 reads process image | Updated before OB1 reads process image |
Why do my S7-1200 clock memory bits never change in PLCSIM?
The hardware configuration was not downloaded to the simulator. Open Online → Download to device, ensure both Hardware configuration and Software (all blocks) are ticked, and execute a full download. PLCSIM does not initialize the clock generator from the program blocks alone; it needs the system data blocks generated by the device configuration.
Where is the best address for system and clock memory on CPU 1214C?
Avoid MB0 and MB1 because they sit inside the default retentive range and overlap with MD0/MW0/M0.0 user references. Use MB1000 for system memory and MB1001 for clock memory. The CPU 1214C has 8 KB of M area, so addresses up to MB8191 are valid.
How can I get clock bits without using the M area at all?
Create a Global DB named GlobalClock with BOOL tags for each required frequency, and drive them from a Cyclic Interrupt OB (e.g. OB30 at 100 ms). Use a binary counter or a simple toggle to derive 5 Hz, 2 Hz, and 1 Hz from the 10 Hz tick. The M area stays free for scratch flags and the architecture is fully type-safe.
Why does the FirstScan bit stay TRUE on every download in PLCSIM?
PLCSIM retains M-area data across downloads by default. If the system memory byte is inside the retentive range, the FirstScan latch is never cleared. Move the system memory byte above the retentive cutoff, or perform an MRES (full memory reset) in PLCSIM before each test cycle.
What is the highest clock frequency I can get on S7-1200 vs S7-1500?
On S7-1200 the system memory byte exposes a 50 Hz bit (20 ms period) at bit 7, and the clock memory byte starts at 10 Hz. On S7-1500, additional system memory bits provide 5 ms, 2 ms, and 1 ms clocking. The exact bit positions are documented in the S7-1500 clock memory functional description and the S7-1200 system and clock memory reference.