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.

AM2632: ECAP usage

Part Number: AM2632
Other Parts Discussed in Thread: LP-AM263, AM2634, SYSCONFIG

Tool/software:

Dear TI Technical Support Team,

I am encountering an issue with the ECAP module interrupt not triggering while working on the AM2632 chip nortos. I would greatly appreciate your help in analyzing the root cause.

Issue Description

  1. Hardware Environment

    • Chip Model: AM2632

    • Core: R5FSS1-0

    • ECAP Module: ECAP0

    • Pin Configuration: PRO_PRUO_GPIO9/F17 (routed to ECAP0 via INPUT XBAR and INT_XBAR_22)

    • Input Signal: 80kHz square wave/Manually switch between 3.3 and GND

  2. Observed Behavior

    • The input signal is confirmed present, but the ECAP interrupt service routine (ISR) is never invoked.

  3. Troubleshooting Steps Performed

    • Verified the input signal integrity with an oscilloscope.

    • Confirmed pin multiplexing configuration (PRO_PRUO_GPIO6 is set to ECAP input mode).

Key Configuration Details

  1. syscfg

2. code
Note: sdk version:mcu_plus_sdk_am263x_10_01_00_31
/******************************************************************************/
/*                                                                            */
/* Copyright (C) 2014 - 2022 RoboSense, Co., Ltd.  All rights reserved.       */
/*                                                                            */
/******************************************************************************/

/******************************************************************************/
/*                Include common and project definition header                */
/******************************************************************************/

/******************************************************************************/
/*                      Include headers of the component                      */
/******************************************************************************/
#include "EcapDrv.h"

#include "ti_drivers_config.h"
#include "ti_drivers_open_close.h"
#include "ti_board_open_close.h"
#include <drivers/ecap/v1/ecap.h>
/******************************************************************************/
/*                           Include other headers                            */
/******************************************************************************/

/******************************************************************************/
/*                   Definition of local symbolic constants                   */
/******************************************************************************/

/******************************************************************************/
/*                  Definition of local function like macros                  */
/******************************************************************************/


/******************************************************************************/
/*          Definition of local types (typedef, enum, struct, union)          */
/******************************************************************************/

/******************************************************************************/
/*                       Definition of local variables                        */
/******************************************************************************/


/******************************************************************************/
/*                     Definition of local constant data                      */
/******************************************************************************/
/* ECAP Interrupt Sources */
#define ECAP_INT_ALL                    ECAP_ISR_SOURCE_ALL

#define APP_INT_IS_PULSE  (1U)
/******************************************************************************/
/*                      Definition of exported variables                      */
/******************************************************************************/

uint32_t gEcapBaseAddr;// = CONFIG_ECAP0_BASE_ADDR;

/******************************************************************************/
/*                    Definition of exported constant data                    */
/******************************************************************************/

/******************************************************************************/
/*                  Declaration of local function prototypes                  */
/******************************************************************************/

/******************************************************************************/
/*                       Definition of local functions                        */
/******************************************************************************/

/******************************************************************************/
/*                      Definition of exported functions                      */
/******************************************************************************/

void EcapIntrCallback(void *args)
{
    uint32_t end = 0;
    // uint32_t begin = 0;

    volatile uint16_t status;

    status = ECAP_getInterruptSource(gEcapBaseAddr);
    if(status & ECAP_ISR_SOURCE_CAPTURE_EVENT_1)
    {
        end = ECAP_getEventTimeStamp(gEcapBaseAddr, ECAP_EVENT_1);
    }
    else if(status & ECAP_ISR_SOURCE_CAPTURE_EVENT_2)
    {
        end = ECAP_getEventTimeStamp(gEcapBaseAddr, ECAP_EVENT_2);
    }
    else if(status & ECAP_ISR_SOURCE_CAPTURE_EVENT_3)
    {
        end = ECAP_getEventTimeStamp(gEcapBaseAddr, ECAP_EVENT_3);
    }
    else if(status & ECAP_ISR_SOURCE_CAPTURE_EVENT_4)
    {
        end = ECAP_getEventTimeStamp(gEcapBaseAddr, ECAP_EVENT_4);
    }

    if(end > 0)
    {
        // begin++;
    }
    ECAP_clearInterrupt(gEcapBaseAddr, ECAP_INT_ALL);
    /*清除全局中断标志。*/
    ECAP_clearGlobalInterrupt(gEcapBaseAddr);

}

void Ecap_vidInit(void)
{
    // int32_t status;
    HwiP_Params hwiPrms;
    HwiP_Object  gEcapHwiObject;
    gEcapBaseAddr = CONFIG_ECAP0_PTP_BASE_ADDR;
    ECAP_stopCounter(gEcapBaseAddr);

    /* Register & enable interrupt */
    HwiP_Params_init(&hwiPrms);
    hwiPrms.intNum      = CSLR_R5FSS1_CORE0_CONTROLSS_INTRXBAR0_OUT_22;
    hwiPrms.callback    = &EcapIntrCallback;
    hwiPrms.isPulse     = APP_INT_IS_PULSE;
    // status              = HwiP_construct(&gEcapHwiObject, &hwiPrms);
    HwiP_construct(&gEcapHwiObject, &hwiPrms);

    // Starts Time stamp counter
    ECAP_startCounter(gEcapBaseAddr);
   /* Start/ ReArm  eCAP */
    ECAP_reArm(gEcapBaseAddr);

    /* Enables interrupt source for CONFIG_ECAP0 */
	ECAP_enableInterrupt(gEcapBaseAddr, (ECAP_ISR_SOURCE_CAPTURE_EVENT_1 |\
                                                  ECAP_ISR_SOURCE_CAPTURE_EVENT_2 |\
                                                  ECAP_ISR_SOURCE_CAPTURE_EVENT_3 |\
                                                  ECAP_ISR_SOURCE_CAPTURE_EVENT_4 ));
}


int main(void)
{
    /* init SOC specific modules */
    System_init();
    Board_init();
    /* Open drivers to open the UART driver for console */
    Drivers_open();
    Board_driversOpen();
    Ecap_vidInit();

    while(1)
    {

    }

    /* The following line should never be reached because vTaskStartScheduler()
    will only return if there was not enough FreeRTOS heap memory available to
    create the Idle and (if configured) Timer tasks.  Heap management, and
    techniques for trapping heap exhaustion, are described in the book text. */
    DebugP_assertNoLog(0);

    return 0;
}

Request for Guidance

  1. Is the routing configuration for INPUT XBAR and INT_XBAR_22 correct?

  2. Are there any critical settings missing in ECAP0 capture mode?

  3. Are there additional registers that require configuration?

Thank you for your support! Looking forward to your feedback.

Best regards,
zx

  • Hi zx,

    Apologies for the delay.

    I have assigned this query to SW Expert

    Best Regards,
    Rijohn

  • Hi zx,

    Thank you for the config and the code, do you mind sharing the ccs project as a zip as well? Will speed up my debug process!

    Regards,
    Akshit

  • Hi Akshit,

    The attachment is the project I debugged based on SDK sample。

    There are three phenomena that can be used as a reference for you now。

    1. If the input signal of ECAP is selected as UART1-RXD, it can capture and trigger interrupts normally,the response frequency of the interrupt is consistent with the frequency of the input signal

    2.  If the input signal of ECAP is selected as PRO_PRUO_GPIO6, the response frequency of the interrupt is much higher than the frequency of the input signal change, which looks like it is constantly triggering again

    3.  If the input signal of ECAP is selected as PRO_PRUO_GPIO0, the interrupt will only respond once

     ecap_capture_pwm_am263x-lp_r5fss0-0_nortos_ti-arm-clang(1).zip

    Regards,

    zx

  • Hi zx,

    Thank you for sharing the project, I have gone through it, xbar routing and interrupt configurations seem correct, and you have already confirmed input signal presence.

    I have also confirmed that this issue is reported on multiple boards.

    Just confirming, this project is the testcase where you are using PRU_PRU0_GPIO0?

    I'll try some configurations tomorrow and get back to you with a clearer answer.

    Thank you so much for your patience!

    If there are any other updates you have, or discoveries during your troubleshoot please let me know.

    Thanks and regards
    Akshit

  • Hi Akshit,

    Yes, this is my testing project using PRU_PRU0_GPIO0. My understanding is that different PRU_PRU0_GPIOX should have the same phenomenon when applied here, but the experimental results are not like this. My project actually applies PRU_PRU0_GPIO4, 6, and 9.

    I need your help to confirm if PRU_PRU0_GPIO can be used for ECAP input and what the correct configuration is.

    Why do different PRU_PRU0_GPIOs have different results?

    Additionally, I first tested on AM2632 but was unsuccessful, and then switched to a launchpad kit LP-AM263 to verify this feature. The zip I provided you with was tested on LP-AM263, with the chip being AM2634. Our project actually uses AM2632

    Looking forward to your reply

    Thanks

    zx

  • Hi zx

    I am able to reproduce all your issues.

    1.  I ran into issues with your project, so I decided to use the default epwm_capture_pwm.c.
    2.  I tried 4 different scenarios:

      1. Default example: ran fine
      2. Changed the input to be taken from PRU_PRU0_GPIO0, exact same program just change Output from INPUTXBAR to GPIO93(which is corresponding to PRU0_GPIO0, confirmed all HwIP and pinmux settings, also input on the pin, everything was correct and the ISR didn't trigger, stuck on Semaphore_pend()
      3. Tried the exact same case as above, using PRU_PRU0_GPIO6, and ran into the exact same issue.
      4. Then tried using SPI1_CS0 pin, with the exact same configurations and connections, and the program executed perfectly again.

    With all these tests and deductions on a default working example, it seems like there is some issue with using ICSSGPIO pins as input for ECAP. 

    I am now in discussion with the Hardware team to root cause this issue.

    Thank you so much for your patience and pointing this out, I'll get back to you ASAP.

    Regards,
    Akshit

  • Hi zx

    We have been able to successfully debug this issue.

    It is being caused due to internal mux settings that need to be done to use these pins as GPIO instead of ICSSGPIO.

    From the schematic we can see that:

    • AM263_PRU_MUX_SEL_GPIO64 needs to be pulled high for PATH A <-> C (which is what we need)
    • AM263_MUX_EN_GPIO58 needs to be pulled high to enable this U23 mux

    to do these changes through sysconfig, we just added two more gpio configs

    for the above two switches respectively.

    This changed enabled those pins to be used as GPIO, and the program ran correctly.

    Please try these changes and let me know if your issue is resolved. For Control Card as well, some mux changes(maybe different) will be needed to be done, which can be found in a similar way through schematics.

    I am sharing my project for your perusal!

    ecap_capture_pwm_am263x-lp_r5fss0-0_nortos_ti-arm-clang.zip

    Thanks and regards
    Akshit