After a slight modification of my code, it seems that it's no longer skipping any incoming pulses, but if a pot reading of 0 corresponds to 1ms and a reading of 255 corresponds to 5ms, shouldn't that range stay the same even at a different RPM?Generally speaking, events are lost when the MCU is not fast enough to keep up with multiple events in rapid succession.
This is a common problem when the code uses polling techniques. If this is the case, there are ways to improve the performance of the system.
One way is to use interrupts.
Another way is to allow the hardware to do the counting. Many MCUs have internal timer modules that can be incremented directly from external clock pulses. Counting rates higher than 1 million events per second are not unusual.