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.

Timer to generate specific number of pulses.



Hello everyone.

I am trying to implement a timer program on my TIVA TM4C123GXL launchpad. I want to generate a stream of pulses when the timer is enabled and the no.of pulses that should be generated should be equal to the value loaded in the timer. Is there any specific API that i can use from the Tivaware peripheral driver library?

please help.

Thanks in advance.

  • Hi,

    Your problem is not completely specified - may depend on frequency needed and the rest of your application. For what you say, you may use a timer in input-edge count mode - (counting down has more benefits than counting up). Please read carefully the corresponding paragraph, Timer module,  in the user manual. Maybe pulse generating could be better done with a pwm module, and the timer doing the rest.

  • Hello Nikhil,

    What is very unclear is what is the pulse width and frequency of repetition. How do you plan to control the same?

    In almost every case 2 timers (or a PWM and timer as Petrei mentioned) would be required.

    Regards
    Amit
  • Amit Ashara said:
    In almost every case 2 timers

    May I (loudly) agree w/the above suggestion of simplicity - get the job done - over complexity!   KISS - in other (strangely avoided, here) words.

    One timer configured in "counting mode" (agree that count-down usually is easiest) and the 2nd configured into PWM mode which enables near total control of pulse frequency and duty cycle.   And - when that timer's set to PWM mode - that PWM signal may be directly output to the MCU's pin.   (that's the only means to "directly" output a timer signal)

    As the others have well noted - further thought & consideration on your part is required...