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.

Configuring Timer on Tiva Lauchpad



Hi.

I am configuring the timer of 32  bits as periodic and count-down but I need to know when it reach 0, but I don´t  want to use interrup.

I am using library timer.h  but  I  don´t  know  what  function  can  do  it??? I  tried  some  and  nothing....

Plaese I need help...

Regards.

  • Hello Noe

    Note that the CPU may or may not always read the Running count value as 0 due to processor overhead, so I "must" insist using Interrupt. However if you do not want to us the interrupt you can still poll on the GPTMRRIS bit which will get set. Do not forget to clear the bit before start of timer and after every time your application reads it as 1.

    Regards
    Amit
  • Note that the CPU may or may not always read the Running count value as 0 due to processor overhead, so I "must" insist using Interrupt.

    Not only is polling the timer a tremendous waste of performance, you will most likely miss the zero state of timer for any non-trivial clocking rate. And if it does single-shot counting, you don't know how far you missed the 1->0 transition.

    Interrupts aren't that difficult. Actually, they are the backbone of real-world microcontroller software ..

  • Hi Amit.

    Thanks for your recommendations. I will try use the interrupt.

    But I am using TivaWare and library timer.h then how I can check GPTMRRIS using the library timer.h???

    Reagards
  • Hello Noelia

    The API to use is TimerIntStatus(TIMERx_BASE, false). The TIMERx_BASE is the define of the timer base address in the CPU memory map and the return value of the API is the bits from the GPTMRIS register. Some logical arithemetic must still be done to check for the correct bit being set or clear.

    Regards
    Amit
  • Hi Amit.

    ok, but what means the value false into the API TimerIntStatus(TIMERx_BASE, false)?? I saw in the library timer.h that this is bMasked but I don´t understand what means??

    Then for I use this API TimerIntStatus I must enable the interrupt or not is necesary??

    I configure my timer as:

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); //Enable the peripheral

    ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); //Configure 32-bit periodic timer (down count)
    ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, g_ui32SysClock);

    ROM_TimerEnable(TIMER0_BASE, TIMER_A); // Enable the timer

    Regards.
  • Hello Noelia

    As you may see in the document for the driverlib, "false" means reading the GPTMRIS while "true" means reading the GPTMMIS.

    If you still wish to poll the GPTMRIS using the TimerIntStatus then be sure to clear the Interrupt Status bit using TinerIntClear API call before calling TimerEnable. Also it would be strongly advised to reset the timer before enabling it. Please see ISSUE#03 in the following post

    e2e.ti.com/.../374640

    Using the API TimerIntStatus does not require interrupt to be enabled, but then as f.m. mentioned, using interrupt is always the best strategy to save CPU compute clock cycles.

    Regards
    Amit
  • Hi Amit

    Ok I will do it.

    Thanks you very much

    Regards