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.
|Thread starter||Similar threads||Forum||Replies||Date|
|A||Embedded C program - ADC and timer0 on PIC18||Homework Help||6|
|H||Do You Guys Program Embedded Systems With Threads ?||General Electronics Chat||0|
|embedded program||General Electronics Chat||4|
|Embedded C question. program memory and Ram storage||Embedded Systems and Microcontrollers||15|
|Embedded C question. program memory and Ram storage||Programmer's Corner||1|