Other Parts Discussed in Thread: MOTORWARE, CONTROLSUITE
Hi,
I followed one recent post about eCAP here in INSTASPIN forum ("Help with eCAP INT?") and set up all files according with that post.
However for below function in hal.c I am not sure I call it properly in main():
void HAL_setupeCAP(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;
CAP_setModeCap(obj->capHandle); // set mode to CAP
CAP_clearInt(obj->capHandle,CAP_Int_Type_CEVT1); // clear the CEVT1 int
CAP_disableSyncIn(obj->capHandle);
CAP_setCapEvtPolarity(obj->capHandle,CAP_Event_1,CAP_Polarity_Rising);
CAP_setCapEvtPolarity(obj->capHandle,CAP_Event_2,CAP_Polarity_Falling);
CAP_setCapEvtPolarity(obj->capHandle,CAP_Event_3,CAP_Polarity_Rising);
CAP_setCapEvtPolarity(obj->capHandle,CAP_Event_4,CAP_Polarity_Falling);
CAP_setCapEvtReset(obj->capHandle,CAP_Event_1,CAP_Reset_Enable);
CAP_setCapEvtReset(obj->capHandle,CAP_Event_2,CAP_Reset_Enable);
CAP_setCapEvtReset(obj->capHandle,CAP_Event_3,CAP_Reset_Enable);
CAP_setCapEvtReset(obj->capHandle,CAP_Event_4,CAP_Reset_Enable);
CAP_setCapContinuous(obj->capHandle);
//CAP_setRunMode(obj->capHandle);
CAP_setStopWrap(obj->capHandle,CAP_Stop_Wrap_CEVT4);
CAP_enableCaptureLoad(obj->capHandle);
//CAP_enableInt(obj->capHandle,CAP_Int_Type_CEVT1);
CAP_enableInt(obj->capHandle,CAP_Int_Type_CEVT4);
CAP_enableTimestampCounter(obj->capHandle);
// enable eCAP interrupt
PIE_enableInt(obj->pieHandle, PIE_GroupNumber_4, PIE_InterruptSource_ECAP1);
CPU_enableInt(obj->cpuHandle, CPU_IntNumber_4);
return;
} // end of HAL_setupCAP() function
I used lab01a and latest motorware.
In main() I call the function with HAL_setupeCAP(halHandle);
Compilation is OK but in debug mode, in REGISTER window, under eCAP1, all registers (especially control registers) have value 0.
How to inform compiler that in HAL_setupeCAP(HAL_Handle handle), eCAP1 is the one I need registers to be set? ( In controlSuite is for example something like
ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1; // One-shot)
Regards,
Sergiu