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.

Reset Timer_getCount

Other Parts Discussed in Thread: LP-CC2652R7

I'm trying to get the Time of when a GPIO interrupt is signaled whenever I use Timer_getCount(); I get an incrementing count of the whole time the Program has ran. Is there a way to reset the time? I have tried closing the timer for each iteration of the loop but it seems that the Time saved on Timer_getCount(); stays. The Reference files have not said anything that I can find about resetting the overall timer count This is the Code I have so far:
Using LP-CC2652R7

void timerCallback(Timer_Handle myHandle, int_fast16_t status)
{

GPIO_disableInt(PORT5_RX16);
Display_printf(display, 0, 0, "Call Back Ended");
Ended = 2;
Timer_close(timer0);


}

void Rising(uint_least8_t index)
{

Time = Timer_getCount(timer0);
GPIO_disableInt(PORT5_RX16);
Timer_close(timer0);
GPIO_toggle(PORT5_TX17);
Ended = 1;
Display_printf(display, 0, 0, "Rising caught");


}

void *threadFxn0(void *arg0)
{

Display_printf(display, 0, 0, "The Program Has Started In Thread 0");


return (NULL);
}
void *threadFxn1(void *arg0)
{
START:

sleep(SampTime);
Ended = 0;
Display_printf(display, 0, 0, "Inside Rising Edge");

Timer_Params_init(&params);
params.period = 5000000;
params.periodUnits = Timer_PERIOD_US;
params.timerMode = Timer_ONESHOT_CALLBACK ;
params.timerCallback = timerCallback;

GPIO_setConfig(PORT5_TX17, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_LOW);
GPIO_setConfig(PORT5_RX16, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING);

timer0 = Timer_open(TIMER_0, &params);
Timer_start(timer0);
Display_printf(display, 0, 0, "Inter Enabled");
GPIO_enableInt(PORT5_RX16);

GPIO_setCallback(PORT5_RX16, Rising);
Display_printf(display, 0, 0, "CallBakc has been set");
sleep(5);

Display_printf(display, 0, 0, "risingEdge ended in %d ", Ended);
Display_printf(display, 0, 0, "time Stopped %d", Time);
sleep(2);

goto START;
return (NULL);
}

  • Hello Anthony Tran,

    I hope you are well. Have you tried to use Timer_CONTINUOUS_CALLBACK instead of Timer_ONESHOT_CALLBACK? Specifically reference the comments of Timer_CONTINUOUS_CALLBACK (in Timer.h), time timer in this mode resets automatically.
    “When the timer interrupt is triggered, the specified callback function will be called. The timer is automatically restarted and will continue to periodically generate interrupts until Timer_stop() is called.”

    Can you also try to breakpoint exactly what the timer0 is doing when you try to cancel/reset it? Some documentation that might be helpful is the Timer.h file reference, if you have already look at that reference there is GPT0 documentation; you can also look at the GPT0 in the register section while the code is running in debug mode (and check continuous refresh so we can see the numbers updating, click/check the two yellow arrows). There is also some documentation on GPTimer itself (GPTimerCC26XX.h File Reference), which might be an interesting read.

    I hope this helps!

    Thanks,
    Alex

  • There was no way to reset the Timer since it is a board variable that it gets the Count of not the timer itself so what I had to do was set two variables one reads the time exactly when the clock starts and then subtract it from when the time gets triggered

    int Time = 0;
    int TimeClose = 0;

    Timer_start(timer0);
    TimeClose = Timer_getCount(timer0);

    Time = (Timer_getCount(timer0)-TimeClose);

  • Yeah I tried and Figured out the Register it was recording was Under the AON_RTC TIME Register Which I don't know how to access I saw some functions inside GPTimer that would work but compile errors keep popping up when I try to use the Driver functions. So I instead used math to try to calculate it.

    Thank you for Replying