How to calculate RPM, given timer frequency and counter on STM32
Your sample frequency is let's say 50 Hz.
Calculatel the difference of the encoder values. Than divide by 2000 (ppr). This means you get this many of revolutions in 50 Hz (or 1/50 = 0.02s).

As calculation

 RotationSpeed = (EncoderValue_Last - EncoderValue_Previous) / 2000 ppr) * Freq [Hz]


Assuming the previous encoder value was 30,000, the current 80,000, ppr is 2,000 and using 50 Hz (sample encoder data each 0.02 s):

 = (80000 - 30000) / 2000 * 50 = 1,250 RPM


In this article ppr and cpr are explained in more detail.