
Description of the DP Functions, Data, and Error Codes
DP Base Programming Interface for CP 5613/CP 5614
144
C79000-G8976-C108-01
4.3.1 Reading the Input Data of a DP Slave
Consistent Reading
There is a fixed data area in the process image of the CP 5613/CP 5614 for the
input data of each individual slave.
To allow the input data of a slave to be read consistently, your user program first
locks this data area to prevent it being updated by the DP master, then accesses
the area, and releases it again.
The program locks the area by writing the slave number to a control register in the
process image. The program releases the area by writing the value
DPR_DP_UNLOCK or a different slave number to the same register.
Example of Consistent Reading
"p" is a pointer to the process image that your user program obtained with the
"DP_get_pointer" call. Then 200 bytes of slave no. 5 are copied to a local buffer
"buf":
/* Lock the data area against updating */
p->ctr.D_lock_in_slave_adr = 5;
/* Copy data */
memcpy(buf, &p->pi.slave_in[5].data[0], 200);
/* Cancel lock again */
p->ctr.D_lock_in_slave_adr = DPR_DP_UNLOCK;
Comentarios a estos manuales