SER_FREQ
x = divrnd((SER_FREQ / div), speed);
err = divrnd((SER_FREQ / div) * 1000, speed * x) - 1000;