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.

Sysbios function Clock_setTimeout(), Clock_getTimeout() fails by to great Timeoutvalues

Other Parts Discussed in Thread: CODECOMPOSER, SYSBIOS

Clock_setTimeout(value): value is Uint (16Bit) and can be set from 0 up to  65535

 Clock_getTimeout(): Returnvalue is Uint (16Bit) response only from 0 to 32767

At timeout values > 32767 the function returns starting increasing values (that is wrong) and after the "overflow" 32767 the return values decreases down to 0.

Expected: Returnvalues decreases from max. 65535 down to 0.

The used Toolchain with CodeComposer 5.3.0

v6.1.0 cgtools (TI Code-generation tools)
3.24.3.33 xdctools (XDCtools)
1.24.3.32 ipc (Inter-processor Communication)
6.34.2.18 bios (SYS/BIOS)

 

 

  • Philipp,

    When are you calling these functions?  If your application is actively processing Clock ticks, and you call these functions on an active Clock object, then you can expect to see changing values reported back by Clock_getTimeout().  Depending on the timing of making those calls relative to the Clock ticking, the value may be less or more than previously reported.

    There is a constraint for Clock_setTimeout() that you “Cannot change the initial timeout of instance that has been started.”  Are you doing this in your application?

    For reference, the source code for these functions can be found in your SYS/BIOS install, at a location similar to this: C:\ti\bios_6_34_01_14\packages\ti\sysbios\knl\Clock.c

    Scott

  • I using that Clock Object as an Timer which counts down. Cyclically a dispatch functions checks if the timer is expired. Other functions can set an new timeout and will overwrite the previous set timeout value.

    A new timeout value  will be set as following:

    Clock_setTimeout(CANopenTimer, value);
    Clock_start(CANopenTimer);

     My problem is, that all works fine, if the set timeout value will be smaller then 32768. I can check with Clock_getTimeout(...) and see that the value decreases, but if the set timeout value is greater than 32768 I see with the Clock_getTimeout() at the beginning an rising value until 32768 and than it decreases again. So I cannot differ at reading out the timeout value, if the actual counter is really lower than 32768 ticks, or it is still below 32768 ticks.  It looks like a problem between signed int16 and unsigned int16.

     

     

  • Before calling Clock_setTimeout() do you call Clock_stop()?  That is the constraint I was referring to: Clock_setTimeout() should not be called on an active Clock object.

  •  

     

    I added now also the Clock_stop() before modify the timeout value, but it didn't help.

    I did a small experiment:

    Set Timeout function as follows:

    Clock_stop(DebugClock);
    Clock_setTimeout(DebugClock, CAN_Debug_Clock);
    Logger_info1("Set Debugclock Timeoutvalue to %d ", (UArg)CAN_Debug_Clock );
    Logger_info1("Get Debugclock Timeoutvalue %d before Clock started", (UArg)Clock_getTimeout(DebugClock) );
    Clock_start(DebugClock);
    Logger_info1("Get Debugclock Timeoutvalue %d after Clock started", (UArg)Clock_getTimeout(DebugClock) );

     

    When I set a timeoutvalue of 25000 ticks I get following outputs of the logger:

    #0000000463 [ 0:17:23.605719] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 156: Set Debugclock Timeoutvalue to 25000
    #0000000464 [ 0:17:23.605725] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 157: Get Debugclock Timeoutvalue 25000 before Clock started
    #0000000465 [ 0:17:23.605734] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 159: Get Debugclock Timeoutvalue 25000 after Clock started
    #0000000466 [ 0:17:25.351723] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 23254
    #0000000467 [ 0:17:25.933727] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 22672
    #0000000468 [ 0:17:26.423731] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 22182
    #0000000469 [ 0:17:27.037735] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 21568

     If I set a timeoutvalue of 50000 I get this output:

     #0000000516 [ 0:19:10.718425] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 156: Set Debugclock Timeoutvalue to 50000
    #0000000517 [ 0:19:10.718432] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 157: Get Debugclock Timeoutvalue 50000 before Clock started
    #0000000518 [ 0:19:10.718440] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 159: Get Debugclock Timeoutvalue 15536 after Clock started
    #0000000519 [ 0:19:14.758555] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 19576
    #0000000520 [ 0:19:15.502458] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 20320
    #0000000521 [ 0:19:16.334567] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 21152
    #0000000522 [ 0:19:18.038475] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 22856

    ....
    #0000000574 [ 0:20:20.390890] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 30560
    #0000000575 [ 0:20:21.254896] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 31424
    #0000000576 [ 0:20:21.966942] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 32136
    #0000000577 [ 0:20:22.847003] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 32520

    from here it counts as expected down
    #0000000578 [ 0:20:23.742913] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 31624
    #0000000579 [ 0:20:24.734919] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 30632
    #0000000580 [ 0:20:25.750931] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 29616
    #0000000581 [ 0:20:26.494931] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 28872
    #0000000582 [ 0:20:27.230937] xdc.runtime.Main: "../base_tt3000/Communication/CAN/canopen_callback.cpp", line 168: Get Debugclock Timer 28136

     

     

     

     

  • Philipp,

    I wrote a small test program and was able to recreate the behavior you reported.  The problem is within Clock_getTimeout() when it is called on active clock objects.  I just filed a bug report for this: SDOCM00099468.  

    I can’t say for sure yet, but I expect a fix for this will be included in the next SYS/BIOS release in about two weeks.

    Thank you for reporting this bug, and sorry for the trouble that it has caused you.

    Scott

  • Scott,

    Thank you very much for the support.

    Philipp