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.

TM4C1233H6PGE: 1MHz timer (1 usec ticks) on TM4C

Part Number: TM4C1233H6PGE

Stumbled upon previous discussions about the general purpose timers on these boards, and since I am not permitted to reply to any of them since they are now locked, I thought I would spawn a discussion about them again since we are stuck with no possibility of success on this it seems.

I have read everything possible on the subject, and am still left wondering, "How could they have gotten even the most basic functionality wrong?"  Hear me out.

All we need to do is the following:  From an 80MHz system clock, we need a 32-bit register to count, or tick, or however you express it (change) at a rate of 1MHz.  This means the LSB of the timer should increment once for every 1usec of time that has elapsed.  Conventional prescalers to timers would dictate a setting of 80 on the prescaler, which would fire the counter once every 80 system clock cycles.  We then need to be able to read the raw value of the timer throughout the lifecycle of the program, even if it wraps around.  Unsigned integer math easily allows this with overflow, as long as you only overflow once.  Since we never have a delay longer than 1 hr and 12 min (the max time of a 32-bit counter running at 1MHz), this has been doable in any other processor on the market.  That is it.  Nothing could be simpler than that.  I have nothing against TivaWare, the libraries, the effort that went into them.  I do not want this conversation devolving into a discussion about programming style.  Although I do not plan on accessing the registers directly, as I would like to use TivaWare libraries, I'd gladly do so if TivaWare doesn't natively support it.  Just tell us how this can be achieved.  Please.

We have no need for interrupts, and certainly do NOT want to configure a sys tick timer to interrupt our processor 1 Million times per second to increment a counter value in software.  That is absolute madness, as has also been suggested by TI on other threads.  Interrupts are absolutely 100% out of the question.  Multiplication and scaling of each read operation by querying the current system clock (or programatically specifying it intsead) is also absolutely out of the question.  The timer should be able to be configured to WHATEVER resolution and time base you choose.  Else, small delays of 1usec or thereabouts would also needlessly incur the overhead of said computations.  All I would like to do is read the current value of the 1MHz counter in software, and compare it with a previously known value by a simple subtraction (1 clock cycle), and a comparison against a duration (also one clock cycle), and none of this multiplication and division scaling crap to arrive at an answer.  Ok?

I would like someone to explain to me in very simple and no uncertain terms how this is possible using a TSMC processor of any flavor, with the so called general purpose timers.

  • Hi,

    Conventional prescalers to timers would dictate a setting of 80 on the prescaler, which would fire the counter once every 80 system clock cycles.

    There are two different types of general-purpose timers in TM4C123. One is a 16/32-bit GTPM and another is the 32/64-bit GPTM. Please see below. 

    The summary from the above is as follows. 

     1. If you want to use 16/32-bit GPTM in 32-bit mode, then you cannot use prescaler. 

     2.  If you want to use 16/32-bit GPTM in 16-bit mode, then you can use a 8-bit pre-scaler to extend the 16-bit counter.

     3.  If you want to use the 32/64-bit GPTM in 64-bit mode, then you cannot use prescaler.

     4. If you want to use the 32/64-bit GPTM in 32-bit mode, then you can use a 16-bit pre-scaler to extend the 32-bit counter. 

    With the above summary, your choice will be #4. You can use the 16-bit prescaler with a value of 80. When the prescaler counter counts down to 0 it will increment the 32-bit counter. You can potentially try #1 as well although it does not have prescaler. What you can do is when you read the counter value you can mask the lower bits. For example, you can mask with 0x4F (decimal 79). 

      

  • Thank you Charles.  The way this peripheral is documented and implemented is anything but straightforward, and so have been some of the the mocking responses in these forums which is terribly discouraging seeing as how much more work we have ahead of us.  We finally got it working by making the timer count down from UINT32_MAX and resetting itself periodically.  How such a simple use case was this difficult to set up is beyond our level of understanding.  We almost had to switch to a different processor over something this trivial.  Thank you again.