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.

BIOS and TIMER0

Other Parts Discussed in Thread: SYSBIOS

I am running a SYS/BIOS application on the DSP of the 816x.  I wanted to use TIMER0 as the source of the SYSBIOS system clock -- that's not TIMER1 on the 816x but rather the first timer on the platform -- but it looks BIOS is already using TIMER0 for one-shot timers.  My intention was to have the timer wake up SYS/BIOS every 1ms but what actually happens is my timer handler gets called twice for every ms.  Is TIMER0 reserved for SYSBIOS purposes?

Here is my SYS/BIOS timer configuration:


/* Create myTimer as source of Hwi */
var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
var timerParams = new Timer.Params();
timerParams.startMode = Timer.StartMode_USER;
timerParams.runMode = Timer.RunMode_CONTINUOUS;
//timerParams.extFreq.lo = 27000000;
timerParams.period = 1000; // 1ms
Program.global.myTimer = Timer.create(0, "&myTimerFunc", timerParams);

here is my timer handler:

Void myTimerFunc()
{
 Clock_tick();
}

  • By default, the SYS/BIOS Clock module uses GPTimer3 (BIOS Timer #0) to tick with a 1ms period.  However, if you choose to explicitly use BIOS Timer #0 (as you have done in your .cfg file) then BIOS can use another timer.

    Your .cfg code indicates that you haven't disabled the default tick source (from the BIOS Clock timer).  As a result, two timers each cause the clock to tick every 1ms.   This, however, doesn't explain why your timer0-specific handler gets called twice for every ms (I can't explain this). 

    Lastly, why you are trying to override the default SYS/BIOS tick function?   As I mentioned, BIOS by default uses a tick frequency of 1ms by default.

    For your reference (from BIOS 6.31.04)

    TMS320TI816X (DSP)
    BIOS Timer ID Timer Name Timer Base Address
    0 GPTimer3 0x8042000
    1 GPTimer4 0x8044000
    2 GPTimer5 0x8046000
    3 GPTimer6 0x8048000
    4 GPTimer7 0x804a000
  • Shreyas:

    Thanks for the information.  Maybe I'm making this more complicated than it needs to be.  I want to override the default tick function so that I can measure system idleness.

    How do you disable the default tick source?  I tried:

    BIOS.clockEnabled = false; 

    but my timer function still ends up getting called twice per 1ms.

     

    Neil

  • If you plan to call Clock_tick yourself (instead of a BIOS-configured timer doing this for you) you should use the configuration:

    var Clock = xdc.useModule('ti.sysbios.knl.Clock');

    Clock.tickSource = Clock.TickSource_USER; // Clock_tick() run in user's ISR

    How do you plan to measure system idleness by changing the clock tick source?  Have you considered using the Load (ti.sysbios.utils.Load) module to measure load?

  • Shreyas:2768.mutex.zip

    I will check out the load module as an alternative to using my own tick function.  In the meantime, I have to Clock.tickSource set to Clock.TickSource_User and I am still getting 2 interrupts per 1ms.

    See mutex.cfg and mutex.c in the attached zip file. 

    Neil

  • Could you use the ROV tool to ensure that the Clock module is ticking once every time the myTimerFunc ISR executes?  Use Tools-> ROV to launch this tool and navigate to the view for the 'Clock' module.

    How do you know that you are getting 2 interrupts per ms?  Are you measuring this using an external clock/watch?  If you are indeed getting 1 clock tick per ISR, then perhaps your timers are running twice as fast as BIOS expects them to run. 

    Regards,

    Shreyas

  • I used the ROV tool and counted the number of ticks received over roughly a 30 second interval -- I got over 57,000.  This is with a 1ms tick.

    I am measuring the time between ticks by taking the difference in the C674x's TSC register between calls to myTimerFunc.  According to the values that are read from the TSC, there is typically a short tick followed by a long tick.  On the TI816x, the C674x has a default clock rate of 813MHz and a typical value for a short tick is 0x12246 and a longer tick 0xbbc80.  If you add the 2 values together, you get 843,462 or roughly 1ms.

  • I was able to reproduce your problem using the testcase attached to your earlier post.  I see ~57,000 ticks on the DSP after 30 seconds (measured using my stopwatch) have elapsed.  Interestingly, I get the correct number of ticks when I switch modify the DSP to use BIOS Timer #1 (GPTimer #4).  Could you try switching to this timer and let me know if it works for you?

    If you let BIOS create the timer for you, insert the following code into your .cfg:

    Clock.timerId = 1;

    If you create your own Timer instance (as you have done in mutex.cfg), modify the call to Timer.create as follows:

    Program.global.myTimer = Timer.create(1, "&myTimerFunc", timerParams);

    I'm still investigating why GPTimer #3 seems to be counting faster than the rest.

    Regards,

    Shreyas

  • Shreyas:

         I repeated your experiment and verified your results.  myTimerFunc gets called once every 1ms if I change to BIOS Timer #1/GP Timer #4.

    Neil

  • Great.  I'll post updates regarding the issue with Timer#3 when I discover anything new.  Thanks for your patience with this issue.

    Regards,

    Shreyas

  • FYI this issue is still on our radar.

    Shreyas