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.

SYS/BIOS Clock Example - Clock_getTicks() = 0

Other Parts Discussed in Thread: LM3S6965, SYSBIOS

Greetings TI Support:

 I've worked on this issue on and off for a few weeks.

I tried all of the examples from the forum questions about ClockTicks and I still can not get the example running. 

I need some guidance. 

 

It “seems” like the system Clock is running; but, it is not fully linked back to my application through SYS/BIOS. 

Thus, the application does not run correctly because Clock Ticks are always 0.

  

Configuration Details

Stellaris LM3S6965

Code Composer Version: 5.3.0.00090

SYS/BIOS 6.34.2.18

XDCTools 3.24.5.28

 

This is What I Have Tried:

When I run the program, I immediately go to Run->Clock->Enable. 

At that point, a little Yellow Clock on the lower left hand side of my screen shows up and starts “counting” numbers as I step through the code.

This appears to work as it changes values every time I progress into the code.

 

I then go to the RTOS Object View Section (ROV)

To the left of that, I click on Test3.out->ViewableModules->Clock.

 

In the ROV BASIC tab view, I see that both of the Clocks are “created”.

They both indicate that they are “started” with the expected parameters.

This appears to be just fine.

 

I then move to the ROV MODULE tab view and notice that “ticks” are 0.  (Not expected)

I compare this against the little Yellow Clock that started from Run->Clock->enabled and both are different.

 

I added some additional code to see Return Values on various functions. 

They all appear to be fine.

Except… Clock_getTicks(); always returns 0.   

 

By the way, all “added” code is denoted by /* add */

I tried this with ONLY native example code with NONE of my code, with the same results.

 

I added BIOS.clockEnabled = true;   /* add */ at the end of my config file with the same results.

 

System_printf works just fine with the System_flush(); command.

I see everything on the Console just fine. 

Only one line of output winds up on the Console.

 Clock Ticks remain to be Zero and clk0Fxn clk1Fxn are never executed.

 

GEL Files..

tisim_armxx.gel 

tisim_ilc.gel 

seem to load just fine….

 

I also successfully loaded 7183.ti816x_ddr.gel from the forum with the same results.  It did not help.

I really do not understand how the GEL files affect the environment.  This is totally mysterious to me.

 

I tried to do everything that I could think of before I had to ask. 

I learned a lot in the process, so this was not wasted time.

But, I am stuck…

Any help would be appreciated.

 

Thanks

 Rick

 

 

 

 

Config File:

var Defaults = xdc.useModule('xdc.runtime.Defaults');

var Diags = xdc.useModule('xdc.runtime.Diags');

var Error = xdc.useModule('xdc.runtime.Error');

var Log = xdc.useModule('xdc.runtime.Log');

var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');

var Main = xdc.useModule('xdc.runtime.Main');

var SysMin = xdc.useModule('xdc.runtime.SysMin');

var System = xdc.useModule('xdc.runtime.System');

var Text = xdc.useModule('xdc.runtime.Text');

 

var BIOS = xdc.useModule('ti.sysbios.BIOS');

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

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

var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');

 

/*

 * Program.argSize sets the size of the .args section.

 * The examples don't use command line args so argSize is set to 0.

 */

Program.argSize = 0x0;

 

/*

 * Uncomment this line to globally disable Asserts.

 * All modules inherit the default from the 'Defaults' module.  You

 * can override these defaults on a per-module basis using Module.common$.

 * Disabling Asserts will save code space and improve runtime performance.

Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;

 */

 

/*

 * Uncomment this line to keep module names from being loaded on the target.

 * The module name strings are placed in the .const section. Setting this

 * parameter to false will save space in the .const section.  Error and

 * Assert messages will contain an "unknown module" prefix instead

 * of the actual module name.

Defaults.common$.namedModule = false;

 */

 

/*

 * Minimize exit handler array in System.  The System module includes

 * an array of functions that are registered with System_atexit() to be

 * called by System_exit().

 */

System.maxAtexitHandlers = 4;      

 

/*

 * Uncomment this line to disable the Error print function. 

 * We lose error information when this is disabled since the errors are

 * not printed.  Disabling the raiseHook will save some code space if

 * your app is not using System_printf() since the Error_print() function

 * calls System_printf().

Error.raiseHook = null;

 */

 

/*

 * Uncomment this line to keep Error, Assert, and Log strings from being

 * loaded on the target.  These strings are placed in the .const section.

 * Setting this parameter to false will save space in the .const section.

 * Error, Assert and Log message will print raw ids and args instead of

 * a formatted message.

Text.isLoaded = false;

 */

 

/*

 * Uncomment this line to disable the output of characters by SysMin

 * when the program exits.  SysMin writes characters to a circular buffer.

 * This buffer can be viewed using the SysMin Output view in ROV.

SysMin.flushAtExit = false;

 */

 

 

/*

 * The BIOS module will create the default heap for the system.

 * Specify the size of this default heap.

 */

BIOS.heapSize = 0x2000;

 

/* System stack size (used by ISRs and Swis) */

Program.stack = 0x1000;

 

/* Circular buffer size for System_printf() */

SysMin.bufSize = 0x400;

 

/*

 * Create and install logger for the whole system

 */

var loggerBufParams = new LoggerBuf.Params();

loggerBufParams.numEntries = 32;

var logger0 = LoggerBuf.create(loggerBufParams);

Defaults.common$.logger = logger0;

Main.common$.diags_INFO = Diags.ALWAYS_ON;

 

/*

 * Configure SysMin for System_printfs because SysStd cannot be used when

 * calling System_printf from Hwis and Swis

 */

System.SupportProxy = SysMin;

 

BIOS.clockEnabled = true;   /* add */

 

 

Code:

#include <xdc/std.h>

#include <xdc/runtime/System.h>

 

#include <ti/sysbios/BIOS.h>

#include <ti/sysbios/knl/Clock.h>

 

Void clk0Fxn(UArg arg0);

Void clk1Fxn(UArg arg0);

       

/*

 *  ======== main ========

 */

Void main()

{

    Clock_Handle clk1, clk2;

    Clock_Params clkParams;

 

    /* setup Clock params */

    Clock_Params_init(&clkParams);

 

    /* Create a periodic Clock Instance with period = 5 system time units */

    clkParams.period = 5;

    clkParams.startFlag = TRUE;

    clk1 = Clock_create(clk0Fxn, 5, &clkParams, NULL);  /* clk1 – add */

   

    /* Create an one-shot Clock Instance with timeout = 11 system time units */

    clkParams.period = 0;

    clkParams.startFlag = FALSE;

    clk2 = Clock_create(clk1Fxn, 11, &clkParams, NULL);

 

    Clock_start(clk1); /* add */

    Clock_start(clk2);

               

    System_printf("Use Some Time...\n");  /* add */

    System_flush();  /* add */

 

    UInt32 time;  /* add */

    time = Clock_getTicks();  /* add */

 

/* time is 0 at this point… clk0Fxn and clk1Fxn are never executed */

 

    BIOS_start();

}

 

/*

 *  ======== clk0Fxn =======

 */

Void clk0Fxn(UArg arg0)

{

    UInt32 time;

   

    time = Clock_getTicks();

    System_printf("System time in clk0Fxn = %lu\n", (ULong)time);

    System_flush();

}

 

/*

 *  ======== clk1Fxn =======

 */

Void clk1Fxn(UArg arg0)

{

    UInt32 time;

   

    time = Clock_getTicks();

    System_printf("System time in clk1Fxn = %lu\n", (ULong)time);

    System_printf("Calling BIOS_exit() from clk1Fxn\n");

    System_flush();

    BIOS_exit(0);

}

 

 

 

  • Hi Rick,

    I'm not familiar with this Run->Clock->Enable tool in CCS, but I suspect that it doesn't have anything to do with the SYS/BIOS Clock.

    The Clock module configures a Timer instance to provide a 1 ms tick interrupt (you can see it in the Timer section of ROV) that generates the ticks. This isn't enabled until after BIOS_start() is called, so it makes sense that the first Clock_getTicks() that you call in main() should return 0 and that the tick values shown in ROV are also 0. You may want to read the Timing Services section of the SYS/BIOS Users Guide for more information about how it works.

    Can you place breakpoints in clk0Fxn and clk1Fxn and run the application to verify that they are never being reached after BIOS_start() is called?

    Thanks,

    Whitney

  • Good Afternoon Whitney:

    Thank you for looking at my question.

    Per BIOS_Start() and Clock_getTicks().  OK, that makese sense.  I did not put that together.

    clk0Fxn & clk1Fxn are never called after BIOS_Start(). 

    I have breakpoints in them that are never reached and System_printf() messages in them that never put anything out to the console.

    These functions are never called.

    Regarding, Run->Clock->Enable ...

     

    This is kind of a before and after view.

    This Clock actually starts "ticking" after I start stepping through the program.

    I have read the section in the SYS/BIOS Users Guide... I wish I could say that the problem would jump out at me.  It is not.

    GEL File?

    Again, thank you very much for looking at this.  It still is not clear to me.  (yet)

    Rick

     

     

     

     

     

  • Rick,

    You said in your original post that you have tried other examples that use the Clock module, correct? So you've been able to successfully run the SYS/BIOS "Swi Example" and enter that clk0fxn()? Or do you always run into this problem?

    Can you look at the Timer section of ROV, and see if the Timer used for ticks (it will be the one with the tickFxn called something like "ti_sysbios_knl_Clock_doTick") is okay? If you check the Device tab, you should see it go from Disabled to Enabled after BIOS_start() is called.

    Also, the Clock functions run in the context of a Swi, so could you check the Swi section in ROV, and make sure there's a Swi in there with a fxn called something like "ti_sysbios_knl_Clock_workFunc"?

    The GEL files could possibly be affecting the timer in some way. Can you make a new target configuration (using the Target Configuration window in CCS) in and launch your target with that, using the stock GEL files that it brings in?

    Thanks,

    Whitney

  • Whitney:

    I have most of what you are looking for. 

     

    I've never been able to get "this" Swi example running.  I've never been able to hit a break point in clk0fxn();

     

    Timer Section of ROV.

     

    I can not see the GPTM[0] go from Disabled to Enabled.  Once I hit BIOS_start(), I really can not get control back.

    Note... I am pretty sure these tie back to the place that you refer to.

    This is what I am looking at though.

     

     

    Swi in ROV.

    This looks good.

     

     

     Per GEL files and a New Configuration...

    How about this, I deleted all of the projects out of my system and rebuilt a brand new project... using the same example.

    Results:  The same... 

    I appreciate your help.  This has made me look at some things that I did not fully understand.

    So... System: 2  People: 0.  What next?  :-)

     

    Rick

     

     

     

     

     

     

  • Okay, well, at least we know that it's not something wrong with this example since the Swi one seems have the same problem.

    After BIOS_start(), when you suspend the debugging session, does the Debug window say that you're in the Idle loop? It's a problem that that Timer instance doesn't appear to be enabled at that point. If that timer isn't causing an interrupt to generate a tick, then your clock instances are going to stay stuck at zero.

    Here's what I meant by creating a new Target Configuration. Go to View->Target Configurations and hit the button to create a new one. You can either put it in a shared location or uncheck that box and put it right in the example project.

    Fill in your device and emulator info, save it, and launch.

    Connect to the target, load the .out for the example you're running, and run. To see what GEL files you're using, go to Tools->GEL Files.

    I'll see if I can get my hands on a LM3S6965 eval board (are you using an eval board or a custom board?) and reproduce this.

  • Whitney:

    You rock!  It was the GEL file. 

    In setting up a new Config, there is a Text Box that says:

    This section describes the general configuration about the target.

    I WAS using the "Texas Instruments Simulator" with "Cortex M3... Little Endian" instead of the "Stellaris In-Circuit Debug Simulator"  with the LM3S6965.gel.

    Why?  Well, I had my USB cable going to a multi-port USB hub, when I used the "Stellaris" drop down, I was receiving an "out of band" message.

    When I used "Texas Instruments Simulator" with "Cortex M3 Little Endian".... No error message.  So, I used it.

    When I saw what you did, the light bulb went off (finally), I plugged the board directly into a now open USB port and everything worked.

    OK... now, it's time to move forward again.

    Thank you very much for helping me.

    Rick