04-10-2013, 05:02 PM
(This post was last modified: 04-10-2013, 05:14 PM by tweekzilla.)
I've taken the example of the Capture Interrupt Routine from the manual in order to try and capture the encoder count on a channel that is being used as the external time-base. The idea is to latch the encoder count on an accurate tick. I'm using the USER flag input on Chan[2] of an ACC24E3[1].
I have tested that the external time-base and triggering work as expected - the problem is that whenever I enable the ISR and send the tick the PMAC CPU locks up.
The code is shown below and is almost the same as the manual. I also set Acc24E3[1].IntCtrl = $40000 //Chan[2].PosCapt
Note that I am setting the tick by a simple switch that is pressed - I mention this incase there is a bounce issue.
I have tested that the external time-base and triggering work as expected - the problem is that whenever I enable the ISR and send the tick the PMAC CPU locks up.
The code is shown below and is almost the same as the manual. I also set Acc24E3[1].IntCtrl = $40000 //Chan[2].PosCapt
Code:
void CaptCompISR (void)
{
volatile GateArray3 *TickGate3IC; //ASIC structure pointer
int *CaptCounter; //Logs number of ticks
int *CaptPosStore; //Storage pointer
TickGate3IC = GetGate3MemPtr(1); //Pointer to IC base
CaptCounter = (int *)pushm + 65535; // Sys.Idata[65535]
CaptPosStore = (int *)pushm + *CaptCounter + 65536;
*CaptPosStore = TickGate3IC->Chan[2].HomeCapt; //Store position
(*CaptCounter)++; //Increment Counter
TickGate3IC->IntCtrl = 0x04; //Clear interrupt
}
Note that I am setting the tick by a simple switch that is pressed - I mention this incase there is a bounce issue.