Sample api module, Read-modify-write – Rockwell Automation 1785-Vx0B, D17856.5.9 PLC-5 VME VMEbus Programmable Controllers User Manual User Manual

Page 77

Advertising
background image

Chapter 6

PLC-5/VME Processor
Communications Commands

6-8

Refer to page D-3 for additional information on PCCC status codes.

Sample API Module

For a sample
interface
header file:

Refer to page:

For a sample
implementation
source file:

Refer to page:

P40VIHAS.H

B-64

P40VIHAS.C

B-67

Use this command to set or reset specified bits in specified words of data
table memory. The command tells the PLC-5/VME processor to apply a
read-modify-write cycle to:

read out the data
apply an AND mask
apply an OR mask
return the results to the specified address

The address/mask field (up to 242 bytes) in the command packet contains
multiple blocks, each of which contains an PLC-5/VME processor file
address, a 2-byte AND mask, and a 2-byte OR mask.

Read-Modify-Write changes bits in one or more elements in the
processor’s memory. The data field in the command contains up to 242
bytes of address/OR/AND mask field. For each element specified, the
processor reads a 16-bit word, ANDs it with the AND mask, ORs it with
the OR mask, and writes the result back into the location in the
processor memory.

An address/OR/AND mask field is an 11-byte value defined as:

System address

OR mask

AND mask

7

2

2

As an example, 06 FF 02 00 FF 03 00 00 00 00 00 clears (zeroes) the word
at element 3 in file 2.

Important: The controller may change the states of the original bits in
memory before this command can write the word back to memory.
Therefore, some data bits may unintentionally be overwritten. To help
prevent this, we suggest that you use this command to write into the
storage area of a programmable controller’s data table, and have the
controller read the word only, not control it.

Read-Modify-Write

Advertising