hannsx Posted June 2, 2021 Share Posted June 2, 2021 Hi, I wanted to ask how you calculate the Adress for the Gate3[0].HomeCapt[1] Register. My Problem ist that I just do not seem to get it right when I use it in the Interrupt Service Routine. Here is how I calculate it: int Gate3ZeroAdress; int *G3ZhomeCapt ; Gate3ZeroAdress = pshm -> OffsetGate3[0] ; G3ZhomeCapt = (int*)piom + ((Gate3ZeroAdress + 0x80 + 0x74) >> 2) ; 0x80 Is the Offset for Chan[1] 0x74 Is the Offset for HomeCapt The use of the Gate-Array structure volatile GateArray3 *MyFirstGate3IC; MyFirstGate3IC = GetGate3MemPtr(0); and consequently MyFirstGate3IC -> Chan[1].HomeCapt in the Interrupt Servo Routine clears the register and rearms it for the next Interrupt when I read that Register out. When I read out G3ZhomeCapt it does not rearm clear the register or rearms it. Can someone tell me why G3ZhomeCapt != MyFirstGate3IC ->Chan[1].HomeCapt ? Best regards, hannsx Link to comment Share on other sites More sharing options...
Eric Hotchkiss Posted June 3, 2021 Share Posted June 3, 2021 If you want to use a direct pointer based on numerical addresses, it would look like this. volatile unsigned int *MyHomeCapt1; MyHomeCapt1 = (unsigned int *)piom + pshm->OffsetGate3[0]/4 + 0x80/4 + 0x74/4; It would be much easier to use gate pointers like below, however they will use more memory. I would recommend this method if possible. volatile GateIOStruct *GateIo[1]; GateIo[0] = GetGateIOMemPtr(0); GateIo[0] -> DataReg[3] = (0xFF << 8); I am attaching a couple short sections about these pointer types.direct pointers.pdfgate pointers.pdf Link to comment Share on other sites More sharing options...
Recommended Posts