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.

timer / clock not consistently working

Other Parts Discussed in Thread: SYSBIOS, OMAPL138

I am using SYS/BIOS 6.35.4.50 and XDCTools version 3.25.3.72 with Da Vinci SOC (DM8147).

I see that timer is not consistently working. It works fine most of the time. Task_sleep() wake up is not consistent sometimes. It is completely out of range when it wakes out of sleep. For one second, it can take 10 minutes. But it is not all the time. I was trying to debug the problem.

In the debugger, RTOS Object View (ROV), I sometimes see Timer object period changing. Sometimes it is 19999. Sometimes it is random number like 4294965241. I also saw 199990. I was thinking Timer.period should always be same. From ROV, this is the values in 'Basic': name GPTimer1, StartMode_AUTO, RunMode_DYNAMIC, period 19999, periodType_COUNTS, intNum 67. 

I am not doing anything in the code for using timer(guessing SYS/BIOS to handle timer registers etc) other than using Task_sleep(100). 

In app.cfg:

var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Timestamp = xdc.useModule("xdc.runtime.Timestamp");
var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
var TimestampProvider = xdc.useModule('ti.sysbios.timers.dmtimer.TimestampProvider');

var ti_sysbios_hal_Timer = xdc.useModule('ti.sysbios.hal.Timer');

Timestamp.SupportProxy = TimestampProvider;
Clock.tickPeriod = 1000; //for milliseconds

Clock.tickMode = Clock.TickMode_DYNAMIC;

Timer.intFreq.hi = 0;
Timer.intFreq.lo = 20000000;
Timer.checkFrequency =true;

 

Program.argSize = 0x0;
BIOS.clockEnabled = true;
BIOS.libType = BIOS.LibType_Custom;
BIOS.assertsEnabled = false;
BIOS.logsEnabled = false;
//CPU at 1Ghz
BIOS.cpuFreq.hi = 0;
BIOS.cpuFreq.lo = 1000000000;

  • One observation was the task_sleep() is messed up when paused from debugger. This is one case where it is messed up. I am using Code composer version 5.5. I appreciate any hint to debug the problem.

  • Are you using both cores on the OMAPL138?   Which OS is running on each core?  Which core are you seeing this problem on?   The timers are shared and accessible from both sides.  I wonder if "the other side" is competing with you for a single timer.

  • Ooops.   Sorry.  I see it is DaVinci.   I suspect that you are colliding with some Linux timer use from the Arm side.  Can you try a different timer id?   The Clock module allows you to select a different timer id.   You should be able to look in the memory window at the registers for the timers and see which ones are not being touched and pick one of those.

  • Thanks for the reply.

    (1) I am not using Linux OS and so I don't think there will be any interference. By the way, it is working until I pause. On the DSP, no OS is used, just direct access. On the ARM side, I am using SYS/BIOS and Task_sleep(100) is used here.

    (2) Another thing noticed was when Sleep was using like 10 seconds value, it comes out of sleep after very long timeout first time it is used. When tested in loop, it has large timeout first time, but works fine later.

    Any hints on how to debug with ROV or other ways. There is something related to initialization or reloading timer or something similar.

  • 1.  You still need to be careful that there's no collision between DSP and ARM use of timers.  Just make sure that they aren't using the same timer.  Now, you said everything is working correctly until pause.  This suggests that its not a conflict between ARM and DSP but rather you need to set the Emulation bit of the Timer.

    EMUMGT_CLKSPD: Emulation Management/Clock Speed registers

     

    31                         

                                   16

    15                           

                                     0

    CLKSPD

     EMUMGT

     

    EMUMGT: Emulation Management

     

    15                         

                                     2     

                    1           

                      0

      RSV

    SOFT

    FREE

     

     

    Name

    Function

    FREE

    FREE: determines emulation mode functionality of the timer. When the FREE bit is cleared, the Soft bit selects the timer mode.

    FREE=0: the Soft bit selects the timer mode. (DV).

    FREE=1: the timer runs free regardless of the soft bit.

    SOFT

    SOFT: determines emulation mode functionality of the timer. When the FREE bit is cleared, the Soft bit selects the timer mode.

    SOFT=0: The timer stops immediately. (DV).

    SOFT=1: The timer stops when the counter increments and reaches the value in the timer period register. 

     2.  Can you give more context to this long sleep time.  Where is sleep being called?  Where has the processor just been?

    Judah