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: EDGE COUNTER EXAMPLE CODE

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

Hello all,

 Driver library of TM4c have timer example . GPTM module of Driver lib is too difficult to understand to beginner . Can any body help me  in following ?

1.Setup  at least 16 bit counters on PM port  (PM0 to PM6)?

2. Enable the counter

2.Read the value of counts per seconds .

3.Reset the counter 

Thanks you

Abhay Shekhar 

  • Hi,

    1.Setup  at least 16 bit counters on PM port  (PM0 to PM6)?

    Refer to the datasheet. If you want to use PM0-PM6 then you need to use timer module timer2_A, timer2_B, timer3_A, timer3_B, timer4_A, timer4_B and timer5_A. 

    In example C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\timer_edge_capture, it uses PL4 and PL5 for Timer0_A and Timer0_B. You just need to reference the code in the example and change for PM0 and PM1. I strongly suggest you start with just one capture, for example just PM0 using timer2_A. Get just one input capture to work first before you venture into 7 input captures simultaneously. I will greatly reduce the complexity of debugging. 

    2. Enable the counter

    To enable a counter, you basically call TimerEnable() API. Refer to the example. I think the example is very basic and explains everything. For example, if you want to enable Timer2_A and Timer2_B for PM0 and PM1 then you would just enable the counter by calling:

    TimerEnable(TIMER2_BASE, TIMER_BOTH);

    2.Read the value of counts per seconds .

    Refer to the peripheral driver user's guide https://www.ti.com/lit/pdf/spmu298 for all the APIs and the example code. You just call TimerValueGet() to read the count.

    3.Reset the counter 

    The counter can either count up or count down depending on your configuration. In the example, two timers are set up for up counter. See below code. This means the counter starts at 0 and once the counter reaches the match value, the counter will automatically reset to 0.  In another word, resetting the counter is done by the hardware itself. The match value is configured by you as to how many edges you want to count before generating an interrupt. Again, refer to the datasheet and the example. 

    //
    // Initialize Timers A and B to both run as periodic up-count edge capture
    // timers. This will split the 32-bit timer into two 16-bit timers.
    //
    MAP_TimerConfigure(TIMER0_BASE, (TIMER_CFG_SPLIT_PAIR |
    TIMER_CFG_A_PERIODIC |
    TIMER_CFG_A_CAP_TIME_UP |
    TIMER_CFG_B_PERIODIC |
    TIMER_CFG_B_CAP_TIME_UP));