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.

Problem with Timer64 on C6678 using SYSBIOS Timer64 API

I created a test app to use a 64 bit general purpose timer on EVM6678. 

XdcConf:

var Timer = xdc.useModule('ti.sysbios.timers.timer64.Timer');

I created a timer in C as follows:

#include <ti/sysbios/timers/timer64/Timer.h>

void CreateTimer()
{
       // Create the timer
        Timer_Params prms;
        xdc_runtime_Types_FreqHz  freq;

        Timer_Params_init(&prms);
        prms.period     = 10000;
        prms.startMode  = Timer_StartMode_USER;
        prms.periodType = Timer_PeriodType_COUNTS;
        prms.arg        = (UArg) this;

        m_hdlTimer64 = Timer_create(9, TimerISR, &prms, NULL);
        Timer_getFreq(m_hdlTimer64, &freq);

        double factor = (double)freq.lo / 200.0e6;
        double period = 10240.0 * factor;
        unsigned int iPeriod   = (unsigned int) floor(period + 0.5);
        Timer_setPeriod(m_hdlTimer64, iPeriod);

        Timer_start(m_hdlTimer64);
}

volatile g_Ticks=0;

void TimerISR(UArg arg)
{
      g_Ticks++;
}

Everything gets created properly except the TGCR register.  Every time I run this code, the TGCR register is set to 0.  When I go into the debugger and set it to 3, everything works.  What is missing in my initialization to get the TGCR set correctly?

Thanks,

Dan

  • What version of SYS/BIOS are you using? What is the value of iPeriod that is being passed into Timer_setPeriod?

    Not related...
    1. Is there a reason you are passing "this" into arg? The TimerISR function does not use it. You can not set it and save a few cycles.
    2. Do not use a NULL Error_Block in the Timer_create. If there is an error in the function and the Error_Block is NULL, the program terminates. If the Error_Block is not NULL (and initialized properly), the function returns with a NULL handle and a filled in Error_Block.
  • What version of SYS/BIOS are you using? 
    -- 6.32.6.56 (to be compatible with the Syslink version that works with C6x Linux)

    What is the value of iPeriod that is being passed into Timer_setPeriod? 
    -- 51200

    Not related...
    1. Is there a reason you are passing "this" into arg? The TimerISR function does not use it. You can not set it and save a few cycles.
    -- This code was hacked out of a larger C++ class.  The this pointer is important for maintaining state information


    2. Do not use a NULL Error_Block in the Timer_create. If there is an error in the function and the Error_Block is NULL, the program terminates. If the Error_Block is not NULL (and initialized properly), the function returns with a NULL handle and a filled in Error_Block 
    -- Thanks.  I did not realize this.

  • I need to look at this a little more. Just to make sure, you are not using timer id 9 any where else are you? Can you list the other timers that are being used? An easy way is to look in ROV.
  • The only timers that show up in ROV is Timer7 and Timer9. The app is running on Core7.  C6xLinux is running on Core0.

    Dan

  • I also tried a 32-bit unchained configuration by adding the following line to the init params:

    prms.half = Timer_Half_LOWER;

    I got the same result. The timer did not have the TGCR set and thus didn't work. Once I wrote 5 to the TGCR in the debugger it worked.

    Dan
  • Try adding the following to your *.cfg file:

    Timer.timerSettings[9].ownerCoreId = 7;            /* this means core7 will be owner of Timer9 and take it out of reset */


    Basically, since this is a shared timer, you need to specify why core actually is going to take the timer out of reset.
    This is stated in the cdoc documentation for the Timer.

    Judah

  • Thank you. That fixed it.

    Dan