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.

AM2434: ECAP - time latch problem

Part Number: AM2434

Tool/software:

Hi,

I'm trying to use ECAP (peripheral #1, not #0) on my board & project.

Unlike the sdk example project - I do not use the ISR function.

I tried to make some sanity testing and I'm getting odd results unlike your example output.

I've configured pin C17(MCAN1_TX)  to mode 2 - APWM_ECAP1.

I'm using a signal generator to produce a 1kHz Square Pulse at both 50% and 25% Duty Cycle (2 different test cases).

This is my configuration code:

    /* 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);

    /* One shot mode, stop capture at event 4 */
    ECAP_oneShotModeConfig(gEcapBaseAddr, ECAP_CAPTURE_EVENT4_STOP);
//    ECAP_continuousModeConfig(gEcapBaseAddr);

    /* Set polarity of the events to rising, falling, rising, falling 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_RESET,
                                 ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET,
                                 ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET,
                                ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET);

    ECAP_counterControl(gEcapBaseAddr, ECAP_COUNTER_FREE_RUNNING);
    ECAP_syncInOutSelect(gEcapBaseAddr, ECAP_ENABLE_COUNTER, ECAP_SYNC_IN);

    /* Enable eCAP module */
    ECAP_captureLoadingEnable(gEcapBaseAddr);


However - I'm not getting the right results when using:

        ECAP_oneShotReArm(gEcapBaseAddr);

####   Assume there is a delay here for the registers to load ###


        /* Read Counter values and print for last iteration. */
        cap1Count = ECAP_timeStampRead(gEcapBaseAddr, ECAP_CAPTURE_EVENT_1);
        cap2Count = ECAP_timeStampRead(gEcapBaseAddr, ECAP_CAPTURE_EVENT_2);
        cap3Count = ECAP_timeStampRead(gEcapBaseAddr, ECAP_CAPTURE_EVENT_3);
        cap4Count = ECAP_timeStampRead(gEcapBaseAddr, ECAP_CAPTURE_EVENT_4);

cap1Count sometimes shows unreasonable values like 200,000,000.

Also I would expect the values of the rising edges/falling edges would be equal in case of 50% PWM - which they aren't,

In the case of 25% - there is no data consistency much like in the 50% DC case.

Also note -> pin D18 for APWM_ECAP0 is used for the Sigma Delta clock.

Thanks in advance

  • Hello Aeriel Ronen,

    I have looked at the code and this code seems OK .

    I suspect you are not getting proper results because of the below possible cases ..

    Check the driving   1KhZ signal  in CRO and confirm this signal is properly driving 1KHz with proper voltage  levels .

    And, I am not sure how you are calculating the frequency and duty after getting count values .

    After count values, users need to divide the ECAP clock frequency, which is 125MHz, and if you  are missing this clock divide  operation and do calculate the fre and duty with the ECAP frequency.

    One more thing is that, if you are not using an interrupt, then if you are going in one short mode, the signal is captured for 4 samples. After that, again the feeding input does not create start of the counter ...

    So, for every new feed signal and after the sample is collected, then again you need to start one short mode, else the counter does not give any results.

    How can I reproduce the issue on my side, if the above suggestion does not work for you ?

    Regards,

    Anil.