1. Overview
Siemens SIMATIC S7-300 and S7-400 controllers distinguish between online (running program in the CPU) and offline (program on the programming device/PG) project states. The most common operator doubt is whether the CPU must be placed in STOP before any upload or download operation. The answer is conditional: routine program-block transfers do not require STOP on S7-300/400, but several specific operations do, most notably hardware configuration (HW Config) changes, full memory resets, and certain DB re-initializations.
This reference consolidates the rules for CPU operating modes, the role of System Data Blocks (SDB), the block-type taxonomy (OB, FB, FC, DB, SFB, SFC, SDB), the correct usage of the POINTER and ANY pointer data types in STL versus LAD/FBD, and the workflow for online editing with STEP 7 V5.x and TIA Portal.
2. CPU Operating Modes on S7-300 and S7-400
Three operating modes are defined for S7 CPUs:
| Mode | Description | User Program Execution | Programming Allowed from PG? |
|---|---|---|---|
| RUN | Full process execution; read-only access from PG | Yes, cyclic OB1 + interrupt OBs | No (read-only diagnostics) |
| RUN-P | RUN with programming rights (S7-300 only) | Yes | Yes - upload/download, online edit |
| STOP | User program halted; outputs in safe state (configurable) | No | Yes - full read/write, MRES, compress |
The physical mode selector on S7-300 CPUs (CPU 312 through CPU 319) has three positions: RUN, STOP, and MRES (memory reset, spring-return). S7-400 CPUs use a four-position key switch: RUN, RUN-P, STOP, and MRES. The RUN-P position on S7-400 is what unlocks online programming while the process continues to run.
3. Upload and Download Without STOP
For the following operations the CPU can remain in RUN-P on S7-300 or in RUN-P on S7-400:
- Downloading modified FB, FC, OB, DB, UDT, or VAT blocks (single-block download).
- Uploading blocks from the CPU to the PG.
- Online > Download (incremental compile + transfer).
- Modifying tag values in the monitor / VAT table.
- Performing online > Modify (force) operations on inputs/outputs.
The STEP 7 V5.5/V5.6 menu path used to switch operating modes from the PG without touching the hardware switch is:
- Establish an online connection:
PLC > Display Accessible NodesorPLC > Connect to Target System. - Open
PLC > Diagnostic/Setting > Operating Mode. - Select the desired state (STOP, RUN, RUN-P) and confirm.
In TIA Portal the equivalent path is: project tree > right-click the PLC > Online & Diagnostics > Operating Mode. The CPU must have access level Full access (no protection) or a configured HMI/PG password matching the CPU's protection level to permit remote mode change.
4. Operations That Require STOP
The following list summarizes the operations for which the CPU must be in STOP. This is the core answer to the original operator question:
| Operation | Reason | Restart Type Required |
|---|---|---|
| Hardware Configuration (HW Config) download with rack, module, or address change | Re-generates SDBs; module parameter sets change | Cold restart (OB102) or warm restart (OB100) |
| Adding/removing a module in the rack | Module address and diagnostic addresses shift | Cold restart |
| CPU memory reset (MRES) | Clears work memory, retentives, SDBs | Cold restart only |
| Compress memory (PIQ reduction) | Reclaims deleted-block space in load memory | STOP required for some CPU firmware |
| Downloading a DB with re-initialization of all values | Real/actual value conflicts on DB start values | STOP recommended to avoid process jumps |
| Changing CPU protection level from PG-access side | Security configuration | STOP recommended |
| Firmware update on CPU or interface module | Flash memory rewrite | STOP mandatory |
| Reset to factory settings (S7-1500 / S7-1200) | Wipes IP, project, all data | STOP mandatory |
The original Siemens reply — "The only time you need to put in stop mode is you are changing the hardware configuration" — is correct for routine program edits but is conservative. The complete rule set above is what a commissioning engineer should apply.
5. System Data Blocks (SDB) Explained
System Data Blocks are not user-written blocks. They are generated automatically by the STEP 7 Hardware Configuration editor (HW Config) when you compile the station. SDBs contain:
- Module parameter records (input filter times, diagnostic enables, substitute values).
- CPU parameters (scan time monitoring, OB priority assignments, interrupt configuration).
- PROFIBUS / PROFINET node addresses and bus timing parameters.
- Symbolic I/O assignments (P, I, Q, M addressing derived from slot addresses).
- Communication connection data for S7 connections, TCP/UDP, ISO-on-TCP, FDL.
SDB numbers are allocated by the system starting at SDB 0 upward. They are downloaded with the HW Config download action. Reading SDBs back is performed with PLC > Upload Station to PG; this rebuilds the HW Config on the engineering station. On the CPU's load memory, SDBs can be inspected with PLC > Diagnostic/Setting > Module Information > SDB Container in STEP 7 V5.x, or via the online & diagnostics buffer in TIA Portal.
If SDBs become corrupt (diagnostic buffer entry "SDB error / parameter assignment error" with event IDs 0x80C4, 0x80C5), the recovery procedure is: bring CPU to STOP > re-download HW Config > perform cold restart. The corresponding Siemens S7-300/400 parameter assignment error FAQ lists all parameter-error event IDs.
6. Block Type Reference (S7-300/400)
STEP 7 distinguishes seven block kinds. Each occupies a number range allocated by the CPU firmware:
| Block | Range | User-Writable? | Loaded In | Primary Use |
|---|---|---|---|---|
| OB - Organization Block | 0-255 | Yes (custom OBs) | Work memory | Cyclic, interrupt-driven, error, startup |
| FB - Function Block | 0-65535 | Yes | Work memory + instance DB | Stateful reusable code with DI |
| FC - Function | 0-65535 | Yes | Work memory | Stateless routines, parameter passing |
| DB - Data Block | 1-65535 | Yes | Work memory | User data storage |
| SFB - System Function Block | 0-65535 | No (firmware) | Firmware ROM | Built-in stateful functions (e.g. SFB0 CTU) |
| SFC - System Function | 0-65535 | No (firmware) | Firmware ROM | Built-in stateless functions (e.g. SFC0 SET_CLK) |
| SDB - System Data Block | 0-65535 | No (auto-generated) | Load memory | Hardware configuration data |
| UDT - User-Defined Type | 0-65535 | Yes | Work memory | Reusable data structure template |
Common SFB/SFC catalog excerpts (firmware-dependent; see STEP 7 List of SFBs/SFCs Reference):
| SFB / SFC | Name | Function |
|---|---|---|
| SFB 0 | CTU | Count Up |
| SFB 1 | CTD | Count Down |
| SFB 2 | CTUD | Count Up/Down |
| SFB 3 | TP | Generate pulse (IEC timer) |
| SFB 4 | TON | On-delay timer (IEC) |
| SFB 5 | TOF | Off-delay timer (IEC) |
| SFC 0 | SET_CLK | Set CPU clock (date/time) |
| SFC 1 | READ_CLK | Read CPU clock |
| SFC 20 | BLKMOV | Copy memory area |
| SFC 36 / 37 | MSK_FLT / UNMASK_FLT | Mask synchronous errors |
| SFC 46 | STP | Force CPU to STOP |
| SFC 47 | WAIT | Delay execution up to 32767 ms |
| SFC 51 | RDSYSST | Read system status list (SSL) |
7. Pointer Data Type Usage in STL vs LAD/FBD
The POINTER and ANY data types are defined for S7-300/400 and are used in two contexts:
- Formal parameter declarations of system blocks (e.g. SFC20 BLKMOV takes ANY; SFC59 RD_REC takes ANY).
- Indirect memory addressing in STL programs.
POINTER occupies 6 bytes: two bytes for the DB number (0 for non-DB areas), and four bytes formatted as a byte address (24-bit value, bit offset 0 only). Example:
P#DB20.DBX 100.0 // 6-byte pointer: DB 20, byte 100, bit 0
ANY occupies 10 bytes: data type ID, repetition factor, DB number, byte address. The standard STL pattern for an ANY source variable is:
P#M 100.0 BYTE 20 // ANY: 20 bytes starting at M100.0
In LAD and FBD the same blocks are inserted graphically; the ANY input on SFC20 BLKMOV is filled by entering a label or memory area, and STEP 7 generates the underlying POINTER/ANY automatically. The operator can remain in LAD/FBD and never see the literal P# syntax. Consequently the "pointer data type is only for STL" answer is incorrect — the data type is used internally in both editors, but only STL exposes it directly in source code.
Indirect addressing in STL uses three register pairs:
| Register Pair | Range | Address Type |
|---|---|---|
| AR1, AR2 | 32-bit | Internal pointer for indirect access |
| DBW / DIW / MW / LW / PQW | 16-bit word offset | Word-indexed |
| DBD / DID / MD / LD / PQD | 32-bit dword offset | Dword-indexed |
// STL example: indirect addressing via AR1
L P##SOURCE // Load pointer to SOURCE
LAR1 // Load into AR1
L W [AR1,P#2.0] // Load word at offset 2 from AR1
On S7-1200 and S7-1500 the equivalent pattern is the AT view of a data block slice or the Variant data type. The POINTER type is retained only for legacy compatibility.
8. The Control Unit in HW Config
The "control unit" mentioned in the original post refers to the CPU object inside the S7 station. In HW Config, dragging a CPU (e.g. CPU 315-2 PN/DP, 6ES7315-2EH14-0AB0) into slot 2 of a rack inserts a control unit object that owns:
- The MPI/PROFIBUS interface (X1) properties.
- The PROFINET interface (X2) on PN-capable CPUs.
- The OB configuration (cycle monitoring, OB1 scan time, OB priority assignments).
- The time-of-day, runtime meters, and diagnostic buffer settings.
- The protection/access-level password assignments.
Changes to any of these objects trigger SDB regeneration and therefore require STOP on S7-300/400. CPU objects in TIA Portal's Device Configuration expose the same parameters and follow the same rule.
9. Online Editing Workflow (STEP 7 V5.x)
The recommended sequence to modify a running program block without stopping the process is:
- Open the project online:
View > Online(or press Ctrl+F10 on the editor). - Open the FB/FC to be edited. The editor shows the online version against a yellow background.
- Make the modification offline (white background). STEP 7 tracks the difference.
- Compile with
Program > Compile(or Ctrl+B). - Download with
PLC > Downloador the toolbar icon. The dialog will list the modified blocks. - Confirm. The CPU stays in RUN-P; the new code activates on the next OB1 scan.
If the dialog displays "CPU must be in STOP" the most common causes are:
- The CPU mode selector is set to RUN instead of RUN-P.
- The protection level prevents write access from this PG.
- The block was generated from HW Config (SDB or system block).
- The interface (signature) of a multi-instance FB has changed and forces a download to all instance DBs.
10. Hardware Configuration Download Procedure
When a hardware change is unavoidable, the standard commissioning procedure is:
- Bring the affected CPU to STOP via the key switch or
PLC > Operating Mode. - In HW Config, perform the rack/module change.
- Save and compile (
Station > Save and Compile, Ctrl+F7). - Download to the target (
PLC > Download to Target Station, Ctrl+L). - Verify the SDBs in the diagnostic buffer:
PLC > Module Information > Diagnostic Buffer. Look for event ID 0x1155 / 0x1156 (module parameter assignment OK) and absence of 0x80C4 / 0x80C5 (parameter errors). - Switch the key switch from STOP to RUN (or RUN-P). The CPU performs an OB100 warm restart (default) or OB102 cold restart depending on configuration.
- Confirm outputs via VAT and check process state.
11. Verification Checklist
| Check | Method | Expected Result |
|---|---|---|
| Operating mode after online edit | PG online view / CPU LEDs | RUN or RUN-P, BF off, SF off |
| Modified block present in CPU | PLC > Compare Blocks | Online and offline identical for modified blocks |
| Diagnostic buffer clean | PLC > Module Information > Diagnostic Buffer | No entries "parameter assignment error" |
| Scan time | PLC > Module Information > Scan Time | Within configured OB1 max cycle time |
| Retentive data intact | Online VAT on MB / DB tags | Values match last setpoint |
| Outputs in safe state during STOP | Wire test of DO module | Outputs de-energized or in configured substitute value |
12. Troubleshooting Matrix
| Symptom | Likely Cause | Remedy |
|---|---|---|
| Download fails with "CPU in wrong operating state" | Mode switch in RUN, not RUN-P | Turn switch to RUN-P or use PLC > Operating Mode |
| "Protection level violated" | PG password missing or wrong | Configure protection level in HW Config; enter password on CPU |
| SDB download interrupted | Loss of MPI/PN connection | Re-establish connection, re-download HW Config |
| SF LED on, diagnostic buffer shows 0x80C4 | Module parameter mismatch | Compare HW Config with physical rack; replace or reconfigure module |
| Online edit accepted but old code still runs | Instance DB not re-downloaded | Use "Download all" or check interface signature mismatch |
| CPU stays in STOP after RUN command | OB not loaded or OB85 error | Check OB1, OB100, OB102 presence; review diagnostic buffer |
| "Memory card write-protected" on download | Toggle on MMC set to write-protect | Set toggle to off, re-insert card |
| Pointer access yields wrong data | DB number = 0 for non-DB areas ignored by FB | Use correct POINTER format with explicit DB or 0 + area pointer |
FAQ
Do I always need to put an S7-300/400 CPU into STOP before downloading a program?
No. Routine download of modified FB, FC, OB, DB, UDT, and VAT blocks works with the CPU in RUN-P on S7-300 (mode-switch position RUN-P, present on CPU 312 through 319) or RUN-P on S7-400 (four-position key switch). STOP is required for HW Config downloads, MRES, compress, firmware updates, and DB re-initializations.
What is a System Data Block (SDB) on S7-300/400?
An SDB is automatically generated by HW Config during compile/download and contains module parameters, CPU parameters, MPI/PROFINET addresses, diagnostic settings, and connection data. SDBs are not user-editable; they are produced by STEP 7 from the station's hardware configuration and reside in load memory.
Is the POINTER data type only usable in STL?
POINTER (6-byte) and ANY (10-byte) are formal parameter types accepted in both STL and LAD/FBD. They are typed at the input of system blocks such as SFC20 BLKMOV. In LAD/FBD the editor enters the pointer automatically; in STL the engineer writes literal P# syntax and can use indirect addressing via AR1/AR2 with byte/dword offsets.
What is the function of the control unit object in HW Config?
The control unit is the CPU object within the S7 station. It owns the MPI/PROFIBUS and PROFINET interface parameters, OB configuration, time-of-day and runtime meter settings, diagnostic buffer behavior, and access-protection password assignments. Modifying any of these parameters regenerates SDBs and forces the CPU into STOP for the download.
How can I download a single FB to a running S7-400 CPU without stopping it?
Set the mode selector to RUN-P, open the project online with Ctrl+F10, edit the FB offline, compile with Ctrl+B, then use PLC > Download (or the toolbar icon). The CPU will accept the new code while RUN continues; instance DBs are automatically re-initialized only if the FB interface signature changed.
What is the difference between FB, FC, SFB, and SFC?
FB (Function Block) is a user-written, stateful block with an associated instance DB for retentive tags. FC (Function) is user-written and stateless. SFB (System Function Block) and SFC (System Function) are firmware-provided equivalents with the same stateful/stateless distinction but reside in CPU ROM, so they cannot be modified. Examples: SFB0 CTU vs SFC0 SET_CLK.