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: Which interrupt number should I use for main mcspi3 in mcu2_1 in psdk7.00 ?

Part Number: TDA4VM

Hi,

I'm using main mcspi3 to communicate with external device in mcu2_1 in psdk7.00 refer the main_mcspi_slave_mode.c. When mcspi3 work in poll mode. All things are good. I can transfer and receive data correctly. 

But when I trying using the callback mode, I using CSLR_R5FSS0_INTROUTER0_IN_MCSPI3_INTR_SPI_0 as interrupt number. Then in SPI_v1.c the interrupt will register error. Also my callback function will not trigger.

        if ((chObj->operMode != (uint32_t)SPI_OPER_MODE_POLLING) &&
            (object->hwi == NULL))
        {
            /* register interrrupt when the 1st
               channel of the instance is opened */
            Osal_RegisterInterrupt_initParams(&interruptRegParams);             

            interruptRegParams.corepacConfig.name=NULL;
#ifdef __TI_ARM_V7R4
            interruptRegParams.corepacConfig.priority=0x8U;
#else
            interruptRegParams.corepacConfig.priority=0x20U;
#endif
            interruptRegParams.corepacConfig.corepacEventNum = (int32_t)hwAttrs->eventId;
            interruptRegParams.corepacConfig.intVecNum = (int32_t)hwAttrs->intNum; /* Host Interrupt vector */
            interruptRegParams.corepacConfig.isrRoutine  = (void (*)(uintptr_t))(&MCSPI_v1_hwiFxn);
            interruptRegParams.corepacConfig.arg         = (uintptr_t)mcHandle;

            (void)SPI_osalRegisterInterrupt(&interruptRegParams,&(object->hwi));

            if(object->hwi == NULL)
            {
                MCSPI_close_v1(mcHandle);
                ret_flag = 1u;
                retMcHandle = NULL;
                printf("Enter %s %d\n", __FUNCTION__, __LINE__);
            }
        }

It will return because object->hwi is NULL.

So which interrupt number should I use to enable callback mode ?

Regards

  • Hi, :

    Please refer to the example in 

    mcusw/mcal_drv/mcal/examples/Spi/mcspi_app/soc/j721e/mcu2_1/McspiApp_Startup.c

    Thanks.

  • Hi Peter,

    The APP_SPI_3_INT value is 256+24=280. The Sciclient_rmIrqSet return -1 so it's not successfully.

    Then I modify the code show below, I tried all value 0-511, then I found 384 is good.

    #define INTRTR_CFG_START_LEVEL_INT_NUMBER (CSLR_R5FSS0_CORE1_INTR_R5FSS0_INTROUTER0_OUTL_0)
    #define INTRTR_CFG_MAIN_DOMAIN_MCPSI_3_OUT_INT_NO  (24U)
    #define APP_SPI_3_INT   (INTRTR_CFG_MAIN_DOMAIN_MCPSI_3_OUT_INT_NO +  INTRTR_CFG_START_LEVEL_INT_NUMBER)
    
    void SpiApp_InterruptConfig(void)
    {
        Int32 retVal;
        struct tisci_msg_rm_irq_set_req     rmIrqReq;
        struct tisci_msg_rm_irq_set_resp    rmIrqResp;
        uint32_t i;
    
        for(i=0; i<512; ++i) {
    
    		/* We will have to use the routed interrupt number
    			subsequently */
    		/* 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_MCSPI3;
    		rmIrqReq.global_event           = 0U;
    		rmIrqReq.src_index              = 0U;
    		rmIrqReq.dst_id                 = TISCI_DEV_R5FSS0_CORE1;
    		rmIrqReq.dst_host_irq           = i;
    		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);
    		printf("SpiApp_InterruptConfig retval %d, dst id %d\n", retVal, i);
    		if(!retVal) {
    			break;
    		}
    		Osal_delay(50);
    	}
    }

    Now my mcspi runs well. Thanks.

    Regards.

  • Hi Peter,

    Do you meet this problem? Since I using blocking mode and callback mode instead polling mode, only the first opened channel will transfer successfully. When I operate other channels, the transfer function will crash. I trace where it crash, I found it's in SPI_v1.c's line 772 McSPICSAssert(hwAttrs->baseAddr, chNum);

    But if I just using one channel that first opened, all thing's good.

    This code shows where it crash.

            if(SPI_MASTER == chObj->spiParams.mode)
            {
                McSPIIntEnable(hwAttrs->baseAddr, intStatus);
    
                if (hwAttrs->chMode == MCSPI_SINGLE_CH)
                {
                    /* Assert un-used chip select (Force SPIEN) */
                    McSPICSAssert(hwAttrs->baseAddr, chNum);  //Crash here
                }
            }
            else
            {
                McSPIIntEnable(hwAttrs->baseAddr, (uint32_t)(MCSPI_INT_RX_FULL(chNum)));
            }

    Regards.

  • Hi, Yuping:

    In this case, it seems the code has run into the wrong place.

    Can you change the hwAttrs->chMode from MCSPI_SINGLE_CH to multiple channel mode?

    Thanks.

  • Hi Peter,

    I have tried, It crashed in other place that I don't know. It cannot work.

    Regards.

  • Hi, Yuping:

    Since this is a new question, let's start a new thread for it.

    Thanks.

  • Hi Peter,

    Thanks for your help. Need I create a new topic? Or you created and shared new thread link to me ?

    Regards.