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.

CC2340R5: LGPTimer

Part Number: CC2340R5

I want to use LPGTimer , so I write the test code , and set counterTarget = 48M ( 1 s ),but It only enters TimerCallback() every second, but stays in TimerCallback() without jumping out ( 3 ~ 6 ms ).There is no timing effect

However, I set sleep() and LGPTimerLPF3_stop to enter TimerCallback every second.

So what is the function of setting CounterTarget? Isn’t it just using sleep(1) to set the timer?

PS.I use an oscilloscope to view the GPIO_toggle , and My SDK is 7_10_00_35

  • Hi Ryan,

    The first code image appears to leave mainThread without performing any looping function, which could be causing the behavior to stay in the timer callback instead.

    The second code image applies sleep, and if this is causing the device to enter standby then it effectively disables the LGPTimer as high-frequency clocks are turned off (see Table 9-2 Power Modes of the datasheet).  This is also mentioned in the LGPTimer TI Driver API in the Power Management section.  Thus you should either use sleep to enter standby mode for a second, or implement the LGPTimer using a while loop.  You can also pend/post semaphores to accomplish thread synchronization.  This behavior is demonstrated in the uart2callback example.

    Regards,
    Ryan

  • Does this mean that the CounterTarget is set to allow the Timer to enter the TimerCallback? I still have to use while() and sleep() to enter the callback regularly.

  • CounterTarget sets the value that the timer counts up to before raising the interrupt bit, resetting the count, and starting the process again (given current settings shown, i.e. count up periodically).  You can learn more about the implementation from <sdk_directory>\source\ti\drivers\timer\LGPTimerLPF3.c

    Regards,
    Ryan