S7-1200 CM 1242-5 PROFIBUS Slave Data Exchange via Hilscher CIFX

David Krause15 min read
ProfibusSiemensTutorial / How-to
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

Architecture Overview

The integration described here uses a SIMATIC S7-1200 CPU combined with the CM 1242-5 communications module to expose the S7-1200 as a PROFIBUS DP slave on an existing PROFIBUS DP network. The DP master in this scenario is a Hilscher CIFX family PCI or PCI-104 card installed in an industrial PC. Cyclic process data flows between the host application and the S7-1200 user program using the dual-port memory (DPM) of the CIFX card on the PC side and standard input/output process images backed by data blocks on the S7-1200 side.

The CM 1242-5 is purpose-built by Siemens as a PROFIBUS DP slave module. It connects to the left side of the S7-1200 CPU, is described by a GSD file shipped with the module, and is added to the device configuration of the S7-1200 station inside TIA Portal. The Hilscher CIFX card executes its own protocol stack autonomously and exchanges the process image with the host application through DPM or DMA, depending on the host driver. From the S7-1200 programmer's perspective, the PROFIBUS slave is just another distributed I/O device; the developer only needs to know which data blocks hold the input and output bytes and how they are addressed from user code.

Industrial PC Hilscher CIFX PCI card (DP Master) Host application Dual-Port Memory DMA or polled read/write PROFIBUS DP 9.6 kbps – 12 Mbps S7-1200 Station CM 1242-5 (DP Slave) S7-1200 CPU User Data Blocks (DB)

Prerequisites and Hardware Identification

Before beginning the configuration, confirm that all hardware and software components are on hand and that their firmware/software revisions support the integration. The CM 1242-5 module family has shipped under several order numbers; the most common is 6GK7 242-5DX30-0XE0. Always verify the article number printed on the front of the module against the Siemens online catalog before installing firmware.

Component Typical Order Number / Variant Required For
S7-1200 CPU CPU 1211C, 1212C, 1214C, 1215C, 1217C (Firmware 4.x or newer) Host controller for CM 1242-5
CM 1242-5 6GK7 242-5DX30-0XE0 (DP slave module) PROFIBUS DP slave interface
Hilscher CIFX card CIFX 50E-DP, CIFX 104C-DP (master firmware loaded) PROFIBUS DP master in PC
TIA Portal V15.1 or newer (V16/V17 recommended) S7-1200 hardware configuration
Hilscher Configuration Tool SyCon.net (current version) CIFX firmware, GSD import, master slot map
GSD file for CM 1242-5 Siemens GSD bundle for CM 1242-5 PROFIBUS slave description
PROFIBUS cable and connector Siemens 6GK1 500-0FC10 or equivalent, with terminating resistor ON at end devices Physical layer
Note on Hilscher variants. The Hilscher product finder URL provided in supplementary material lists the CIFX 104C-DP as a DP slave card (PCI-104 form factor). Hilscher ships the same hardware with different firmware loads; the master functionality is enabled by loading a DP master firmware and license. When sourcing a CIFX card, specify "DP master" when ordering or load the master firmware package separately. Confirm with the Hilscher CIFX user manual whether your article number is the master or slave variant. The PC used here is the PROFIBUS class-1 master; the S7-1200 is class-1 slave.

Installing the CM 1242-5 GSD File in TIA Portal

The CM 1242-5 is described by a GSD file that ships with the module on a Siemens DVD or that can be downloaded from the Siemens Industry Online Support portal. The same GSD is used both by TIA Portal (as a generic PROFIBUS slave device under the "PROFIBUS DP" folder) and by the Hilscher configuration tool (to recognize the slave's slot structure).

  1. Open TIA Portal and load the S7-1200 station project.
  2. From the menu choose Options → Manage general station description files (GSD).
  3. Browse to the directory containing the unzipped CM 1242-5 GSD bundle. The bundle typically contains a .gsd and one or more bitmap (.bmp) files.
  4. Select the GSD file and confirm. TIA Portal parses the file and reports any version conflicts.
  5. After installation, the CM 1242-5 appears under Other field devices → PROFIBUS DP → Siemens → CM 1242-5 in the hardware catalog.

Verify that the GSD version matches the firmware of the physical CM 1242-5 module. TIA Portal V17 and a CM 1242-5 firmware 1.3.x or higher are the recommended combination for new deployments.

Configuring the S7-1200 as DP Slave in TIA Portal

The S7-1200 station must be configured as the DP master only when the S7-1200 itself hosts a CM 1243-5 (master module). When using a CM 1242-5 the S7-1200 acts strictly as a DP slave, so the DP master role belongs to the Hilscher CIFX card in the PC. The S7-1200 still requires configuration of the slave interface so that TIA Portal knows which bytes of the CM 1242-5 are mapped into the S7-1200 process image.

  1. In the S7-1200 device view, drag the CM 1242-5 from the hardware catalog onto the left bus of the CPU. The slot to the immediate left of the CPU is slot 101 for CM modules.
  2. Open the CM 1242-5 properties and select the PROFIBUS interface node.
  3. Click Add new subnet to create the PROFIBUS subnet (default name PN/IE_1 may be changed). Set the baud rate to match the Hilscher master (typical default: 1.5 Mbps). Supported rates are 9.6 kbps, 19.2 kbps, 45.45 kbps, 93.75 kbps, 187.5 kbps, 500 kbps, 1.5 Mbps, 3 Mbps, 6 Mbps, and 12 Mbps.
  4. Assign a PROFIBUS address to the CM 1242-5 (for example 3). This address must be unique on the bus and must match the slave address configured on the Hilscher master.
  5. Open the Operating mode node and select DP slave. The module is fixed to this role; the option to choose master is intentionally absent for the CM 1242-5.
  6. Under Module parameters, enable diagnostic interrupts if the application needs bus diagnostics reported to the CPU diagnostic buffer.

Mapping PROFIBUS Slots to Data Blocks

The CM 1242-5 GSD exposes a configurable number of slots, each of which represents one PROFIBUS slot in the slave. The Hilscher master will read/write the configured number of bytes per slot. The default slot configuration is shown below; the values can be reduced or extended up to the module's maximum I/O capacity of 240 bytes input and 240 bytes output total.

Slot Default Length Direction Mapping in S7-1200
0 Diagnostic slot (no cyclic I/O) Not mapped to process image
1 4 bytes in / 4 bytes out Bidirectional Input/output process image area
2 8 bytes in / 8 bytes out Bidirectional Input/output process image area
3 16 bytes in / 16 bytes out Bidirectional Input/output process image area
4 32 bytes in / 32 bytes out Bidirectional Input/output process image area
5–15 0 (empty) Optional, user-defined

To link these slots to user DBs, return to the device view of the CM 1242-5 in TIA Portal. Each slot has a Process image property that can be mapped into the S7-1200 process image (PII / PIQ). Alternatively, the slot can be left out of the process image and accessed directly via the address area %IW/%QW or by using the standard I/O access functions from user code.

Practical recommendation. Create one DB per logical data block (for example DB10_InputsFromMaster and DB20_OutputsToMaster) and use the MOVE_BLK, BLKMOV, or MOVE_BLK_VARIANT instruction to copy bytes between the I/O area and the DB at the start of every cycle. This keeps the PROFIBUS address space separate from application variables and simplifies code reuse.

Configuring the Hilscher CIFX Card as DP Master

The Hilscher side of the integration uses the SyCon.net configuration tool (or the legacy CIFX setup utility, depending on the firmware package purchased). The master loads the slave's GSD, defines which bytes of each slave slot are exchanged, and presents the resulting image to the host application via the dual-port memory.

  1. Install SyCon.net on the industrial PC and connect to the installed CIFX card. The tool lists the card with its MAC, firmware slot, and current protocol.
  2. Load the DP master firmware onto the CIFX card if not already present. The firmware file is named CIFXDPMA.nxf or similar, depending on the Hilscher version.
  3. Add the CM 1242-5 to the PROFIBUS network by importing the same Siemens GSD used in TIA Portal. The GSD is imported through Device → Import GSD.
  4. Place the CM 1242-5 on the bus at the address that matches the physical module (in the example: address 3).
  5. Open the slot configuration of the slave. Confirm that the byte lengths match the configuration done in TIA Portal exactly. Mismatched slot lengths are the most common cause of bus errors.
  6. Assign the input/output areas to the desired offsets in the CIFX dual-port memory. Typical defaults place inputs at DPM offset 0x0000 and outputs at 0x0200, but offsets can be customized.
  7. Download the configuration to the CIFX card and restart the device.
DPM versus DMA. The Hilscher CIFX card can expose process data either through dual-port memory (polled by the host driver) or via DMA. For deterministic latency, configure DMA in the host driver properties; for simple integration, polling the DPM at 1–5 ms is sufficient. The choice does not change the PROFIBUS configuration.

Dual-Port Memory Layout and Data Exchange

The dual-port memory is divided into control/status area and process data area. The exact layout depends on the Hilscher firmware version, but the structure follows the Hilscher DPM specification:

DPM Offset Direction Width Description
0x0000 Host ↔ Card 64 bytes Control/status block (handshake, watchdog, bus state)
0x0040 Card → Host Application specific Process input data (PC reads what S7-1200 sent)
0x0200 Host → Card Application specific Process output data (PC writes what S7-1200 receives)
0x0400 Card → Host Variable Diagnostic buffer (extended status, error codes)

The host application (C, C++, .NET, or LabVIEW) reads the input area and writes the output area. On the S7-1200 side the same bytes are visible at the I/O addresses of the CM 1242-5. If slot 1 is configured for 4 bytes in / 4 bytes out and slot 2 for 8 bytes in / 8 bytes out, the total input area is 12 bytes at, for example, %IW100..%IW111 and the output area 12 bytes at %QW100..%QW111.

Sample S7-1200 Code for Data Exchange

The code below is written in SCL (Structured Control Language) for an S7-1200 firmware 4.4 CPU. It copies the cyclic PROFIBUS inputs from the CM 1242-5 process image into DB10 and copies DB20 out to the PROFIBUS outputs. The blocks are evaluated every scan; if higher determinism is needed, place them in a cyclic interrupt OB (e.g. OB30) with a 1 ms period.

// Block: OB1 (Main) – call the PROFIBUS exchange FB once per cycle // Inputs from CM 1242-5 process image start at %IW100 // Outputs to CM 1242-5 process image start at %QW100 "ProfibusExchange"( iSlotInStart := 100, // first input word address from CM 1242-5 iSlotOutStart := 100, // first output word address to CM 1242-5 iInLen := 12, // total input bytes / 2 = words iOutLen := 12 // total output bytes / 2 = words ); // Function block: ProfibusExchange (FB, SCL) // Copies process image bytes into / out of application DBs FUNCTION_BLOCK "ProfibusExchange" VAR_INPUT iSlotInStart : INT; // start address of inputs in process image iSlotOutStart : INT; // start address of outputs in process image iInLen : INT; // length of input area in WORDS iOutLen : INT; // length of output area in WORDS END_VAR BEGIN // Copy inputs from CM 1242-5 image -> DB10 BLKMOV( SRCBLK := P#I{iSlotInStart} WORD{iInLen}, DSTBLK := "DB10_InputsFromMaster".iw_ProfibusInput ); // Copy outputs from DB20 -> CM 1242-5 image BLKMOV( SRCBLK := "DB20_OutputsToMaster".qw_ProfibusOutput, DSTBLK := P#Q{iSlotOutStart} WORD{iOutLen} ); END_FUNCTION_BLOCK

Define DB10 as a global DB with a WORD array of sufficient length (e.g. ARRAY[1..6] OF WORD for 12 bytes) and DB20 similarly. Mark both DBs with Optimized block access = OFF if you want to access the words by absolute name; otherwise use symbolic addressing only.

Commissioning and Verification

  1. Power up the PC with the Hilscher CIFX card and verify that the green "RUN" LED on the card is steady. A blinking red LED indicates firmware download state; solid red indicates a configuration or bus fault.
  2. Power up the S7-1200 with the CM 1242-5 attached. The CM 1242-5 carries two status LEDs: SF (red, group fault) and BF (red, bus fault). Both must be OFF in normal operation.
  3. From TIA Portal, go online with the S7-1200 and open Online & Diagnostics → Diagnostics buffer. Confirm that no DP slave diagnostic interrupts are present.
  4. Open the Watch table on DB10 and DB20. Force a known value into DB20; verify that the host application receives the same value at the configured DPM output offset within one PROFIBUS cycle.
  5. From the host application, write a known pattern into the DPM input area; verify that it appears in DB10 within one PROFIBUS cycle.
  6. Use SyCon.net's online monitor to inspect the bus state: the master must report Data exchange with the configured slave address, and the slave's diagnostic bytes must show 0x00 (no errors).
  7. Capture a PROFIBUS trace using a class-2 diagnostic tool (such as the Siemens PROFIBUS Diagnostics Repeater or the Hilscher PROFIBUS Monitor) to confirm token passing, parameterization telegrams, and check the cyclic data exchange CRC.

Troubleshooting Matrix

Symptom LED State (CM 1242-5) LED State (CIFX) Likely Cause Corrective Action
No bus activity BF solid red RUN solid green, but DP state = Wait_Prm Master has not sent parameterization Check that the slave address and slot lengths match between SyCon.net and TIA Portal; confirm baud rate parity
Intermittent data exchange BF blinking red RUN blinking green Baud rate mismatch or terminator missing Verify terminating resistor is ON at both end devices and OFF at all middle devices; set identical baud rate on master and slave
Data exchange established but values are wrong SF OFF, BF OFF RUN green Slot length mismatch between master and slave Compare byte lengths of each slot in SyCon.net to the slot configuration in TIA Portal; reload configuration
S7-1200 diagnostic buffer reports "Station failure" SF red, BF red RUN green Cable break or duplicate slave address Check PROFIBUS address switches on all stations; inspect D-sub connector pin-out for crossed A/B lines
Host application sees only zero bytes SF OFF, BF OFF RUN green DPM offset configured incorrectly in host driver Verify the input/output offsets match the layout exported from SyCon.net; check the handshake byte
Configuration download fails SF OFF, BF OFF SF red on CIFX Incompatible firmware / license on CIFX Confirm the DP master firmware and license are loaded; cross-check CIFX article number against Hilscher delivery note
Signal integrity warning. PROFIBUS DP at 12 Mbps requires that the cable shield be bonded to ground at every connector backshell and that the segment be earthed at one point only. Floating shields or daisy-chained shield terminals create ground loops that corrupt the differential signal and present as intermittent BF faults that are difficult to reproduce.

Diagnostic Codes and PROFIBUS Status

The CM 1242-5 reports its own state through the standard PROFIBUS slave diagnostic bytes (bytes 7..21 of the slave diagnostic telegram, per EN 50170 Volume 2). Common values are:

Diagnostic Byte Value Meaning
Station status 1 0x00 Slave in data exchange, no error
Station status 1 0x01 Slave not ready for data exchange (parameterization missing)
Station status 1 0x04 External diagnostics present (extended diagnostic follows)
Station status 1 0x0C Watchdog timeout – master poll cycle too slow
Extended diagnostic 0x0B Channel-related diagnostic (see byte 9 for slot/channel)
Extended diagnostic 0x0F Module-related diagnostic – slot cannot provide configured I/O length

Use SyCon.net's "Extended Diagnostics" view or a class-2 diagnostic tool to decode these bytes during commissioning. The same bytes can be read from the host application through the DPM diagnostic buffer if the CIFX firmware exposes them.

Frequently Asked Questions

What is the maximum I/O data size supported by the CM 1242-5?

The CM 1242-5 supports up to 240 bytes of input and 240 bytes of output data per direction, distributed across a maximum of 32 slots. The default GSD provides five preconfigured slots (4, 8, 16, 32 bytes in each direction plus an empty slot); empty slots may be reduced or extended to fit the application.

Can the S7-1200 act as a PROFIBUS master?

No. The S7-1200 can only be a DP slave on PROFIBUS using the CM 1242-5. For master functionality, Siemens offers the CM 1243-5 module, which supports DP-V0/V1 master with up to 16 slaves. The choice between CM 1242-5 and CM 1243-5 is made at hardware selection time and cannot be changed by firmware.

Which Hilscher CIFX card firmware is required for DP master?

You need a CIFX card with the DP master firmware loaded (file extension typically .nxf) and an active master license. Cards shipped with slave firmware (such as the CIFX 104C-DP slave variant listed in the Hilscher product finder) cannot be reloaded as master without a separate firmware license from Hilscher. Confirm the article number and license state before ordering.

Do I need a separate GSD for the Hilscher configuration tool?

Yes. SyCon.net must be given the same GSD file used in TIA Portal so that it knows the slot structure of the CM 1242-5. Import the Siemens GSD through Device → Import GSD. A mismatch between the GSD versions on the two sides leads to silent data corruption because SyCon.net will calculate offsets based on the imported slot map.

Why does the BF LED stay on even though the cable is wired correctly?

The most common cause after a wiring check is a baud-rate mismatch between master and slave, or a duplicate PROFIBUS address. Open SyCon.net and TIA Portal and confirm both report the same baud rate and that the slave address set in the CM 1242-5 properties is unique on the bus. A second common cause is a missing or open terminating resistor at one end of the segment.

Is the CM 1242-5 supported in TIA Portal V18 and V19?

Yes. The CM 1242-5 has been supported continuously since TIA Portal V12 and remains supported in the current releases. For new deployments use TIA Portal V17 or newer together with the CM 1242-5 firmware V1.3.x or higher. Older combinations may still work but are no longer recommended for new projects.

Back to blog