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.

Snapshot mode on Tiva timer

Other Parts Discussed in Thread: TM4C123GH6PM

Hi,

I'm trying to understand that value of the snapshot mode in the Tiva C GPTM.

The docs say "In periodic, snap-shot mode (TnMR field is 0x2 and the TnSNAPS bit is set in the GPTMTnMR

register), the value of the timer at the time-out event is loaded into the GPTMTnR register and the
value of the prescaler is loaded into the GPTMTnPS register." 

As I understand it, a time-out event always occurs at either the value in GPTMTnILR or 0, depending on whether you are counting up or down. Won't the snapshot always be one of those values (depending on up or down counting)?

thanks,

ed

--

  • Hi Ed,

    Please try to be more specific about the document. I assume it's the datasheet, and from your quote i found the text (i assume). Also which part are you using?

    Let's assume it's the TM4C123GH6PM datasheet:

    The snapshot value, that does not work in one shot timer - like the datasheet for the TM4C123GH6PM says under "11.3.2.1 One-Shot/Periodic Timer Mode" -  at the time of a timeout the value of the timer is loaded into the GPTMTnR register. So in countdown mode 0 is loaded, in count-up mode the value of GPTMTnILR is loaded.

    Now if you search further "snapshot" in the datasheet you get more info:

    In GPTMTAMR for example, in the bit TASNAPS it says:

    If Timer A is configured in the periodic mode, the actual

    free-running, capture or snapshot value of Timer A is loaded at

    the time-out event/capture or snapshot event into the GPTM

    Timer A (GPTMTAR) register. If the timer prescaler is used,

    the prescaler snapshot is loaded into the GPTM Timer A

    (GPTMTAPR).




     


    Meaning that the same would happen at a capture event (the load of the timer value into GPTMTnR, in this case GPTMTAR, register. 



  • Luis,

    Thanks for the quick reply and my apologies for not being more specific about which part.

    It is indeed, the TM4C123GH6PM on the Tiva Launchpad that I'm working with.

    After I posted the original question, I saw the section that you quoted about the TASNAPS bit, but it still left me wondering...

    Where I am now is not knowing if I need to use the TASNAPS bit to do input time capture (where I would see a purpose).

    My confusion comes from reading the initialization sequence described in section 11.4.4, which makes no mention of the TASNAPS bit in describing how to do the setup for Input Edge Time Mode. Do you know if  that initialization sequence correct?

    If you don't need to set the TASNAPS bit to do input time capture, and using TASNAPS in Periodic Timer Mode always yields either 0 or the value from GPTMTnILR (both of which you already know) we are back to what I was trying ask initially "what is the value of TASNAPS?"

    I feel pretty confident that the designers didn't throw in random logic without a value so I'm hoping to understand how to use it to good effect.

    thanks,

    ed

    --

  • Hi Ed,

    First, the TASNAPS is just for configuration. It holds 0 or 1, snapshot mode OFF or ON. The holding of 0 or GPTMTnILR is in GPTMTnR. It's important to get the registers right.

    About that initialization on 11.4.4 it is correct for the use described. You can, or not, use the snapshot mode!

    The use of this mode can be aid some applications. On "11.3.2.4 Input Edge-Time Mode" check the "Note" under "Figure 11-4. 16-Bit Input Edge-Time Mode Example", it notes, maybe not distinctively enough the use of the snapshot mode.
    The timer generates a interrupt in capture, but you do have some delay between the call and when you actually get the value from the free running timer, correct? Entering the interrupt handler does take time + checking getting the value from the GPTMTnV also takes a bit (really not that much but it's still a bit). If you use TivaWare, which you should do to avoid problems that come with direct register access, getting that value takes more time. 
    But wait! In snapshot mode the value of the timer is saved when the capture occurs! So you don't have any of that problem and it's the way to get the best precision.


    Snapshot mode is just a extra mode to the basic modes - periodic, input-capture - that saves automatically (and fast) the value of the timer in GPTMTnR when a particular event happens.

  • Hello Luis,

    Thanks for carrying it forward so nicely. Indeed what you have mentioned is "true"

    Regards
    Amit
  • Hi Amit,

    I think i finally found the forum configuration to get notifications in posts that i participate - i was actually bored/insomniac and kept hitting refresh time to time but i can't be doing that.

    Thank you for confirming, always good to get confirmation from more experienced users of the Tiva. Glad i could help.
  • Luis,
    Thanks for bearing with me...
    I understand that the TASNAPS bit is for configuration and the 'snapshot' value will be in GPTMTnR.
    What puzzles me is that there is no mention of the TASNAPS bit in the context of the Input Edge-Time mode either in the description of the initialization sequence in section 11.4.4 nor in the example in 11.3.2.4.

    In the example that you cited (11.3.2.4), it says "When the selected input event is detected, the current timer counter value is captured in the GPTMTnR and GPTMTnPS register and is available to be read by the microcontroller." Nowhere does it indicate that the TASNAPS bit needs to be set to get that effect.

    I have a fair amount of experience with input capture systems on other microcontrollers and from my understanding the whole point of a 'capture' is to grab the time in hardware so that the accuracy of the time measurement does not depend on how long it takes you respond to the interrupt. Without doing the capture of the timer value, you have nothing more than an event interrupt. Doing timing from that kind of interrupt does depend on how quickly your code responds.

    I had already read the 'Note' that you referenced at the end of the example and I don't see how it relates to TASNAPS. It seems to me to be explaining how to deal with a pair of edges that might have an interval between them that is longer than the roll-over (or time-out) interval configured for the timer.

    I have seen examples of using the Input Edge-Time mode that do not set TASNAPS, so I'm still wondering under what conditions it is useful.

    thanks,
    ed
    --
  • Hi Ed,

    I already referred where it would be useful. Please read again. If you still don't understand later i will try to explain more, right now i can't.

    It's a bit weird that the snapshot mode is not used in some examples i agree
  • Hello Ed

    I checked the timer module and it seems that for the main timer (not the prescaler) it is not required to be set for capturing the time event of the signal change,

    Regards
    Amit