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.

TDA4VM: Routing eCap interrupt via the interrupt router

Part Number: TDA4VM

Hi, TI

I'd like to implemet eCAP interrupt handler using the Router on mcu3_0.

We want to run a handler with the ecap0 interrupt.
Can I use router "Sclient_rm.c"?
If that's true, how do I use it? 
please tell me how to use it and please give me a code example

  • Hi.

    i know the FAQ, So, I implemented an ecap handler using that question as a reference, but an error occurred.

    The error occurred in the CSL_PASS condition.

    1. Why did an error occur? 

    Also I have a technical reference manual called "spruill 1c.pdf". 

    As shown in the red circle below, ecap0's dst input index is 315~317, but the index of the FAQ link is 316~318.

    2. Which of the two is correct?

  • Hi,

    The index mentioned in the FAQ is correct. 
    Please find the same in the TRM as shown below 

    Regards,

    Nikhil

  • thank you.

    I confirm that my TRM is the same.

    so, i have try the dst_id, 316. but, The error still occurs.

    is there anything else needs to modified?

  • Hi

    The dst_host_irq is not the input to the router but the input to the R5F core. So this has to be a free IRQ in the system. The ID 316 is set by the src_id using the TISCI_DEV_ECAP0.

    Please refer the TISCI user guide for the Interrupt routers inputs and possible outputs.

    For MCU3_0 you need to do the below

    1. Set the src_id as TISCI_DEV_ECAP0, this is the peripheral you need to route the IRQ from.

    2. Set the src_index based on which interrupts from the peripheral you need to route.

    3. Set dst_id as the device ID for the core you need to route the IRQ to. This is incorrect in your code, this needs to be TISCI_DEV_R5FSS1_CORE0.

    4. Identify a free MCU3_0 IRQ line in the system. This is an interrupt number which is not registered on the MCU3_0. This becomes your dst_host_irq.

    5. Use the Sciclient_rmIrqSet() to tie the path from interrupt router input (316) to interrupt routers output (dst_host_irq). Use the table here to get the list of all outputs from the R5FSS1_INTROUTER0.

    5. Register the interrupt corresponding to dst_host_irq on the MCU3_0.

    Regards

    Karan

  • Hi, Karan

    Thank you. That's what I wanted.

    I have one more question.

        4. Identify a free MCU3_0 IRQ line in the system. This is an interrupt number which is not registered on the MCU3_0. This becomes your dst_host_irq.

    What does this mean?

    I have never registered an irq. I need to your guide. also, can I get the guide document? 

  • Hi

    A free IRQ is an interrupt number on the MCU3_0 which is not registered.

    If you see here in the R5FSS1_INTROUTER0 outputs you will see that all 0:255 outputs of the R5FSS1_INTROUTER0 are connected to to MCU3_0 and MCU3_1 at inputs 256:511. You can choose any of the numbers between 256:511 assuming these are not already registers with the core.

    I have never registered an irq. I need to your guide. also, can I get the guide document? 

    Once you have run the Sciclient_rmIrqSet() and that returned success, then you can use the OSAL API Osal_RegisterInterrupt().

    Please refer the example in mcusw/mcal_drv/mcal/examples/Can/soc/j721e/mcu1_0/CanApp_Startup.c

    Regards

    Karan

  • Hi, Karan.

    I got success with your guide.

    thank you.

    So I set a ecap callback function using the OSAL API Osal_RegisterInterrupt().

    But the callback function doesn't work.(ecap_cnt doesn't increase)

    * The Osal_ClearInterrupt() add for interrept initialize.

     

  • Hi

    Are there no errors from the Sciclient_rmIrqSet() or the Oal_RegisterInterrupt()?

    Also, how are you generating the interrupt?

    Regards

    Karan

  • Yes, there was no error.

    I set the ecap interrupt register.
    And I confirmed that ecap4's interrupt status register had changed.
    The fan's tachometer is connected to this ecap.

  • Are your interrupts enabled? What is the value of ECAP_ECINT_EN_FLG register?

    Regards

    Karan

  • Hi,

    I have enabled all ecap event interrupts.

    The ECAP_ECINT_EN_FLG is "0x1FFE"

  • Hi

    Let me try to get some additional details on this. I will get back with more information.

    Regards

    Karan

  • Hi Karan.

    Thank you for your support.
    Please reply as soon as possible.

  • hi,

    I share some of our code.

    We impleamented in "vision_apps".

    volatile static uint32_t ecap_cnt = 0;
    
    static void ecap_call_back(uintptr_t arg){
        ecap_cnt++;
        uint16_t eceflg = HW_RD_REG16(ecap_baseAddr[0] + ECAP_ECFLG);
        // appLogPrintf("ECAP_ECFLG | 0x02%x \n", eceflg);
        ECAPIntStatusClear(ecap_baseAddr[0], ECAP_INT_ALL);
    }
    
    void eCAP_IntrConfig(void)
    {
        Int32 retVal = 0;
        uint16_t intNum;
        uint16_t interruptOffset;
        struct tisci_msg_rm_irq_set_req  rmIrqReq = {0};
        struct tisci_msg_rm_irq_set_resp rmIrqResp = {0};
        /* Enable interrupt router settings to connect interrupt event */
        struct tisci_msg_rm_get_resource_range_resp res = {0};
        struct tisci_msg_rm_get_resource_range_req  req = {0};
        uint16_t intStartNum, intRangeNum;
        OsalRegisterIntrParams_t    intrPrms;
        OsalInterruptRetCode_e      osalRetVal;
        HwiP_Handle hwiHandle;
    
    #define SELF_DEVICE_ID TISCI_DEV_R5FSS1_CORE0
        req.type           = TISCI_DEV_R5FSS1_INTROUTER0;
        req.secondary_host = TISCI_MSG_VALUE_RM_UNUSED_SECONDARY_HOST;
    
        /* Get interrupt number range */
        retVal =  Sciclient_rmGetResourceRange(
                  &req,
                  &res,
                  SCICLIENT_SERVICE_WAIT_FOREVER);
        if (CSL_PASS != retVal || res.range_num == 0)
        {
            /* Try with HOST_ID_ALL */
            req.secondary_host = TISCI_HOST_ID_ALL;
    
            retVal = Sciclient_rmGetResourceRange(
                     &req,
                     &res,
                     SCICLIENT_SERVICE_WAIT_FOREVER);
        }
        if (CSL_PASS == retVal)
        {
            intRangeNum = res.range_num;
            if (intRangeNum == 0)
            {
                retVal = -2;
            }
        }
    
        if (CSL_PASS == retVal)
        {
            /* Translation must happen after this offset */
            retVal = Sciclient_rmIrqTranslateIrOutput(req.type,
                                                      res.range_start,
                                                      SELF_DEVICE_ID,
                                                      &intStartNum);
            if(CSL_PASS != retVal)
            {
                retVal = -3;
            }
        }
    
        if (retVal == 0)
        {
            rmIrqReq.dst_id         = TISCI_DEV_R5FSS1_CORE0;
            rmIrqReq.secondary_host = TISCI_MSG_VALUE_RM_UNUSED_SECONDARY_HOST;
    
            interruptOffset = 0;
    
            intNum = intStartNum + interruptOffset;
            appLogPrintf("intNum : %d \n", intNum);
            if (retVal == 0)
            {
                appLogPrintf("Sciclient_rmIrqSet ............... \n");
                /* Set the destination interrupt */
                rmIrqReq.valid_params           = TISCI_MSG_VALUE_RM_DST_ID_VALID;
                rmIrqReq.valid_params          |= TISCI_MSG_VALUE_RM_DST_HOST_IRQ_VALID;
                rmIrqReq.src_id                 = TISCI_DEV_ECAP0;
                rmIrqReq.global_event           = 0U;
                rmIrqReq.src_index              = 0U;
                rmIrqReq.dst_id                 = TISCI_DEV_R5FSS1_CORE0;
                rmIrqReq.dst_host_irq           = intNum;
                rmIrqReq.ia_id                  = 0U;
                rmIrqReq.vint                   = 0U;
                rmIrqReq.vint_status_bit_index  = 0U;
                rmIrqReq.secondary_host         = TISCI_MSG_VALUE_RM_UNUSED_SECONDARY_HOST;
                retVal = Sciclient_rmIrqSet(
                             &rmIrqReq, &rmIrqResp, SCICLIENT_SERVICE_WAIT_FOREVER);
            }
            if (retVal != 0)
                appLogPrintf("Error4444 in SciClient Interrupt Params Configuration!!!\n");
            else
                appLogPrintf("Ok\n");
            if (retVal == 0)
            {
                /* We will have to use the routed interrupt number
                subsequently */
                Osal_RegisterInterrupt_initParams(&intrPrms);
    
                intrPrms.corepacConfig.arg          = (uint32_t)NULL_PTR;
                intrPrms.corepacConfig.isrRoutine   = (void (*)(uintptr_t))ecap_call_back;
                intrPrms.corepacConfig.priority     = 1U;
                intrPrms.corepacConfig.corepacEventNum = 0U; /* NOT USED  */
                intrPrms.corepacConfig.intVecNum = intNum;
    
                Osal_ClearInterrupt(intrPrms.corepacConfig.corepacEventNum, intrPrms.corepacConfig.intVecNum);
    
                osalRetVal = Osal_RegisterInterrupt(&intrPrms, &hwiHandle);
                if(OSAL_INT_SUCCESS != osalRetVal)
                {
                    appLogPrintf(": Error in Osal Interrupt Registration Configuration!!!\n");
                }
            }
            else
            {
                appLogPrintf(": Error in SciClient Interrupt Params Configuration!!!\n");
            }
    
        }
        else
        {
            appLogPrintf(": Error in Interrupt IR translation Configuration!!!\n");
        }
    
    }

    The "intNum" is 256.

    Is there anything else needs to modified?

    Thank you.