Hi Florian,
If you look at the asyn/devEpics/devAsynUInt32Sigital.c device support you will see that for mbbi, mbbo, mbbiDirect and mbboDirect records the SHFT field is computed by the computeShift function in the record initialization function.
This is the computeShift function:
static int computeShift(epicsUInt32 mask)
{
epicsUInt32 bit=1;
int i;
for(i=0; i<32; i++, bit <<= 1 ) {
if(mask&bit) break;
}
return i;
}
So it sets SHFT to the first non-zero bit in the mask.
You have set the mask to 0x1f3c, which is 0001 1111 0011 1100 in binary. The first non-zero bit is bit 2 (starting from 0) so SHFT is set to 2.
So I think you need to use B0 and B1 for your switches, because the mask says that the mbboDirect value starts at bit 2, not bit 0 in the hardware register.
Mark
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Florian Feldbauer
Sent: Tuesday, July 16, 2013 10:15 AM
To: EPICS Tech Talk
Subject: mbbxDirect SHFT field
Hey all,
for the settings of the stop switch mode of a motor driver, we are
using, a 16 bit code is used.
Bit 2 and Bit 3 are coding the polarity of the "left" and "right" stop
switch, respectively.
I'm currently using bo records for each bit and one mbboDirect record to
send all 16 bits at once to the device. As device support the
asynUInt32Digital interface is used with a custom asynPortDriver:
record( mbboDirect, "PANDA:$(subsys):MOTOR:$(sector):SAP:SWITCHMODE" ) {
field( DTYP, "asynUInt32Digital" )
field( OUT, "@asynMask($(BUS),14,0x1f3c,1)TMCM142_SAP_U" )
}
record( bo, "PANDA:$(subsys):MOTOR:$(sector):SAP:LEFTSWITCHPOLARITY" ) {
field( OUT, "PANDA:$(subsys):MOTOR:$(sector):SAP:SWITCHMODE.B2 NPP" )
field( ONAM, "active high" )
field( ZNAM, "active low" )
}
record( bo, "PANDA:$(subsys):MOTOR:$(sector):SAP:RIGHTSWITCHPOLARITY" ) {
field( OUT, "PANDA:$(subsys):MOTOR:$(sector):SAP:SWITCHMODE.B3 NPP" )
field( ONAM, "active high" )
field( ZNAM, "active low" )
}
When I now set "PANDA:$(subsys):MOTOR:$(sector):SAP:RIGHTSWITCHPOLARITY"
to one,
PANDA:$(subsys):MOTOR:$(sector):SAP:SWITCHMODE.VAL is 8.
So far so good.
But the value in asynPortDriver::writeUInt32Digital is 0x20.
Having a closer look to the mbboDirect record shows that SHFT is 2.
Setting it to 0 inside the db-file has no effect.
Any idea why it is set to 2? How can I change this behavior?
The same problem occurs for the mbbiDirect record used to read back the
settings.
Best regards,
Florian