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.

LAUNCHXL-CC1352R1: GPTimerCC26XX - resetting running load value to zero

Part Number: LAUNCHXL-CC1352R1

Hello,

I tried to clear the timer value for a long time and nothing seems to work. Closing and reopening timers doesn't work. Same thing goes to setting various values (load/match) using GPTimer.h and timer.h functions. Timer keeps old value. What is a proper way to reset timer before it calls an event or in case it is being stopped by button interrupt?

  • Is it possible to clear timer value by clearing timer specific register (if I want to clear GPT0_BASE than using value under 0x40010000 address)? If so, how can I execute this operation?
  • Hi KP,

    There is no support in the GPTimer driver to clear the free-running counter. Could you elaborate on your user case and why you need to clear the timer?
  • For example - I would like to send a message in specified time window (for example 5 seconds) but an error occurred. So the logical thing to do would be stopping timer and waiting for some calculated value until it is correct. Now correct value appears so we send a message and start timer once again. But... In current iteration of TI drivers, when you start timer again it starts from the previous stopped point. So if I send message and continue timer, it will start from, let's say, 3.9s point. Next message will appear in network once again in 1.1s, messing with whole windowing.

    Sending is an example. If I want to reset timer's callback or use it for any other task, I simply can't. It's free running value will be all wrong, messing with whole implemented logic. I am pretty sure resetting match value to lower value from it's current load value will force clock to tick until it fills up, roll back to 0, and then finally reach match value. Either I don't get the idea and miss the point of timers or there is something wrong.
  • Hi KP,

    As the current version of the GPTimer driver does not support "count down" mode, "restarting" the timer is a bit tricky.
    Have you looked into using the TI-RTOS Clock module instead of the GPTimer? This module also allow for the device to go into standby.
  • Is TI-RTOS really necessary? We are using No-RTOS version to save few of those extra bytes/kilobytes and would like to avoid your solution.

  • Hi KP,

    Using No-RTOS quite often result in a larger flash footprint as much of TI-RTOS are located in the device ROM while No-RTOS is not. Either way, Clock is available for No-RTOS as well as part of the dpl layer, look for ClockP.
  • So, just so I can get this right, you are telling me to use clock library based on CPU ticks instead of hardware timers built in CC1352R1 board? That's quite the workaround, and a little bit disappointing.
  • The Clock module is not based on CPU ticks, it is a software module based around the RTC Timer (which is very much a hardware timer). This means you can use it to also create timers that allow you to go into standby if possible.

    For example you can start a 5 second timeout and then go into standby to conserve power. This is not possible with the GPTimer driver as you will need to power on the GPTimer domain, increasing the idle power consumption.
  • So it does not apply additional heavy workload on CPU? I mean, is maintaining the clock and handling various clock callbacks not CPU "heavy"? Followup question because I didn't get really into it - ClockP still does not contain an explicit reset method. I can only assume that tick count reset may happen during restart, or more obviously, during reinitialization of said clock? There is an explicit tick count value but I can't assess if that is the thing I need the most - resetting free load value at runtime.
  • I would suppose this depends on the definition of heavy. The clock module itself are very lightweight and designed to be used as the system clock instance in TI-RTOS and NoRTOS. The GPTimer driver itself would include additional Hwi, Swi processing together with the application part of the code, this easily adds up a significant CPU workload as well.

    ClockP does not provide a reset feature as such. The clock objects timeout is re-calculated every time you issue start on a inactive clock. It does not track how much time that has expired, just when it should trigger if active.

    If you look at ClockP_start, you will see that the object in question will update it's "currTimeout" value with the "nowTick" + the timeout value. The "nowTick" that it gets from the TimerP API is simply the current value of the RTC clock.