cancel
Showing results for 
Search instead for 
Did you mean: 

Outputting a fixed number of pulses.

stuart2399
Associate II
Posted on October 01, 2008 at 05:36

Outputting a fixed number of pulses.

3 REPLIES 3
lanchon
Associate III
Posted on May 17, 2011 at 12:46

you could use PWM with the period interrupt prescaler.

stuart2399
Associate II
Posted on May 17, 2011 at 12:46

Hi all,

I wish to output a fixed number of square wave pulses (e.g. 100) at a fixed frequency (e.g. 1 MHz). Using the example values, this effectively would mean toggling a port pin every 500ns!

How would I go about this, without toggling port pins directly? I assume this is too fast to use interrupts (especially as I have other time critical routines running).

I have available on my circuit: TIM1 and its output port pins & DMA channels.

Any advice would be gratefully received.

Cheers.

:o

niklas
Associate II
Posted on May 17, 2011 at 12:46

PWM seems like a good idea.

If you use TIM1 you can use the REP register to get an interrupt after the 100 pulses (to shut the PWM down).

/Niklas