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: 如何在TI-RTOS設定Timer and Interrupt?

Part Number: TDA4VM


SDK: Processor SDK RTOS J721E 08_06_01

 請教,在 ti-processor-sdk-rtos-j721e-evm-08_06_01_03/vision_apps/platform/j721e/rtos/mcu2_0/main.c

如果想要設定 Timer 在一固定周期(例如 1us or 任意時間) 產生一中斷並進行調用 callball function。

是參考 ti-processor-sdk-rtos-j721e-evm-08_06_01_03/pdk_jacinto_08_06_01_03/packages/ti/csl/test/dmTimerUt中的範例?

或是使用

或是有推薦的example code and reference document。

謝謝。

  • 是參考 ti-processor-sdk-rtos-j721e-evm-08_06_01_03/pdk_jacinto_08_06_01_03/packages/ti/csl/test/dmTimerUt中的範例?

    可以的。以下帖子的讨论可以参考看一下:

    e2e.ti.com/.../tda4vm-how-to-use-ti-rtos-timers-to-add-a-periodic-function

  • 請問,

    1. 要調整時間周期,除了使用TIMERPreScalerClkEnable還有其他的嗎?時間週期彈性度不大。

    static void csldmTimerTest_Stub(uintptr_t arg)
    {
      uint32_t baseAddr = (uint32_t) (CSL_TIMER12_CFG_BASE);
    
      //TIMERPreScalerClkEnable(CSL_TIMER12_CFG_BASE, TIMER_PRESCALER_CLK_DIV_BY_256);
    
      /* Disable the Timer interrupts */
      TIMERIntDisable(baseAddr, TIMER_INT_OVF_EN_FLAG);
    
      /* acknowledge the interrupt */
      TIMERIntStatusClear(baseAddr, TIMER_IRQSTATUS_OVF_IT_FLAG_MASK);
    
      printf("Timer Interrupt\n");
    
       /* Enable the Timer interrupts */
      TIMERIntEnable(baseAddr, TIMER_INT_OVF_EN_FLAG);
    }
    
    static int32_t csldmTimer_registerTimerInt(void)
    {
        int32_t                  testStatus;
        OsalInterruptRetCode_e   retVal;
        OsalRegisterIntrParams_t interruptRegParams;
        /* Initialize with defaults */
        Osal_RegisterInterrupt_initParams(&interruptRegParams);
    
        /* Populate the interrupt parameters */
        interruptRegParams.corepacConfig.arg = (uintptr_t) CSL_TIMER12_CFG_BASE;
        interruptRegParams.corepacConfig.name = NULL;
        interruptRegParams.corepacConfig.isrRoutine = csldmTimerTest_Stub;
        interruptRegParams.corepacConfig.triggerSensitivity =  OSAL_ARM_GIC_TRIG_TYPE_HIGH_LEVEL;
        interruptRegParams.corepacConfig.priority = 0xFU; // R5: 0-15
    
        interruptRegParams.corepacConfig.intVecNum = CSLR_R5FSS0_CORE0_INTR_TIMER12_INTR_PEND_0; /* Host Interrupt vector */
        interruptRegParams.corepacConfig.corepacEventNum = CSLR_R5FSS0_CORE0_INTR_TIMER12_INTR_PEND_0;
    
        printf("Register interrupts\n");
        /* Register interrupts */
        retVal = Osal_RegisterInterrupt(&interruptRegParams,&(gdmTimerTest_HwiPHandle));
    
        printf("retVal %d\n", retVal);
    
        if (retVal == OSAL_INT_SUCCESS)
        {
            testStatus = CSL_APP_TEST_PASS;
        }
        else        
        {    
            testStatus = CSL_APP_TEST_FAILED;
        }
        return (testStatus);
    }
    
    static void appMain(void* arg0, void* arg1)
    {
        appUtilsTaskInit();
        appInit();
        appRun();
        #if 1
        appLogPrintf("mcu2_0: Task - start\n");
    
        TIMERPreScalerClkEnable(CSL_TIMER12_CFG_BASE, TIMER_PRESCALER_CLK_DIV_BY_256);
        csldmTimer_registerTimerInt();
    
        while(1)
        {
            appLogWaitMsecs(100u);
            appLogPrintf("mcu2_0: Task - appMain\n");
        }
        #else
        appDeInit();
        #endif
    }
    
    int main(void)
    {
        TaskP_Params tskParams;
        TaskP_Handle task;
    
        /* This is moved before the wait function as NDK comes up with BIOS
            and looks for semaphore handle created by appEthFwEarlyInit() */
    #ifdef ENABLE_ETHFW
        appEthFwEarlyInit();
    #endif
    
        /* This is for debug purpose - see the description of function header */
        StartupEmulatorWaitFxn();
    
        OS_init();
    
        TaskP_Params_init(&tskParams);
        tskParams.priority = 8u;
        tskParams.stack = gTskStackMain;
        tskParams.stacksize = sizeof (gTskStackMain);
        task = TaskP_create(&appMain, &tskParams);
    
        //csldmTimer_registerTimerInt();
    
        if(NULL == task)
        {
            OS_stop();
        }
    
        OS_start();
        
        return 0;
    }
        
    

    2. 另外如果在 Task 的 appMain啟動 csldmTimer_registerTimerInt, Timer 中斷有動作,但是Task無法動作 (while 內的printf log 無輸出)。

    但是如果在 main中啟動 csldmTimer_registerTimerInt,Task 可以正常輸出(while內的 printf log) 。

    請問如何解決和為什麼?謝謝。

  • 後來改用 TimerP.h,目前可以動作。但是想了解使用 CSL的dmTimer 哪邊出問題和為何不能動作?! 謝謝。

  • 您的问题我们需要升级到英文论坛看下,链接如下,请持续关注:

    e2e.ti.com/.../tda4vm-adjust-the-time-period