Troubleshooting S7-300 AG_SEND AG_RECV ANY Pointer Error

David Krause14 min read
S7-300SiemensTroubleshooting
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

Troubleshooting S7-300 AG_SEND / AG_RECV P-Area Access Errors on a CP 343-1 Lean

A CPU 313C stations that fails to bring up a TCP connection through a CP 343-1 Lean and surfaces diagnostic buffer entries such as "P area, word access, Access address: 4" is almost always hitting an ANY-pointer fault inside the AG_SEND / AG_RECV call interface. The peripheral (P) area is being addressed because a malformed ANY pointer is being interpreted by the operating system as a process-image I/O read. The symptom is not a defective CP module and the supplied Siemens remedy ("Replace the module") is misleading - the pointer is wrong, not the hardware. This reference walks through the exact pointer construction, the diagnostic buffer interpretation, and the commissioning checks for the S7-300 / CP 343-1 Lean combination.

1. Affected Hardware and Firmware

Component Catalog Number Firmware / Version Notes
S7-300 CPU 313C 6ES7313-5BF03-0AB0 Firmware V2.6 or higher (for CP-redirected SEND/RECV) 64 KB work memory, integrated DI16/DO16; older 5BE01 / 5BG01 revisions also affected.
CP 343-1 Lean 6GK7343-1CX10-0XE0 Firmware V3.0 or higher recommended Single-port RJ45, 10/100 Mbit/s, max 8 S7 connections + 4 PG/OP slots; see CP 343-1 Lean device manual (Siemens ID 24485272).
STEP 7 SIMATIC Manager V5.5 + SP2 (or V5.6) N/A Required for CP 343-1 Lean V3.0 GSD import.
Function blocks FB 5 / FB 6 (AG_SEND / AG_RECV) from the SIMATIC_NET library CP 343-1 Lean ships block version V2.0 / V2.5 Older CPUs (firmware < V2.0) require the legacy FC 5 / FC 6 interface - see Siemens application note "Communication with CP 343-1" (ID 18638131).
Compatibility caveat: The CP 343-1 Lean block version installed in STEP 7 must match the firmware on the physical CP. If the block is newer than the firmware, AG_SEND returns STATUS = 8183hex (start-up of CP not yet finished) or 80B1hex (FW mismatch). Refer to the CP manual's release compatibility matrix.

2. Diagnostic Buffer Entry Decoded

The diagnostic buffer of the CPU reports two repeated entries:

Event ID  W#16#39xx  "I/O access error when updating the process image"
  P area, word access, Access address : 4
  P area, word access, Access address : 8
Field Value Meaning
Event class W#16#39xx CPU-detected I/O access error during process image update.
Area type P Peripheral / process-image-of-I/O area, NOT a flag, DB, or input byte.
Access width WORD (2 bytes) The ANY pointer requested a 16-bit read or write.
Address 4 (decimal) = PQW 4 / PIB 4 region Address points at the process image of the onboard I/O, which the CP does not own.

The error is generated by the CPU when the ANY pointer passed to AG_SEND / AG_RECV is corrupted or constructed incorrectly. The byte-offset field inside the ANY resolves to a small integer (4 or 8), which the CPU interprets as an offset from the start of the P area rather than from the referenced data block. Siemens lists two remedies - "replace the module" and "correct the logical address". In this fault pattern, the third remedy that actually applies is correct the source pointer.

3. Root Cause: ANY Pointer Construction

An ANY pointer in STEP 7 is a 10-byte structure describing a memory area, its byte offset, and its length. For AG_SEND the relevant parameter is SEND (input, ANY), which tells the function block what to transmit. A syntactically valid ANY for sending 420 bytes from DB100 looks like this in STL:

     L  W#16#10        // Syntax ID: S7ANY
     L  W#16#14        // Transport size: BYTE
     L  P#DB100.DBX0.0 // Byte offset pointer
     L  420            // Length in bytes
     T  P#DB100.DBX0.0 BYTE 420  // Combined ANY pointer literal

In LAD/FBD the pointer is typically entered at the SEND input. A common field failure is writing the literal in a way the editor accepts but the CPU rejects at runtime:

Form typed in editor Accepted by compiler? Runtime behaviour
P#DB100.DBX0.0 BYTE 420 Yes (correct) Transmits 420 bytes starting at DBX 0.0.
P#M 0.0 BYTE 420 Yes Transmits 420 bytes from the bit-memory area.
P#DB100.DBX0.0 WORD 210 Yes Transmits 420 bytes (210 words). Same wire length, different type tag.
DB100.DBX0.0 BYTE 420 (missing P#) Sometimes (legacy) Editor silently inserts default segment; CPU may resolve to P area if DB number 100 overlaps a peripheral slot mapping.
P#DB100.DBX0.0 REAL 105 Yes Length is bytes only, but type tag set to REAL changes the way the CP's firmware counts the buffer - mismatched length causes partial transmit and the CPU retries via P-area read.

The mechanism that produces the "P area, word access, Access address : 4 / 8" diagnostic is the following sequence:

  1. The AG_SEND FB is called with a length that exceeds the declared size of the data block referenced in the pointer.
  2. When the SEND FB passes the data to the CP via the backplane, the CP hardware requests the buffer from the CPU.
  3. The CPU's integrated I/O read logic interprets the byte offset of the malformed ANY (typically the first 16 bits of the pointer's low word) as a P-area slot offset.
  4. Because the P-area read returns nothing useful (slot 4 / 8 on a CPU 313C is not assigned to any signal module), the CPU logs the I/O access error and the AG_SEND call returns STATUS = 80A1hex or 8081hex.
  5. The CP's TCP connection eventually aborts, and the diagnostic buffer fills with W#16#39xx entries.

4. Correct ANY Pointer Examples

For a CPU 313C paired with a CP 343-1 Lean, the SEND and RECV pointers must satisfy three rules:

  1. The data block referenced in the pointer must already exist with sufficient declared length. Declare DB100 with length >= 420 bytes BEFORE calling AG_SEND; otherwise the editor accepts the pointer but the CPU cannot resolve it.
  2. The transport-size tag (BYTE, WORD, DWORD, REAL) must match a real divisor of the buffer length. AG_SEND supports BYTE, WORD and DWORD as transport tags.
  3. The pointer must be inside a data block or a bit-memory area that is also written by application code. Pointers into P#I or P#Q areas are not supported by AG_SEND - they always produce the P-area error.
// STL example for SEND parameter
     CALL  FB 5 , DB115            // AG_SEND, instance DB115
      ID        :=1               // Connection ID from NetPro
      LEN       :=420             // Number of bytes to send
      DONE      :=M100.0
      ERROR     :=M100.1
      STATUS    :=MW102
      SEND      :=P#DB100.DBX 0.0 BYTE 420

For an FB 6 (AG_RECV) the equivalent RECV buffer is declared ahead of time. The pointer passed to RECV describes the buffer that will be written by the CP, not the buffer that will be read by the application.

// STL example for RECV parameter
     CALL  FB 6 , DB116            // AG_RECV, instance DB116
      ID        :=1
      LEN       :=MW110           // Actual length received
      NDR       :=M120.0
      ERROR     :=M120.1
      STATUS    :=MW122
      RECV      :=P#DB200.DBX 0.0 BYTE 420
Critical: The data blocks DB100 (send) and DB200 (receive) must be created in the offline S7 program with length >= 420 bytes and the block must be present in the online program of the CPU. If DB100 was created on the programmer but never downloaded - or was downloaded with a smaller length - the CPU will trap the call and the diagnostic buffer will record exactly the "P area, word access" sequence shown earlier. Use PLC > Download User Program to Memory Card or Monitor/Modify > View on DB100 to confirm the byte count.

5. Step-by-Step Resolution

  1. Stop the CPU in STOP mode from STEP 7 (PLC > Operating Mode > Stop).
  2. Open DB100 in the offline project and confirm that the data block length is >= the value in the SEND pointer. If the length is 0, expand the DB to 420 bytes (or higher) and recompile.
  3. Open the FB 5 call in OB1 (or wherever AG_SEND is called). Right-click the SEND input and select Symbolic > Edit. Re-type the literal as P#DB100.DBX0.0 BYTE 420 exactly. Make sure no hidden characters or different transport-size tags are present.
  4. Compile the program with Save and Compile. Resolve any warnings about overlapping or uninitialised DBs.
  5. Download the corrected program to the CPU with PLC > Download. Tick "Download to target system - overwrite all blocks" so that DB100 is refreshed with its new declared length.
  6. Switch the CPU to RUN. Open PLC > Diagnostic Buffer and confirm that no new W#16#39xx entries are written.
  7. Force AG_SEND / AG_RECV to run once by setting ACT = TRUE in the call. Watch the DONE bit and STATUS word. STATUS = 0000hex for one scan indicates a successful TCP send. STATUS = 8183hex means the CP is still starting up; wait two seconds and retry.
  8. Capture the TCP connection in NetPro. Verify that the configured connection ID matches the ID input of FB 5 / FB 6. A mismatch produces STATUS = 8182hex ("connection not established") and the CP will repeatedly reset the P-area fault.
  9. Verify from the remote partner that bytes are being received. Use Wireshark or the partner's receive buffer to confirm that exactly 420 bytes are arriving per call.

6. Connection Resource Constraints on S7-300

Older S7-300 CPUs - and especially the CPU 313C paired with the CP 343-1 Lean - have very limited connection resources. The CP 343-1 Lean provides a maximum of 8 S7 connections and 4 PG/OP slots. If a partner opens more connections than the configured limit, the CP responds with ERROR = 1 and STATUS = 80C3hex ("no resources available"), which the CPU's diagnostic buffer will sometimes represent as another P-area access error.

Resource CP 343-1 Lean max CPU 313C max (PG/OP+S7) Notes
S7 connections 8 4 (firmware V2.6); 2 on earlier FW Both ends must be considered; the lower of the two is the effective ceiling.
PG/OP connections 4 (shared) 1 Reserved by STEP 7 online session.
Open TCP connections via SEND/RECV 8 Part of S7 connection count Each NetPro "TCP connection" consumes one ID.
Simultaneous jobs (per call interface) 1 per ID 1 AG_SEND is non-reentrant per connection ID.

Use PLC > Accessible Nodes in STEP 7 to enumerate active connections. On the CP's web server (if enabled) the page Information > Connection Statistics lists every open ID, the partner IP, and the byte counters. Compare those against the IDs configured in NetPro to detect orphaned connections from previous commissioning attempts.

7. CP 343-1 Lean Configuration Requirements

The CP must be configured in HW Config with the correct slot (slot 4 for an S7-300 rack). The CP's Ethernet interface is then opened in NetPro with one or more connections of the appropriate type. For an AG_SEND/AG_RECV TCP connection:

  1. Insert a new connection on the CP, choose TCP connection.
  2. Set the partner IP address and the partner's port (default 2000 for ISO-on-TCP, 102 for S7). For raw TCP use the port chosen on the partner application.
  3. Configure the CP's MAC or IP address; for the CP 343-1 Lean the MAC is on the front label.
  4. Compile and download the HW Config.
  5. Confirm the CP's LED pattern: SF off, BF1 off, LINK green, RX/TX flashing during traffic. A solid BF1 indicates the configured connection partner is unreachable.
Bayes' reminder: The CP 343-1 Lean does NOT support routing of S7 functions for other stations - it is a single-port CP without router capability. If a connection target sits on a different subnet, configure the IP router on the CP under Properties > Ethernet Interface > IP Parameters > Use Router.

8. Verification and Online Diagnostics

After correcting the pointer and downloading the program, perform the following acceptance checks:

Check Procedure Pass criterion
Diagnostic buffer clean PLC > Diagnostic Buffer, clear with "Refresh" No W#16#39xx entries in the last 60 seconds of RUN.
AG_SEND STATUS Monitor the STATUS word of the SEND instance DB 0000hex on completion, DONE bit = TRUE.
AG_RECV STATUS Monitor the STATUS word of the RECV instance DB 0000hex, NDR bit = TRUE when a frame arrives.
Connection ID match Cross-check the NetPro ID with the ID input Identical integer.
Buffer length match Watch LEN of RECV vs declared DB length LEN <= declared DB byte count.
CP RUN LED Visual inspection of the CP front panel RUN green, SF off, BF1 off.
Wire capture Wireshark on the Ethernet segment TCP frames matching connection ID appear at the configured cadence.

9. Related Fault Codes and Edge Cases

STATUS Name Typical cause Corrective action
80A1hex Send buffer too small or incorrect ANY pointer length exceeds the DB. Extend DB or shrink LEN parameter.
8081hex Timeout on send / receive Partner offline or wrong connection ID. Verify NetPro connection and IP reachability.
8182hex Connection not established AG_SEND called before AG_RECV partner or wrong ID. Match connection ID across the S7-300 / partner.
8183hex CP start-up not yet completed AG_SEND called immediately after CPU RUN transition. Add a 2-second delay before first call.
80C3hex No resources available CP connection limit reached. Free a connection or upgrade to CP 343-1 (non-Lean).
W#16#39xx I/O access error ANY pointer resolves to P area Correct the source pointer as documented in Section 4.
W#16#3312 Diagnostic interrupt from CP CP has lost link or partner closed TCP Check network cabling, restart CP via PLC > Accessible Nodes.
W#16#3842 Module error CP firmware crash Power-cycle rack; if persistent, replace CP.

Edge cases that frequently surface alongside the ANY-pointer fault:

  • Symbolic vs absolute addressing: switching from symbolic to absolute addressing in STEP 7 can silently reformat the literal - always verify the resulting ANY pointer after a project-wide Find/Replace.
  • Optimised DB vs standard DB: on S7-300 the option "Optimised block access" does not exist, but on S7-1500 it does. A project migrated from S7-1500 may carry over a non-deterministic DB layout; revert the DB to standard access before re-deploying to a CPU 313C.
  • Multi-instance DB: when AG_SEND / AG_RECV are called as a multi-instance inside another FB, ensure the multi-instance DB has been generated and downloaded.
  • PLC reinitialisation: a CPU cold restart resets all instance DBs to their initial values, including any pointer-adjacent data. Add an OB100 initialisation block to recreate SEND buffers on startup.

10. Preventive Maintenance Checklist

  1. After every program download, open the diagnostic buffer and verify no P-area access entries are written within 30 seconds of RUN.
  2. Add the following error ladder to every AG_SEND / AG_RECV call to capture STATUS history:
// STL snippet for capturing SEND errors
      A       ERROR                  // FB 5 ERROR output
      JCN     NOER
      L       STATUS                 // FB 5 STATUS word
      T       MW 200                // Snapshot to flag word
      S       M 205.0               // Latch "SEND error" bit
      JU      NOER
NOER: NOP   0
  1. Add a watchdog timer (e.g. a TON with PT = 10 s) that clears the latch and calls the CP's restart FB if STATUS stays non-zero longer than the timeout.
  2. Document each connection ID, partner IP and port in a table attached to the project. The CP 343-1 Lean frequently has the same connection ID reused for multiple protocols during commissioning - that overlap is one of the leading causes of intermittent P-area faults after a hot redeploy.

FAQ

What does the diagnostic buffer entry "P area, word access, Access address: 4" mean on an S7-300 CPU 313C?

It is a W#16#39xx I/O access error logged when the CPU's process-image update logic interprets a malformed ANY pointer as a peripheral-area read. The CPU is trying to fetch a WORD (2 bytes) from peripheral address 4 - the CP does not own slot 4 of the rack, so the read fails. The remedy is to correct the source pointer (for example P#DB100.DBX0.0 BYTE 420), not to replace the CP.

Why does a correct-looking literal such as P#DB100.DBX0.0 BYTE 420 still throw a P-area error?

Three causes account for most cases: (1) DB100 has not been created offline or its declared byte length is smaller than 420, (2) the wrong transport-size tag was used and the CP firmware miscounts the buffer, or (3) the program was downloaded without DB100, so the online DB is missing. Declare DB100 with length >= 420 bytes, recompile, and re-download the entire program including all data blocks.

How many TCP connections can the CP 343-1 Lean handle simultaneously with AG_SEND / AG_RECV?

The CP 343-1 Lean supports a maximum of 8 S7 / TCP connections and 4 PG/OP slots. The CPU 313C itself only allows 4 S7 connections (firmware V2.6 or higher). The effective ceiling is the lower of the two values, so a CPU 313C + CP 343-1 Lean combination supports 4 simultaneous SEND/RECV connections.

Which STEP 7 library contains AG_SEND and AG_RECV for the CP 343-1 Lean?

They are supplied in the SIMATIC_NET library as FB 5 (AG_SEND) and FB 6 (AG_RECV). After installing the CP in HW Config, the blocks are added to the S7 program under Libraries > SIMATIC_NET > CP 300 > Blocks. The instance DB number is assigned per call - use one unique instance DB per connection ID.

Can the same ANY pointer be reused for both AG_SEND and AG_RECV?

No. AG_SEND reads from the buffer; AG_RECV writes into it. If the same pointer is used for both, AG_RECV will overwrite data that AG_SEND has not yet transmitted, producing STATUS = 80A1hex. Always declare two independent buffers (e.g. DB100 for SEND and DB200 for RECV) and pass them through two distinct pointers.

Back to blog