Applies To
GC5050, GX5050, GX5055, GX5150, GX5280, GX5290, GX5290e, GX5295
Purpose
Returns the program counter value of the specified Master board.
Syntax
DioReadProgramCounter (nMasterHandle, pdwCounter, pnStatus)
Parameters
Name |
Type |
Comments |
nMasterHandle |
SHORT |
Master board handle. |
pdwCounter |
PDWORD |
Returned program counter value (address). |
pnStatus |
PSHORT |
Returned status: 0 on success, negative number on failure. |
Comments
GC5050/GX5050:
Set 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:
Set 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:
Set 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 waits until the board is in the HALT state and then retrieves the last program counter value:
#define HALT_ADDRESS_ERROR1 0x128
DioTrig (nMasterHandle, &nStatus);
do
{ DioReadStatusRegister (nMasterHandle, &wData, &nStatus);
}while (wData & 0x1C ==0); // mask the STATE bits
DioReadProgramCounter (nMasterHandle, &dwCounter, &nStatus);if (dwCounter == HALT_ADDRESS_ERROR1)
// Do something
See Also
DioWriteProgramCounter, DioReset, DioGetErrorString