I have a sketch that has several independent selectable functions: one of which is a simple frequency counter that uses pulseIn(8,HIGH) plus pulseIn(8.LOW) to measure the pulse period. It works well at low frequencies but around 100Khz and up it varies a lot. Doesnt this pulseIn() function use Timer1? The reason I ask is that I have another function in the sketch which is a pulse generator, that I think also uses counter 1, based on the commands
and pulse width using: pwmWrite(PULSE, pulse_width);
You would think that only one of these functions should work at a time, and you would get an error message for trying to compile both simultaneously. Yet I've connected the output of PulseGen to the FreqCounter and it works, however that also is a flaky around 100Khz and up. I've spent a good time trying to figure out what causes the variations in the measure frequency, but havent found anything.
I wish there was a reference to all these libraries that defined their limitations & the hardware they require.
Any ideas about whats going on?