Can you give more info?

What is the motor being used for?

How does the user change the speed?

Typical servo systems use a PID routine.

Henrik Olsson posted a great PID program example on the forum. As I recall the thread mentioned motors and DT interupts.