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.

Compiler/TDA4VM: Do TimerP_create() API use a Timer resource?

Part Number: TDA4VM

Tool/software: TI C/C++ Compiler

I have checked that Timer_create() and Clock_create() will use one Timer in below link:

I have find new API named “TimerP_create” which is different with "Timer_create".

I want to know:

  1. What is the difference between them?
  2. Do TimerP_create() API use a Timer resource?

  • Hi,

    TimerP_create() is an OSAL (Operating System Abstraction Layer) API. It acts as an intermediary between the Application and BIOS API.

    It was added so that customers can port their own Operating Systems without changing application/examples.

    Yes, TimerP_create() uses a DM Timer resource.

    Regards

    Vineet

  • I want to double check the TimerP_create() and Timer_create(). Are they same as each other?

  • They do the same thing. TimerP_create() is abstracted for Operating System and the recommended option

    Regards

    Vineet

  • I have do some test of TimerP_create, but the period is not accurate.

    • First step: I create one timer use TimerP_create:

         Error_init(&eb);

        TimerP_Params_init(&timerParams_hwi_0);

        timerParams_hwi_0.startMode = TimerP_StartMode_USER;
        // timerParams_hwi_0.periodType = TimerP_PeriodType_MICROSECS;
        timerParams_hwi_0.periodType = TimerP_PeriodType_COUNTS;
        timerParams_hwi_0.period = TEST_TIMER_INTERVAL;/*usecs*/

        timerHandle_hwi_0 = TimerP_create(TimerP_ANY, (TimerP_Fxn)Timer_HWI_func,
                                        &timerParams_hwi_0);
        if (NULL == timerHandle_hwi_0)
        {
            /*Failed to create timer*/
            appLogPrintf("TimerTest: Failed to create timer\n");
        }

    • Second step: I post some semaphore for each task.

    #if defined(OSAL_SEMAPHORE_TEST)
    static void Timer_HWI_func(void)
    {
        hwi_timerTickCnt_1ms++;
        SemaphoreP_post(semaphoreHandle_1ms);
        if( hwi_timerTickCnt_1ms % 5 == 0 )
        {
            SemaphoreP_post(semaphoreHandle_5ms);
        }

        if( hwi_timerTickCnt_1ms % 10 == 0 )
        {
            SemaphoreP_post(semaphoreHandle_10ms);
        }

        if( hwi_timerTickCnt_1ms % 20 == 0 )
        {
            SemaphoreP_post(semaphoreHandle_20ms);
        }

        if( hwi_timerTickCnt_1ms % 50 == 0 )
        {
            SemaphoreP_post(semaphoreHandle_50ms);
        }

        if( hwi_timerTickCnt_1ms % 100 == 0 )
        {
            SemaphoreP_post(semaphoreHandle_100ms);
        }

        if( hwi_timerTickCnt_1ms % 200 == 0 )
        {
            SemaphoreP_post(semaphoreHandle_200ms);
        }

        if( hwi_timerTickCnt_1ms % 500 == 0 )
        {
            SemaphoreP_post(semaphoreHandle_500ms);
        }

        if( hwi_timerTickCnt_1ms % 1000 == 0 )
        {
            SemaphoreP_post(semaphoreHandle_1000ms);
        }
    }
    #endif

    • Third step: print the counter in 1S task.

    static void appTask_1ms_proc(UArg arg0, UArg arg1)
    {
        // static uint32_t app_Task_1ms_cnt_internal = 0;
        while(1)
        {
            /*Pend on semaphore posted by DM Timer*/
            SemaphoreP_pend(semaphoreHandle_1ms, SemaphoreP_WAIT_FOREVER);

            Task_timerTickCnt_1ms++;

    }

    /**************************** appTask_5ms_proc *********************************/
    static void appTask_5ms_proc(UArg arg0, UArg arg1)
    {

        while(1)
        {
            /*Pend on semaphore posted by DM Timer*/
            SemaphoreP_pend(semaphoreHandle_5ms, SemaphoreP_WAIT_FOREVER);
            Task_timerTickCnt_5ms++;
        }
    }

    /**************************** appTask_1000ms_proc *********************************/
    static void appTask_1000ms_proc(UArg arg0, UArg arg1)
    {
        while(1)
        {
            /*Pend on semaphore posted by DM Timer*/
            SemaphoreP_pend(semaphoreHandle_1000ms, SemaphoreP_WAIT_FOREVER);
            Task_timerTickCnt_1000ms++;
            appLogPrintf("timertest : Task_timerTickCnt_1ms = %d\n", Task_timerTickCnt_1ms);
            appLogPrintf("timertest : Task_timerTickCnt_5ms = %d\n", Task_timerTickCnt_5ms);
        }

    }

    The result of the print log in 1S had print more than 5 times.

    I think the clock of the timer is not correct.

    I want to check the below questions:

    1. Is my timer use the TI-RTOS System timer?if it means I can use TimerP_create to create many timers and don't need to care about the timer resource?
    2. How can I make my timer clock be correct?
    3. Is there one fixed unit of TimerP_PeriodType_COUNTS or what is the unit of this type?
    4. For TimerP_PeriodType_MICROSECS, the same question with 3rd.

  • I have solved this problem using this link:

    I add these code for timer configuration:

        /* Overriding frequency to set it to 250MHz */
        timerParams_hwi_0.intfreqLo = 250000000;
        timerParams_hwi_0.intfreqHi = 0;
        timerParams_hwi_0.extfreqLo = 250000000;
        timerParams_hwi_0.extfreqHi = 0;
        timerParams_hwi_0.runMode = TimerP_RunMode_CONTINUOUS;

    Then it works.

    Could you please answer the last two questions:

    1. Is there one fixed unit of TimerP_PeriodType_COUNTS or what is the unit of this type?
    2. For TimerP_PeriodType_MICROSECS, the same question with above.

  • Hi,

    TimerP_PeriodType_COUNTS is a unitless value. It just returns the number of clock ticks. Whatever be the frequency.

    TimerP_PeriodType_MICROSECS gives the number of microseconds.

    Both of them are types for the structure field Timer_PeriodType.

    See

    Regards

    Vineet

  • Thanks for your reply, I can use my periodic task now.