daves Posted June 4, 2014 Posted June 4, 2014 I was trying to use nice pointers directly: ptr R1CaptCtrl->u.io:$908068.6.4; // Gate3[2].Chan[0].CaptCtrl Is the following as expected? It doesn't explain this situation in the documentation that I can see, it only says you need to use the Gate structure in C code: This doesn't work: open plc 1 Sys.WpKey = $AAAAAAAA; R1CaptCtrl = 2; Sys.WpKey = $0; disable plc 1; close This DOES work: Gate3[2].WpKey = $AAAAAAAA; R1CaptCtrl = 3;
Sina.Sattari Posted June 4, 2014 Posted June 4, 2014 Daves, Let me explain this by giving a bit of a background: In C programs, it is code's/user's responsibility to set the Gate3.WpKey before writing to any protected registers or else the register stays unchanged. In PMAC Script the same can be done, but in order to make life easier for the users, Sys.WpKey was implemented. In PMAC Script before a write to a GSPGate3 protected register, the contents of Sys.WpKey is copied into corresponding Gate3.WpKey. This ensures that the write process is authorized by the DSPGate3. In your first example, the script doesn't know that you're writing to a DSPGate3 register since you're using a pointer and not a DSPGate3 structure. This means that the automatic write to Gate3.WpKey is not performed. In the second example, you're performing the same step that the firmware would have done, had it known the target is a protected register in a DSPGate3, and that's why it is working.
Recommended Posts