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.

cc26xx TI RTOS One shot clock event firing up before its time



hi 

I have created a one shot clock instance using following function

Util_constructClock(&timeoutclock, timeoutHandler,_new_timeout_interval,0, false, SBP_timer_EVT);

Util_startClock(&timeoutclock);

the timeout interval i kept is for 3 weeks which is in milliceconds equal to  "_new_timeout_interval = 1828800000;"

the interrupt should fire after three weeks but  actually it is firing uf after 14 hours as i tested. wht the problem is ?

is the interval value so long? or the interval variable is getting corrupt 

i saw the definition of Util_constructClock function it takes uint32 for interval it means it can go upto 2^32  or 7 weeks

urgent help is required in this regards

  • Hello Mohammad,
    Set instead a periodic interval of for example one hour and increment I counter until you get to three weeks.

    You need to set the timeout value relatively to the system clock tick period. For example if you want your argument in milliseconds you can:
    /* Set timeout in ms from now and re-start clock */
    Clock_setTimeout(hButtonClock, (milliseconds * (1000 / Clock_tickPeriod)));

    if you need the value in hours you could set up:
    Clock_setTimeout(hButtonClock, (hours * ((1000000*60*60) / Clock_tickPeriod)));

    WARNING: The timeout value is limited by the value type size of 32 bits. If 10 hours is chosen and the system tick period is 10 us the value of the argument given is then:
    (10*((1000000*60*60) / 10)) = 3.600D+09 = 0xD693A400

    Setting 10 hours will result in a value needing more than 31 bits to be represented in binary form and you are close to causing an overflow.
    log2(3.600D+09) = 31.74535
  • I have already implemented it using 2 hours clock timeout increment a variable and comparing of certain hours have been passed ..
    but the point is that i did watched uint32 in the "Clock_setTimeout" function it should be mentioned somewhere max value of timeout we can pass in that function :/
  • Hello,

    Nice.

    If you open help (F1) in CCS and search for the function you will find some details. Remember that the timeout is in clock ticks and the clock tick period (Clock.tickPeriod) is set in the project TI-RTOS config file (.cfg), meaning it can vary. When system tick period is set to 10 us the maximum duration will be:

    (2^32*10 us)/(1e6*60*60) = 11.930465 Hours. 

  • hi  

    thanks for the detailed reply

    I figured out the calculations also by applying break point   

    I think this calculation for max timeout should be mention in the guide or at least as a warning of overflow in the clock construction section of software developement guide