DioWriteProgramCounter

Applies To

GC5050, GX5050, GX5055, GX5150, GX5280, GX5290, GX5290e, GX5295

Purpose

Writes a new value to the program counter.

Syntax

DioWriteProgramCounter (nMasterHandle, dwCounter, pnStatus)

Parameters

Name

Type

Comments

nMasterHandle

SHORT

Master or File board handle.

dwCounter

DWORD

Program counter value.

pnStatus

PSHORT

Returned status: 0 on success, negative number on failure.

Comments

GC5050/GX5050:

Sets the address of the input, output and control memories. The program counter may be changed only by a control memory command in the RUN state, or by calling a function that resets the program counter to 0, such as DioReset, DioSaveFile, etc. The control memory commands that change the value of the program counter are JUMP, LOOP, CALL and RETURN.

GX5055:

Sets the address of the input, output, direction, valid data and control memories. The program counter may be changed only by a control memory command in the RUN state, or by calling a function that resets the program counter to 0, such as DioReset, DioSaveFile, etc. The control memory commands that change the value of the program counter are JUMP, LOOP, CALL and RETURN.

GX5150:

Sets the address of the I/O and control memories. The program counter may be changed only by a control memory command in the RUN state, or by calling a function that resets the program counter to 0, such as DioReset, DioSaveFile, etc. The control memory commands that change the value of the program counter are JUMP, LOOP, CALL and RETURN.

GX5280/ GX5290/GX5290e/GX5295:

GX5280: Sets the address of the I/O memory.

GX5290/GX5290e/GX5295: Sets the address of the I/O and direction memories. The program counter may be changed only by a control memory command in the RUN state, or by calling a function that resets the program counter to 0, such as DioReset, DioSaveFile, etc.

When the number of active channels is less than 32, the program counter value will be rounded to be on a 32 channels boundaries. E.g. if the I/O configuration was set to 16 channels and the program counter value was set to 1025 the value will be rounded to 1024.

Note: when reading back the program counter value it will correspond to the actual active number of channels as follows:

Number of Active Channels

Program Counter Range

32

GX5281: 0 to 32M

GX5282: 0 to 64M

GX5283: 0 to 128M

GX5291/GX5291e: 0 to 32M

GX5292/GX5292e: 0 to 64M

GX5293/GX5293e: 0 to 64M

GX5295: 0 to 64M

16

GX5281: 0 to 64M

GX5282: 0 to 128M

GX5283: 0 to 256M

GX5291/GX5291e: 0 to 64M

GX5292/GX5292e: 0 to 128M

GX5293/GX5293e: 0 to 128M

GX5295: 0 to 128M

8

GX5281: 0 to 128M

GX5282: 0 to 256M

GX5283: 0 to 512M

GX5291/GX5291e: 0 to 128M

GX5292/GX5292e: 0 to 256M

GX5293/GX5293e: 0 to 256M

GX5295: 0 to 256M

4

GX5281: 0 to 256M

GX5282: 0 to 512M

GX5283: 0 to 1G

GX5291/GX5291e: 0 to 256M

GX5292/GX5292e: 0 to 512M

GX5293/GX5293e: 0 to 512M

GX5295: 0 to 512M

2

GX5281: 0 to 512M

GX5282: 0 to 1G

GX5283: 0 to 2G

GX5291/GX5291e: 0 to 512M

GX5292/GX5292e: 0 to 1G

GX5293/GX5293e: 0 to 1G

GX5295: 0 to 1G

1

GX5281: 0 to 1G

GX5282: 0 to 2G

GX5283: 0 to 4G

GX5291/GX5291e: 0 to 1G

GX5292/GX5292e: 0 to 2G

GX5293/GX5293e: 0 to 2G

GX5295: 0 to 2G

 

Example

The following example writes the value 1024 to the program counter and then verifies the setting by calling DioReadProgramCounter:

 

SHORT nStatus;

DWORD dwAddress;

DioWriteProgramCounter (nHandle, 1024, &nStatus);

DioReadProgramCounter (nHandle, &dwAddress, &nStatus);

 

See Also

DioReadProgramCounter, DioGetErrorString