C example, Basic example, References – Rockwell Automation 1771-DMC_DMC1_DMC4_DXPS Control Coprocessor User Manual User Manual
Page 203

API Library of Routines
Appendix B
DTL_RMW_W
B-72
C Example
/*
* Suppose there is a 16-bit “status word” in binary file 10, word 1,
* describing the current status of the machine. Bits 0 through 3 of
* this word contain a code for the “current operating mode” (0-F) of
* the machine.
*/
#define OPER_MODE_MASK 0xFFF0 /* last 4 bits = mode */
#define MANUAL_MODE 0x0002 /* bit 1*/
unsigned status;
unsigned data_id;
unsigned iostat;
.
.
.
status = DTL_C_DEFINE (&data_id, “B10:1, 1, WORD, MODIFY”);
status = DTL_RMW_W (data_id, OPER_MODE_MASK, MANUAL_MODE, &iostat);
if (status != DTL_SUCCESS)
{
printf (“Error %d %d changing to MANUAL\n”, status, iostat);
exit (status);
}
.
.
.
BASIC Example
The BASIC function code is 7.
procedure COPRO
DIM status : INTEGER
DIM n7_name : INTEGER
DIM iostat : INTEGER
DIM and_mask : INTEGER
DIM or_mask : INTEGER
.
.
.
rem * DTL_RMW_W - Read/modify/write from N7:0 1 word into rcvbuff
and_mask := $2
or_mask := $1230
RUN AB_BAS (7, status, n7_name, and_mask, or_mask, ADDR(iostat))
.
.
.
References
DTL_C_DEFINE(); DTL_READ_W();
DTL_WRITE_W();