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: use TimerP_creat, can not succes

Part Number: TDA4VM
Other Parts Discussed in Thread: SYSBIOS

Hi Experts,

Environment

       QNX, vision_apps ,TIRTOS, mcu2_0  , code fold is in kernels;

My issue is creat a timer counter by 'TimerP_creat ',  the function TimerP_creat  no responed, and the software is dead;

First I use while(1) , my software is OK, every funtion is running in plan(MCSPI ,GPIO,and state change etc.);

then i try using 'TimerP_creat ' to setting a timer flag, and using while(flag) instead the while(1), reference SDK code (Enet_apputils_baremetal.c)

but the software could not run after compiled(no debug messages out which i wrote after the 'while' ),

then I check the function TimerP_creat is in which file,and copy the file in my code folder, but compiled fail, the issue is "Timer_Params" not include "params->intNum", 

I remove the code "params->intNum", compiled still fail, the faile message is " no define ti_sysbios_hal_Timer_Module_startup__E " etc, I do not know where these defined.

My question is:

1.The resense is not  contain a correct path about  TimerP_creat ? If the path not right, which path should include?

2.Any ' .mak' file need change? If need, in kernel folder, or in basic_demos/app_tirtos/tirtos_qnx/mcu2_0 or other path? How to change the file?

Thanks! 

 

  • Hi,

    Which SDK is under test?

    In referencing ti-processor-sdk-rtos-j721e-evm-07_03_00_07/pdk_jacinto_07_03_00_29/packages/ti/drv/enet/examples/utils/enet_apputils_baremetal.c, the while loop reads as below, where it is checking a variable gTimeElapsed which is set in the interrupt handler EnetAppUtils_timerISR().

       while (1U != gTimeElapsed);

    The interrupt handler is being called upon expiry of a timer which was created by TimerP_create(), in EnetAppUtils_timerInit() in the same file.

    Does this example meet the request of a TimerP_create() example?   Please advise and/or provide further details (code example) if the question has been misunderstood.   

    Regards,

    kb

  • Hi KB,

      My code as below. I did not test a SDK code, I just wrote code reference SDK code.

    You can see after TimerP_create , no matter succes or fail , there is  ok or err message out in Timer2ms_registerTimerInt , in fact after compiled , and runing code, there is no messages out.

    static void FunctionDriverMain(UArg arg0, UArg arg1)
    {
    Timer2ms_registerTimerInt();
    while(true==gTimerset)
    {
    gTimerset = false;
    Function_Task();

    }
    }

    uint8_t gTimerset = 0U;
    static void Timer2ms_clockFxn (uintptr_t arg)
    {
    gTimerset = true;
    (void)TimerP_start(CycTimerHandle);

    appLogPrintf("2ms task gTimerset set \n");
    }

    void Timer2ms_registerTimerInt(void)
    {
    TimerP_Params TimerParams_2ms;
    TimerP_Params_init(&TimerParams_2ms);

    appLogPrintf("Timer2ms_registerTimerInt \n");
    /* Initialize Main Timer 1 */
    TimerParams_2ms.periodType = TimerP_PeriodType_MICROSECS;
    TimerParams_2ms.startMode = TimerP_StartMode_USER;
    TimerParams_2ms.runMode = TimerP_RunMode_CONTINUOUS;
    TimerParams_2ms.period = 200;
    appLogPrintf("Timer2ms_registerTimerInt 2 \n");
    CycTimerHandle = TimerP_create(TimerP_ANY,
    (TimerP_Fxn)&Timer2ms_clockFxn,
    &TimerParams_2ms);
    if(CycTimerHandle != 0)
    {
    Timer2ms_startClock(2);
    appLogPrintf("Timer2ms_registerTimerInt creat ok \n");
    }
    else
    {
    appLogPrintf("Timer2ms_registerTimerInt creat err \n");
    }
    }

  • The logic of the while loop may not be correct for the desired functionality. 

    For example if the initialization of gTimerset, is modified to be 1 as opposed to 0, does that make a difference?   Currently it appears as though the while() loop would not be entered, and code would exit.

    Regards,

    kb.

  • Yes, the main loop logic is wrong, i rewrote as below.

    static void FunctionDriverMain(UArg arg0, UArg arg1)
    {
        Timer2ms_registerTimerInt();
    }

    static void Timer2ms_clockFxn (uintptr_t arg)
    {

    Function_Task();
    (void)TimerP_start(CycTimerHandle);

    appLogPrintf("2ms task gTimerset set \n");
    }

    void Timer2ms_registerTimerInt(void)
    {
    TimerP_Params TimerParams_2ms;
    TimerP_Params_init(&TimerParams_2ms);

    appLogPrintf("Timer2ms_registerTimerInt \n");/**********1************************/


    /* Initialize Main Timer 1 */
    TimerParams_2ms.periodType = TimerP_PeriodType_MICROSECS;
    TimerParams_2ms.startMode = TimerP_StartMode_USER;
    TimerParams_2ms.runMode = TimerP_RunMode_CONTINUOUS;
    TimerParams_2ms.period = 200;


    appLogPrintf("Timer2ms_registerTimerInt 2 \n");/**********2************************/


    CycTimerHandle = TimerP_create(TimerP_ANY,
    (TimerP_Fxn)&Timer2ms_clockFxn,
    &TimerParams_2ms);
    if(CycTimerHandle != 0)
    {
    Timer2ms_startClock(2);
    appLogPrintf("Timer2ms_registerTimerInt creat ok \n");/**********3************************/
    }
    else
    {
    appLogPrintf("Timer2ms_registerTimerInt creat err \n");/**********3************************/
    }
    }

    In fact, the issue is in Timer2ms_registerTimerInt() before enter the loop, the print information, just 1 and 2 out, no 3.

  • If code is not functioning, recommended next step would be to attach a debugger and follow code path to failure.   A while loop, or equivalent is likely required to keep the code above from exiting.

    The E2E forum has links which go over TimerP_create() usage, and the PDK also has examples (search on TimerP_create).

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/925990/compiler-tda4vm-do-timerp_create-api-use-a-timer-resource 

    Regards,

    kb

  • “If code is not functioning, recommended next step would be to attach a debugger and follow code path to failure.”

    I try to fined the resaon, search the TimerP_creat in PDK , the function is in two files TimerP_tirtos.c and TimerP_nonos.c,

    Which file will be used? 

    Because my woftware is running TIRTOS, so i copied  TimerP_tirtos.c into my folder, compiled failed "timerParams no include intNum", that means there is different between Timer_Params and TimerP_Params, all of these code are in PDK,  should i use "imerP_nonos.c"?

  • Hi,

    The reason for referencing the above thread, was to provide another example of TimerP_create() being used, that can be referenced and compared to the code that is being debugged.

    There is no reason to move from using TimerP_create() to directly using Timer_create().

    Regards,

    kb

  • Hi,

    "The reason for referencing the above thread, was to provide another example of TimerP_create() being used, that can be referenced and compared to the code that is being debugged."

    you mean that even though the system uses Tirtos, may call the function in TimerP_nonos?

    I just search 2 files include  TimerP_creat.

    "There is no reason to move from using TimerP_create() to directly using Timer_create()."

    Not use Timer_create(), in TimerP_create(), there is a define as below screen shot.

    SDK code for TimerP_creat

     

  • Hi,

    Could you please rephrase the last question, not following the request. 

    Regarding original code posted, and failure under investigation, recommendation is to reference a working solution and try to keep the code as similar as possible.  Once "new" sample code is working, then start making modifications to meet the needs of feature development.

    Regards,

    kb

  • Hi

    sorry for late reply!

    Current the creat funtion is OK, the debug information "Timer2ms_registerTimerInt creat ok" was print out;

    but then the system broken down, the  others debug information not print out.

    Code as below

    TimerP_Handle CycTimerHandle;
    uint8_t gTimerset;

    static void Timer2ms_clockFxn (UArg arg)
    {

    appLogPrintf("2ms task gTimerset set 1\n");


    gTimerset = true;

    appLogPrintf("2ms task gTimerset set 2\n");
    }

    static void Timer2ms_stopClock(void)
    {
    TimerP_stop(CycTimerHandle);

    /* Reset the timer elapsed variable */
    gTimerset = 0U;
    }
    void Timer2ms_timerDeInit(void)
    {
    Timer2ms_stopClock();
    while(NULL!= CycTimerHandle)
    {
    TimerP_delete(CycTimerHandle);
    }
    }

    void Timer2ms_registerTimerInt(void)
    {
    TimerP_Params TimerParams_2ms;
    TimerP_Params_init(&TimerParams_2ms);

    TimerParams_2ms.periodType = TimerP_PeriodType_MICROSECS;
    TimerParams_2ms.startMode = TimerP_StartMode_USER;
    TimerParams_2ms.runMode = TimerP_RunMode_CONTINUOUS;
    TimerParams_2ms.period = 200000;
    CycTimerHandle = TimerP_create(TimerP_ANY,
    (TimerP_Fxn)&Timer2ms_clockFxn,
    &TimerParams_2ms);
    if(CycTimerHandle != 0)
    {
    TimerP_start(CycTimerHandle);
    appLogPrintf("Timer2ms_registerTimerInt creat ok \n");
    }
    else
    {
    appLogPrintf("Timer2ms_registerTimerInt creat err \n");
    }
    }


    static void USSDriverMain(UArg arg0, UArg arg1)
    {

       Timer2ms_registerTimerInt();
      while(1)
      {
        if(gTimerset)
       {
         appLogPrintf("Timer2ms_registerTimerInt FLAG set \n");
         gTimerset = 0;
       }
       appLogWaitMsecs(1000u);
      }
    }