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.

AM2432: AM2432: Ecap only enter an interrupt once

Part Number: AM2432

Tool/software:

Hi TI

We used Ecap to capture the encoder signal, but testing found that it would only enter an interrupt once, here is my configuration and interrupt function:

/* ECAP Interrupt Sources */
#define ECAP_INT_ALL                    (ECAP_CEVT1_INT  | \
                                         ECAP_CEVT2_INT  | \
                                         ECAP_CEVT3_INT  | \
                                         ECAP_CEVT4_INT  | \
                                         ECAP_CNTOVF_INT | \
                                         ECAP_PRDEQ_INT  | \
                                         ECAP_CMPEQ_INT)

uint32_t gEcapBaseAddr = CONFIG_ECAP0_BASE_ADDR;
static HwiP_Object gEcapHwiObject;

void hal_ecap_it_cb(void *args)
{
    uint32_t fall = 0;
    uint32_t rise = 0;

    ECAP_intrStatusClear(gEcapBaseAddr, ECAP_INT_ALL);

    fall = ECAP_timeStampRead(gEcapBaseAddr, ECAP_CAPTURE_EVENT_2);
    rise = ECAP_timeStampRead(gEcapBaseAddr, ECAP_CAPTURE_EVENT_1);
    /* todo */
}

int32_t hal_ecap_init(void)
{
    HwiP_Params hwiPrms;

    /* Disable and Clear Interrupts */
    ECAP_intrDisable(gEcapBaseAddr, ECAP_INT_ALL);
    ECAP_intrStatusClear(gEcapBaseAddr, ECAP_INT_ALL);
    /* Disable CAP1-CAP4 register loads */
    ECAP_captureLoadingDisable(gEcapBaseAddr);
    /* Configure eCAP */
    ECAP_counterControl(gEcapBaseAddr, ECAP_COUNTER_STOP);

    /* Enable capture mode */
    ECAP_operatingModeSelect(gEcapBaseAddr, ECAP_CAPTURE_MODE);

    ECAP_continuousModeConfig(gEcapBaseAddr);

    ECAP_counterConfig(gEcapBaseAddr, 0);

    /* Set polarity of the events to falling, rising, falling, rising edge */
    ECAP_captureEvtPolarityConfig(gEcapBaseAddr,
                                  ECAP_CAPTURE_EVENT_RISING,
                                  ECAP_CAPTURE_EVENT_FALLING,
                                  ECAP_CAPTURE_EVENT_RISING,
                                  ECAP_CAPTURE_EVENT_FALLING);

    /* Set capture in time difference mode */
    ECAP_captureEvtCntrRstConfig(gEcapBaseAddr,
                                 ECAP_CAPTURE_EVENT_RESET_COUNTER_NO_RESET,
                                 ECAP_CAPTURE_EVENT_RESET_COUNTER_NO_RESET,
                                 ECAP_CAPTURE_EVENT_RESET_COUNTER_NO_RESET,
                                 ECAP_CAPTURE_EVENT_RESET_COUNTER_NO_RESET);

    ECAP_syncInOutSelect(gEcapBaseAddr, ECAP_SYNC_IN_DISABLE, ECAP_SYNC_OUT_DISABLE);

    /* Register & enable ICSSG EnDat PRU FW interrupt */
    HwiP_Params_init(&hwiPrms);
    hwiPrms.intNum      = CONFIG_ECAP0_INTR;
    hwiPrms.callback    = hal_ecap_it_cb;
    hwiPrms.args        = 0;
    hwiPrms.isPulse     = CONFIG_ECAP0_INTR_IS_PULSE;
    hwiPrms.isFIQ       = FALSE;
    HwiP_construct(&gEcapHwiObject, &hwiPrms);

    ECAP_prescaleConfig(gEcapBaseAddr, 0);
    ECAP_counterControl(gEcapBaseAddr, ECAP_COUNTER_FREE_RUNNING);
    /* Enable eCAP module */
    ECAP_captureLoadingEnable(gEcapBaseAddr);
    /* Enable interrupt */
    ECAP_intrEnable(gEcapBaseAddr, ECAP_CEVT2_INT);

    return 0;
}

  • Hi, our expert is currently out of office, please allow him few days to come back to you. Please ping this thread by Friday if you haven't gotten a reply.

    In the meantime, few things you can check (if you haven't).

    - Is interrupt clear?

    /* Clear Ecap Interrupt. */
    ECAP_intrStatusClear(gEcapBaseAddr, ECAP_INT_ALL);
    /* Clear Global Interrupt Flag. */
    ECAP_globalIntrClear(gEcapBaseAddr);
    SemaphoreP_post(&gEcapSyncSemObject);

    - Can you run MCU+SDK ECAP out box examples?

    AM243x MCU+ SDK: ECAP APWM mode (ti.com)

    thank you,

    Paula

  • Run the out box examples through, but the out box examples is also a single-trigger interrupt, so I can't verify a continuous trigger.

    thank you.

  • Dear Walker.

    I think you need clear Global interrupt flag like the example in the SDK.

    C:\ti\mcu_plus_sdk_am243x_09_02_01_05\examples\drivers\ecap\ecap_epwm_loopback\ecap_epwm_loopback.c

    static void App_ecapIntrISR(void *arg)
    {
    /* Clear Ecap Interrupt. */
    ECAP_intrStatusClear(gEcapBaseAddr, ECAP_INT_ALL);
    /* Clear Global Interrupt Flag. */
    ECAP_globalIntrClear(gEcapBaseAddr);

    SemaphoreP_post(&gEcapSyncSemObject);
    }

    and as you mentioned before, you are trying the case in chapter12.4.2.5.3 of TRM.

    12.4.2.5.3 Time Difference (Delta) Operation Rising Edge Trigger Example

    please also check below suggestions.

    1. need set CTRRSTx bit to 1.

    /* Set capture in time difference mode */
    ECAP_captureEvtCntrRstConfig(gEcapBaseAddr,
    ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET,
    ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET,
    ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET,
    ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET);

    2. the cycle is CEVT1~CETV4, 

        ECAP_intrEnable(gEcapBaseAddr, ECAP_CEVT4_INT);

    Thanks a lot!

    yong

  • Dear Walker.

    may I ask if you have fixed the issue?

    please help provide the update.

    thanks a lot!

    yong

  • Sorry, forgot to reply. Yes, the last reply has solved my problem, thank you very much.