This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-F28069M: Ecap 3 capture doesn't work

Part Number: LAUNCHXL-F28069M
Other Parts Discussed in Thread: TIDA-00643

Hello,

I'm looking for into a esc with  LAUNCHXL-F28069M + DRV830.

I found a way to do it with the reference design TIDA-00643 where it's indicated a lot of modification to have an eCAP Speed Reference Receiver.

Regarding to the LAUNCHXL-F28069M, I chose the GPIO26 (Ecap3) .I have added the following modifications to activate the ecap, but the interuption function was never called.

I double check the register in debug mode, the ecap3 clock is enable.

What changes need to be made?

Thanks

Source code:

/************************Hal.c*****************************/

  // initialize the eCAP
  obj->capHandle = CAP_init((void *)CAP3_BASE_ADDR,sizeof(CAP_Obj));

.....

// ECAP
void HAL_setupeCAP(HAL_Handle handle)
{
    HAL_Obj *obj = (HAL_Obj *) handle;


    CAP_setModeCap(obj->capHandle); // set mode to CAP

    //Disables counter synchronization
    CAP_disableSyncIn(obj->capHandle);

    //Sets the capture event polarity
    CAP_setCapEvtPolarity(obj->capHandle, CAP_Event_1, CAP_Polarity_Rising);

    //Sets the capture event polarity
    CAP_setCapEvtPolarity(obj->capHandle, CAP_Event_2, CAP_Polarity_Falling);

    //Sets the capture event counter reset configuration
    CAP_setCapEvtReset(obj->capHandle, CAP_Event_1, CAP_Reset_Disable);

    //Sets the capture event counter reset configuration (reset counting here)
    CAP_setCapEvtReset(obj->capHandle, CAP_Event_2, CAP_Reset_Enable);

    // continous timer
    CAP_setCapContinuous(obj->capHandle);

    //Set the stop/wrap mode to 2 events
    CAP_setStopWrap(obj->capHandle, CAP_Stop_Wrap_CEVT2);
    //Enables loading of CAP1-4 on capture event

    CAP_enableCaptureLoad(obj->capHandle);
    // Enables Time Stamp counter to running

    CAP_enableTimestampCounter(obj->capHandle);
    //Enables capture (CAP) interrupt source

    CAP_enableInt(obj->capHandle, CAP_Int_Type_CEVT2);
    // enable eCAP interrupt

    PIE_enableInt(obj->pieHandle, PIE_GroupNumber_4, PIE_InterruptSource_ECAP3);
    // enable CPU ECAP Group interrupts

    CPU_enableInt(obj->cpuHandle, CPU_IntNumber_4);

    return;
} // end of HAL_setupCAP() function

..............

 CLK_enableEcap2Clock(obj->clkHandle);

/**** Hal.h ***/

// ECAP
extern interrupt void ecapISR(void);

....

  ENABLE_PROTECTED_REGISTER_WRITE_MODE;

  pie->ADCINT1 = &mainISR;

  // ECAP
  pie->ECAP3_INT = &ecapISR;

  DISABLE_PROTECTED_REGISTER_WRITE_MODE;

/*** main.c ***/

long test_ecap = 0;
__interrupt void ecapISR(void)
{
    // Clear capture (CAP) interrupt flags
    CAP_clearInt(halHandle->capHandle, CAP_Int_Type_All);

    test_ecap++;

    // Compute the PWM high period (rising edge to falling edge)
    uint32_t PwmDuty = (uint32_t) CAP_getCap2(halHandle->capHandle) - (uint32_t)
    CAP_getCap1(halHandle->capHandle);
    // Assign the appropriate speed command, combine 0-5% and 95-100%
    // 0-100% speed is proportional to 1-2ms high period
    // 80MHz * 2ms = 160000

    // 0-1%
    if (PwmDuty <= 81333) // 61000
    {
        gSpeedRef_Ok = 0;
        gSpeedRef_duty = _IQ(0);
        //gMotorVars.Flag_Run_Identify = 0;
    }
    // 1-99%
    if ((PwmDuty > 81333 ) && (PwmDuty < 158666)) // 61000 & 119000
    {
        gSpeedRef_Ok = 0;
        gSpeedRef_duty = _IQdiv(PwmDuty - 80000, 80000);
        //gMotorVars.Flag_Run_Identify = 1;
    }
    // 99-100%
    else if (PwmDuty >= 158666) // 119000
    {
        gSpeedRef_Ok = 0;
        gSpeedRef_duty = _IQ(1.0);
        //gMotorVars.Flag_Run_Identify = 1;
    }
    // Catch all
    else
    {
        gSpeedRef_duty = _IQ(0);
        gMotorVars.Flag_Run_Identify = 0;
    }
    // Clears an interrupt defined by group number
    PIE_clearInt(halHandle->pieHandle, PIE_GroupNumber_4);
} // end of ecapISR() function