Arduino DUE and stepper motor

hi ! I'm trying to write some code to drive a stepper motor drive which receive the direction and a train of pulses train .About the train of pulses I have some choice :

1- To use a timer interrupt hanlder and to use digitalwrite to create the pulses , in this way I can count the pulses but when I change speed , and then frequency , I have to change on fly the preset of the timer , it is working but I have some trouble ...for high frequencies when I use 3-4 timer the question is critical .....

2- Using a PWM peropheral controller with duty cycle fixed at 50% , but I have to change frequency and I must to count the pulses , I don't know how todo , maybe by reading a register ...

3- Using a VFO , voltage to frequency converter , but I have to count the pulses generated .I'm looking for a method to detect external pulses in counter of the SAM3 , but I don't how todo ....

The stepper motor is in a opened loop , this is because I don't have any encoder to count the pulses .

Somebody know what to do or to suggest me where to find seriuos documentation ? I'm reading the sam3 datasheet but it0s difficult to focus on this problem ...

What's wrong with the existing libraries?

I believe at least one of the major 3D printer firmwares has been ported to the Due. That will be doing a lot with stepper motors so maybe it is relevant to your unspecified problem.

yes I know , tinyG2 for example is an application for cnc machine . I would like to know how to implement a pwm and to be able to count the pulses , this is what I need...

You can use DDS techniques, run an interrupt handler at some high speed from a timer, and use phase-accumulation to generate your step frequency. Normally DDS (direct digital synthesis) is used for waveform generation, but a step pulse train is just another kind of waveform relly.

The advantage of DDS is that you control the frequency directly, and it runs in the background in an ISR. This makes it relatively simple to drive > 1 motor simultaneously.

nice. How to get access to DDS ?
Pratically what I’m doing is to drive 2 stepper driver with TB6660 drivers.
I’m studing the linear interpolation as vector and I calculate the speed of two axis X and Y
Of course the speed is different for the motors, and for now I have just implemetned two timer interrupt handler .When the speed changes, then the frequency changes, I change the preset of the timers and I restart them .At high frequency it seems work well , I’m watching with my oscilloscope , I’m waiting for the steppers …In the interrupt I can also to count the pulses .
This method is running but when the frequency is about 2-3 KHz , it means to get the interrupt timer every few microseconds …
Do you have some documentations about DDS tecniques?