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.

TM4C1294NCPDT: How to clear GPTMTAR after TAEN bit cleared in GPTMCTL register when the timer works in Input Edge-Time mode

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: EK-TM4C1294XL

Hi, Mr Expert

     I need to clear the value in the GPTMTAR register when the timer works in Input Edge-Time mode, the timer works in up-count direction from 0 when the TAEN bit is set for the first time, once the edge is detected, the counter value is captured in GPTMTAR register. But I found after the first edge is captured, I can not clear the value either in GPTMTAR or GPTMTAV register. when I disable TAEN and then enable it, the value in GPTMTAR does not reset to 0.

    Is the timer designed to work this way or there is a solution to reset the TAR or TAV register somehow? 

  • Not sure why you would need to clear GPTMTAR, but have you tried writing 0 to GPTMTAV?

  • Hi, Bob

        Because I only need to measure the width when the voltage is on the CCP pin is low, the time for high voltage is not cared, the easiest way is to clear the TAR each time before the timer is started, when the edge detected, I only need to read the value in the TAR register.

        When I tried to clear the TAV register directly in debug mode with TAEN cleared, I found the value in the TAV can not be cleared. looks like it is a read only register.

  • Data sheet (SPMS433B) Table 13-8 suggests that those registers are cleared (appropriate to mode) on a TxEN toggle. How are you testing this? There's also Erratum GPTM#13 [Ref Errata (SPMZ850G) p. 30]. Are you using the Alternate clock source?

    That said: I've written a number of timer-capture applications, and I never reset the counter to 0, rather I capture two consecutive events and subtract. Doing it that way avoids the (software) latency between the triggering event and starting/clearing the timer.

  • Bruce, Thank you! I agree.

    Steven,

    There is an example doing what Bruce suggests in TivaWare:

    C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\timer_edge_capture

  • Hi, Bob/Bruce

        Thanks for your help, the issue looks like solved, I will come back to you any further questions,