[Question] How to generate finite number pulses?

Hi everyone,

I want to generate exactly 10 pulses.
If i just use simple analogWrite function, sometimes it couldn't generate complete pulse like the attached graph.
If i use timer1 lib, i have no idea to generate number of pulses i want.

Is there any easy way to generate finite number of pulse?

1-7-2015 4-21-20 PM.png

I found the solution to use FastWrite to creat pulse train.

http://forum.arduino.cc/index.php?topic=41228.0