Delta Tau Forums
RESOLVED - Calculating Register Pointer-Adresses - Printable Version

+- Delta Tau Forums (http://forums.deltatau.com)
+-- Forum: Delta Tau Data Systems (http://forums.deltatau.com/forumdisplay.php?fid=1)
+--- Forum: Power PMAC (http://forums.deltatau.com/forumdisplay.php?fid=2)
+--- Thread: RESOLVED - Calculating Register Pointer-Adresses (/showthread.php?tid=3235)



RESOLVED - Calculating Register Pointer-Adresses - hannsx - 06-02-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


RE: Calculating Register Pointer-Adresses - Eric Hotchkiss - 06-03-2021

If you want to use a direct pointer based on numerical addresses, it would look like this.
Code:
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.
Code:
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.