Problem Overview
The Siemens CP 341 communication processor is widely deployed as a point-to-point Modbus RTU master or slave on S7-300 and S7-400 PLC backplanes. A recurring field issue is that the CP 341 configured as a Modbus slave accepts FC 03 (Read Holding Registers) requests without fault, but rejects every FC 06 (Write Single Register) or FC 16 (Write Multiple Registers) request with Modbus exception code 0x02 — Illegal Data Address. The same station, when reconfigured as a master with the same slave device, performs flawless reads and writes. The fault is therefore localized to the slave-side parameterization, the CP firmware, and the data-block address layout.
This reference explains the root causes of the error, the correct configuration procedure for the Modbus slave parameter blocks, the firmware update path, and the verification steps required to clear exception code 02. It targets engineers commissioning or troubleshooting a CP 341 with order numbers 6ES7341-1AH02-0AE0 (RS-232C) or 6ES7341-1BH02-0AE0 (RS-485/RS-422) running Modbus slave protocols.
Problem Details — Modbus Exception Code 02
Modbus exception code 0x02 is defined by the Modbus Application Protocol Specification (Modicon) as "Illegal Data Address." The CP 341 slave answers a write request by transmitting the offending function code with the MSB set plus the exception code:
| Direction | Bytes (hex) | Meaning |
|---|---|---|
| Master request (FC 06) | 01 06 00 0A 00 FF | Write register 10, value 0x00FF |
| Slave response | 01 86 02 | FC 86 = FC 06 + 0x80, exception 02 |
| Master request (FC 16) | 01 10 00 0A 00 02 04 00 FF 01 FF | Write 2 registers starting at 10 |
| Slave response | 01 90 02 | FC 90 = FC 16 + 0x80, exception 02 |
The SEND job on the master reports the Modbus slave instance-DB and the offending register number through the STATUS output word of the MODB_341 / P_SND_RK call. Combined with the Modbus trace of the slave (Step 7 → CP 341 → Diagnostics → Modbus trace), the engineer can pinpoint the register address the master is requesting and compare it against the configured range.
Root Cause Analysis
Five layered causes are observed in the field. They interact, and a station may exhibit multiple problems simultaneously:
-
Out-of-range parameter block — the register range defined on the FC 03/06/16 tab does not cover the register the master is targeting. CP 341 returns 0x02 because the start address falls outside
MIN DBtoMAX DB. -
Firmware defect on early CP 341 versions — firmware prior to
V 2.0.xfor the1BH02module mishandles FC 16 boundaries. The firmware defect was corrected in HSP releases; field experience shows the symptom disappears only after the firmware is upgraded toV 3.0.0or later (CP 341-1BH02-0AE0, MLFB 6ES7341-1BH02-0AE0). -
DB word index above 510 — the parameter block addresses
DBWx(x = 0..510). Data words atDW 511onward are unreachable by the slave firmware. - Crossing a 1024-byte (kilobyte) boundary — when the configured range straddles two consecutive DBs or crosses the 1024-byte page inside a single DB, the CP returns 0x02 even though the underlying data is contiguous.
-
Reverse direction in Modbus address space — Modbus register 0x0000 maps to
DBW0of the configured DB; many engineers interpret the Limits tab as inclusive MIN and MAX register numbers while the firmware treats them as starting and ending DB word indices.
CP 341 Hardware and Firmware Reference
Select the correct module variant before commissioning. The Modbus slave dongle is hardware-keyed:
| Order Number (MLFB) | Interface | Dongle | Firmware (latest) |
|---|---|---|---|
| 6ES7341-1AH02-0AE0 | RS-232C | 6ES7870-1AB01-0YA0 | V 1.3.x (no slave firmware fix after V 1.3.4) |
| 6ES7341-1BH02-0AE0 | RS-485 / RS-422 | 6ES7870-1AB01-0YA0 | V 3.0.0 (recommended for FC 16) |
| 6ES7341-1CH02-0AE0 | RS-232C + 20 mA | 6ES7870-1AB01-0YA0 | V 1.3.x |
The official configuration manual CP 341 Point-to-Point Communication, Installation and Parameter Assignment documents the parameter dialog and lists the function-code capabilities of each firmware revision.
MODB_341 Slave Block Parameters
The slave uses the standard library block MODB_341 (FB 80 in the example project) loaded into the S7-300 CPU. The block interfaces are:
| Parameter | Direction | Type | Meaning |
|---|---|---|---|
| LADDR | IN | INT | Logical base address of the CP 341 (e.g., 256) |
| SLAVE_DB | IN / IN_OUT | BLOCK_DB | Instance DB generated by the slave wizard |
| REQ | IN | BOOL | Trigger slave update job |
| DONE | OUT | BOOL | Job completed without error |
| ERROR | OUT | BOOL | Job completed with error |
| STATUS | OUT | WORD | Error / status code from CP |
The slave DB is auto-generated from the HW Config wizard. The SLAVE_DB image table is the binding between Modbus register numbers and S7 data-block words. The MODB_341 documentation on the Siemens documentation portal explains the SEND job and instance DB diagnostics in detail.
Step-by-Step Configuration for FC 03 / FC 06 / FC 16
The wizard on the CP 341 dialog Properties → Parameter → Modbus-Slave exposes eight tabs. The fields relevant to a write-capable slave are FC 01/05/15, FC 03/06/16, and Limits.
- Open HW Config, select the CP 341, open Properties and click Parameter…. When the dongle is detected, the Modbus-Slave entry is enabled (blue envelope icon).
- FC 01/05/15 tab — clear FC 15 if coil writes are not required. For 16-bit register writes only, leave this tab on its default values.
-
FC 03/06/16 tab — enable FC 03, FC 06, and FC 16. Enter the starting DB word (
DBWn) of the register window, e.g.,DB10.DBW0. The wizard treats this entry as the first register address accessible to the master; register 0x0000 will map here. - Limits tab — set MIN DBW to the same starting offset as in step 3, and MAX DBW to the offset of the last register that the master may access. For two consecutive DBs the limits must remain inside the smaller DB number; do not span DBs.
-
DB layout in the CPU — ensure the data blocks exist physically (DB10 and DB11) and contain the required number of
WORDvalues. CP 341 will not create the DBs. - Compile HW Config and download to the CPU and the CP. The parameters are pushed to the CP only after a full download.
- Rebuild the slave DB from the example project on the dongle diskette to obtain a clean instance DB; mismatched instance DBs cause the slave to silently reject FC 16 even with correct parameter blocks.
The Limits tab is the single most common source of exception 0x02. The CP 341 checks every FC 06/FC 16 request against MIN DBW ≤ target ≤ MAX DBW; if either bound is violated, the CP returns 0x02 without consulting the application program.
DB Address Constraints and Kilobyte Boundary Rules
The Modbus slave firmware inside CP 341 supports a maximum of 511 data words (0..510) per data block. Additional hard rules:
| Constraint | Value | Symptom on violation |
|---|---|---|
| Max DBW index | 510 | 0x02 (illegal address) |
| Max contiguous range | 1024 bytes / 512 words | 0x02 at the boundary |
| Cross-DB request | Disallowed | 0x02 or 0x03 (illegal value) |
| Unallocated DB | — | 0x02 or SF LED on CP |
| DB number range | 1..255 (recommended < 256) | 0x02 if the parameter block uses a high DB number |
Keep the target register count small and the offset low. A configuration of DB10.DBW0..DB10.DBW99 (100 words) is straightforward; DB10.DBW500..DB10.DBW520 requires the firmware to support a split range and frequently fails on older CP 341 versions. Where a wider register space is required, deploy multiple CP 341 stations or split the address map across two lower-numbered DBs (for example, registers 0..255 in DB10 and registers 256..511 in DB11) and configure two separate parameter blocks in the wizard.
Firmware Update Procedure
- Identify the current firmware under HW Config → CP 341 → Module Information. Note the hardware version and MLFB.
- Download the latest firmware/HSP from the Siemens Industry Online Support portal. Search for the MLFB of the CP 341 to obtain the matching firmware file (e.g.,
CP341_V3.0.0.upd). - Open SIMATIC Manager → PLC → Update Firmware, select the CP 341 slot, and load the upgrade file. The CP reboots; do not power down during update (typical 90-180 s).
- Re-download the HW Config and re-transfer the example project. Verify the CP boots without SF/BF errors and that the Modbus slave dongle LED indicates a healthy state.
- Re-test FC 06/FC 16 from the master. The firmware defect behind exception 02 is reproducible on
V 1.xand is corrected inV 2.0.xand later for the1BH02module.
Verification Procedure
- From the Modbus master, issue a read against
register 0. Expect FC 03 success. If this fails with 0x02 the slave image DB has not been loaded. - Issue a single-register write to
register 0using FC 06. Expect success and a read-back value equal to the written value. - Issue a multi-register write using FC 16 covering at least two consecutive registers. Expect success and consistent echo on read-back.
- Issue a write that intentionally targets a register outside the configured limits. Expect exception 0x02, confirming that the limit checking is now working correctly.
- Capture the slave's Modbus trace from HW Config → CP 341 → Diagnostics → Modbus Trace and verify the request/response match the application intent.
Troubleshooting Matrix
| Observed Symptom | Likely Cause | Corrective Action |
|---|---|---|
| FC 03 OK, FC 06 / 16 → 0x02 on first write attempt | FC 06/16 not enabled in wizard | Re-check FC 03/06/16 tab; enable both function codes |
| FC 16 fails only when crossing register 511 | Firmware DBW limit (510) | Reduce range or split into two parameter blocks |
| FC 16 fails at register boundary (every 512 words) | Kilobyte boundary crossing | Keep request within 1024-byte block or split DBs |
| All writes fail, reads return zeros | Wrong instance DB / SLAVE_DB pointer | Regenerate instance DB from dongle example project |
| All writes return 0x02 after firmware change | Wizard parameters not re-downloaded | Re-download HW Config and slave parameter blocks |
| Master trace shows request, slave returns no response | RS-485 termination / duplex mismatch | Check termination, A/B polarity, half-/full-duplex setting |
| Intermittent 0x02 only at runtime | Application overwrites DBW area used by slave | Reserve the slave DB exclusively for the CP |
| Persistent 0x02 across all register ranges | Firmware defect on early CP 341 | Upgrade CP firmware to latest HSP |
Related Configuration Points
The Modbus slave wizard also exposes tabs for FC 02 (Read Discrete Inputs) and FC 04 (Read Input Registers). These are read-only by design; a master attempting FC 05/06/15/16 against the input range receives exception 0x02 by specification. If the master must write, ensure the registers live in the holding-register map configured on the FC 03/06/16 tab, not on the FC 04 input map.
The Data Transmission tab controls the frame format (start bits, data bits, parity, stop bits, baud rate). A mismatch with the master baud rate does not produce 0x02 but produces timeout/no response. The baud rate must match exactly between CP 341 and the master device.
For RS-485 multidrop applications, the CP 341 acts as a slave on the bus. Bias resistors and termination (typically 120 Ω) must be present at both ends of the bus and the CP must be configured for RS-485 half-duplex operation in HW Config. Reversed A/B polarity looks identical to a frame error and is sometimes misdiagnosed as an address problem.
Safety and Operational Notes
Frequently Asked Questions
Why does my CP 341 Modbus slave return exception 02 only on FC 16 writes?
The CP 341 only allows FC 16 writes inside the register window configured on the FC 03/06/16 tab and within the Limits (MIN DBW to MAX DBW). Out-of-range addresses, addresses above DBW 510, or ranges that cross a 1024-byte boundary produce exception 0x02. Re-check the wizard parameter blocks and split the register map into lower-numbered DBs if a wider window is required.
Does upgrading the CP 341 firmware fix the FC 16 issue?
Yes. Field experience shows that CP 341-1BH02-0AE0 modules with firmware below V 2.0.x produce persistent 0x02 on FC 16 even with correctly configured parameter blocks. Upgrading to V 3.0.0 (the latest Siemens HSP) eliminates the firmware defect. Always re-download the HW Config and the example project from the dongle diskette after the firmware update.
Can the CP 341 Modbus slave serve more than 256 holding registers?
Yes, but only across two separate parameter blocks, each kept inside a single DB and below DBW 510. The CP does not handle ranges that cross data blocks or kilobyte boundaries, so plan the register map to fit within 0..510 of each DB. For maps larger than 1024 bytes, deploy two CP 341 stations or split the application into separate slaves.
What Modbus function codes does the CP 341 slave support?
The CP 341 slave supports FC 01 (Read Coils), FC 02 (Read Discrete Inputs), FC 03 (Read Holding Registers), FC 04 (Read Input Registers), FC 05 (Write Single Coil), FC 06 (Write Single Register), FC 15 (Write Multiple Coils) and FC 16 (Write Multiple Registers). Each function code must be enabled in the corresponding wizard tab. FC 05/15/16 require the Modbus slave dongle (6ES7870-1AB01-0YA0).
Why are my FC 06 writes succeeding on the wire but the CPU does not see them?
The CP 341 updates the configured DBW range inside the slave instance DB on completion. If your application program reads from a different DB or a different offset, the data is present but invisible. Verify LADDR, the slave SLAVE_DB pointer, and the application DB access offsets. Capturing the Modbus trace in HW Config confirms the bytes landed on the wire correctly.