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.

How to generate single pulse with desired duration using AM3517 GP Timer?

Other Parts Discussed in Thread: AM3517, OMAP3530

I need generate single pulse with desired duration using GP Timer, preferable without use of interrupts.

AM3517 TRM says, that GP timer has "one-shot" mode - automated stop of timer after overflow occurs. But in the same place it is told that in the PWM mode first "match event" is ignored, if it comes before first overflow.  It seems doesn't allow to use PWM toggle mode in conjunction with "one-shot" mode to generate single pulse...

Is there a way to generate single pulse with programmed duration using "one-shot" mode without using of interrupts? Or the only way to do it - to use two cycles of timer: first overflow toggles PWM output to ON state, then interrupt service routine clears "autoreload" bit to enter one-shot mode, then second overflow toggles PWM output to OFF state and stops timer?

It is planned to use in the Linux kernel driver environment for control of the power device therefore use of interrupts is undesirable - Linux doesn't guarantee determined time of reaction for an interrupt event, and I am afraid of an extra pulse due to heavy load of CPU by other tasks.

  • somebody knows the answer?

  • I guess that one-shot mode of the GP timer should enable to generate one single pulse.
    I found the below GP timer Linux driver implementation that suggest that one-shot does work:
    http://www.kunen.org/uC/beagle/omap_dmtimer.html
    This is for OMAP35x but I believe on AM3517 the GP timer is comparable Could you try it out?

    Anthony

  • Yes, I'm alredy use this set of functions (omap_dmtimer_*).

    Yes, AM3517 timer is the same timer, as in the OMAP3530.

     I succeed to generate only single pulses with duration of one timer's FCK cycle. But I need longer pulse duration - N timer's FCK clocks, where N is programmable for each pulse (as with the PWM modulation, but not continuous - with single pulses only when needed)

  • Hi Sergey,

    Is this timer routed to a pin or you use the timer event internally?

    If the goal is to toggle a pin may be you could use:
    - an extra HW that will extend the duration of the pulse
    or
    - use 2 pulses and an external flip flop. The delay between 2 pulses correspond to N timer's FCK period. The 2 pulses will toggle the flip flop to have a N timer's FCK period.

    Hope it helps.

    Anthony

  • I use "gptX_pwm_evt" pin as output, and no external additional hardware present in the system.

    To produce two pulses it  is also necessary to use interrupts. Thus most likely there is only one way - a PWM mode and use of interrupts for timer stop....

  • The problem is solved.

    I added new function to dmtimer.c which loads the reload register to the new value and starts timer from end of count:

    void omap_dm_timer_set_load_start_from_end(struct omap_dm_timer *timer, int autoreload,

                                unsigned int load)

    {

         u32 l;

     

         l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);

         if (autoreload) {

             l |= OMAP_TIMER_CTRL_AR;

             omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load);

         } else {

             l &= ~OMAP_TIMER_CTRL_AR;

         }

         l |= OMAP_TIMER_CTRL_ST;

     

         omap_dm_timer_write_reg(timer, OMAP_TIMER_COUNTER_REG, 0xFFFFFFFD);

         omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);

    }

    This routine starts timer from end of it's count, then an interrupt is generated and counter is reloaded, timer triggers pwm output first time, then counter expires 2'nd time, timer triggers pwm output again once, 2'nd interrupt is generated  which stops the timer. Thus the necessary impulse is generated.

  • I have a same problem with you.
    I want to generate a single pulse which can program a duration time.
    I cannot use irq,because The pulse duration I want to generate is 500ns ~ 1000ns .
    I can generate a one tick pulse,but cannot generate  N time pulse.

    Could you tell me about whole of your program?