TI中文支持网
TI专业的中文技术问题咨询交流网站

能不能解释一下HAL_setupFaults函数的用途

请问大侠,能不能解释一下HAL_setupFaults函数的用途。
我用的平台是C2000Ware_MotorControl_SDK_3_00_01_00,芯片是F280049C,控制单马达。

现在在我这里HAL_setupFaults需要直接返回,这样电机可以运行,运行参数正常。

如果HAL_setupFaults不直接返回,而是运行里里面内容,那么运行程序时电机不转,也不拉电流,也没有出错。

void HAL_setupFaults(HAL_Handle handle)
{
    HAL_Obj *obj = (HAL_Obj *)handle;
    uint16_t cnt;
//    return;

    // Configure Trip Mechanism(ÌøÕ¢»úÖÆ) for the Motor control software
    // -Cycle by cycle trip on CPU halt
    // -One shot fault trip zone
    // These trips need to be repeated for EPWM1 ,2 & 3

    // configure the input x bar for TZ2 to GPIO, where Over Current is connected
//    XBAR_setInputPin(XBAR_INPUT2, HAL_PM_nFAULT_GPIO);
//    XBAR_lockInput(XBAR_INPUT2);

    for(cnt=0;cnt<3;cnt++)
    {
        EPWM_enableTripZoneSignals(obj->pwmHandle[cnt],
                                   EPWM_TZ_SIGNAL_CBC6);

        EPWM_enableTripZoneSignals(obj->pwmHandle[cnt],
                                   EPWM_TZ_SIGNAL_OSHT2);

        //enable DC TRIP combinational input
        EPWM_enableDigitalCompareTripCombinationInput(obj->pwmHandle[cnt],
               (EPWM_DC_COMBINATIONAL_TRIPIN7 |
                EPWM_DC_COMBINATIONAL_TRIPIN8 |
                EPWM_DC_COMBINATIONAL_TRIPIN9),
                EPWM_DC_TYPE_DCAH);
        EPWM_enableDigitalCompareTripCombinationInput(obj->pwmHandle[cnt],
               (EPWM_DC_COMBINATIONAL_TRIPIN7 |
                EPWM_DC_COMBINATIONAL_TRIPIN8 |
                EPWM_DC_COMBINATIONAL_TRIPIN9),
                EPWM_DC_TYPE_DCAL);
        EPWM_enableDigitalCompareTripCombinationInput(obj->pwmHandle[cnt],
               (EPWM_DC_COMBINATIONAL_TRIPIN7 |
                EPWM_DC_COMBINATIONAL_TRIPIN8 |
                EPWM_DC_COMBINATIONAL_TRIPIN9),
               EPWM_DC_TYPE_DCBH);
        EPWM_enableDigitalCompareTripCombinationInput(obj->pwmHandle[cnt],
               (EPWM_DC_COMBINATIONAL_TRIPIN7 |
                EPWM_DC_COMBINATIONAL_TRIPIN8 |
                EPWM_DC_COMBINATIONAL_TRIPIN9),
               EPWM_DC_TYPE_DCBL);

        // Trigger event when DCAH is High
        EPWM_setTripZoneDigitalCompareEventCondition(obj->pwmHandle[cnt],
                                                     EPWM_TZ_DC_OUTPUT_A1,
                                                     EPWM_TZ_EVENT_DCXH_HIGH);

        // Trigger event when DCBH is High
        EPWM_setTripZoneDigitalCompareEventCondition(obj->pwmHandle[cnt],
                                                     EPWM_TZ_DC_OUTPUT_B1,
                                                     EPWM_TZ_EVENT_DCXL_HIGH);

        // Enable DCA as OST
        EPWM_enableTripZoneSignals(obj->pwmHandle[cnt], EPWM_TZ_SIGNAL_DCAEVT1);

        // Enable DCB as OST
        EPWM_enableTripZoneSignals(obj->pwmHandle[cnt], EPWM_TZ_SIGNAL_DCBEVT1);

        // Configure the DCA path to be un-filtered and asynchronous
        EPWM_setDigitalCompareEventSource(obj->pwmHandle[cnt],
                                          EPWM_DC_MODULE_A,
                                          EPWM_DC_EVENT_1,
                                          EPWM_DC_EVENT_SOURCE_FILT_SIGNAL);

        // Configure the DCB path to be un-filtered and asynchronous
        EPWM_setDigitalCompareEventSource(obj->pwmHandle[cnt],
                                          EPWM_DC_MODULE_B,
                                          EPWM_DC_EVENT_1,
                                          EPWM_DC_EVENT_SOURCE_FILT_SIGNAL);

        // What do we want the OST/CBC events to do?
        // TZA events can force EPWMxA
        // TZB events can force EPWMxB
        EPWM_setTripZoneAction(obj->pwmHandle[cnt],
                               EPWM_TZ_ACTION_EVENT_TZA,
                               EPWM_TZ_ACTION_LOW);
        EPWM_setTripZoneAction(obj->pwmHandle[cnt],
                               EPWM_TZ_ACTION_EVENT_TZB,
                               EPWM_TZ_ACTION_LOW);

        // Clear any spurious fault
        EPWM_clearTripZoneFlag(obj->pwmHandle[cnt],
                                        HAL_TZ_INTERRUPT_ALL);
    }

    return;
} // end of HAL_setupFaults() function

Susan Yang:

jiaren lu如果HAL_setupFaults不直接返回,而是运行里里面内容,那么运行程序时电机不转,也不拉电流,也没有出错。

请问您是否进入该函数并单步调试?

另外您现在使用的硬件以及软件是什么?能否请您详细描述一下?

赞(0)
未经允许不得转载:TI中文支持网 » 能不能解释一下HAL_setupFaults函数的用途
分享到: 更多 (0)