Quote Originally Posted by geckogrotto View Post
I do have another question tho

On a 4mhz chip how long would this take to add 1 and get back to while?

while GPIO.4=0
Nosig = Nosig + 1
wend
So, in my world:
one channel, idles low, 1-2 ms high going pulse, repeats every 20ms, no matter the high going pulse width

In your world:
one channel, idles high, 5-20ms low going pulse, repeats every 15-30ms depending on the low going pulse, minimum of 10ms idling high...

Is that good? Sure, you can get a freq off that.
And what I meant by the end result was...what is this whole thing running off of, what's it supposed to do in the end? Is this a new egg frying machine

As far as measuring the time in the above example, one way I do it is to write a program that is only the above example. I label every line. When done, I go back into the generated .lst file, find those labels, and write down the hex address for each label. Most instructions take 1 cycle (ie. 1us @ 4mhz clock rate), jumps, goto's, branches, etc. take 2 cycles (ie. 2us @ 4mhz clock). So, in your example (and I'm guessing here):

while GPIO.4=0 a 'bit test, skip if clear' instruction 1 or 2 cycles depending
Nosig = Nosig + 1 an 'add' instruction, 1 cycle
wend[/QUOTE] a 'jump' or 'goto', should be 2 cycles

So, this could be anywhere from 4 to 5 cycles depending on conditions. However, there are also bank bits to set sometimes if your code goes over code boundaries (not applicable in the 18F world) which will add 1 or 2 cycles. So, now you're at anywhere from 4 to 7 cycles per loop. Best way to figure it out is how I described it earlier. Or use MPLAB's IDE simulator and use the 'stopwatch' function. Or just build a prototype that'll work off it and toggle an led and 'scope those leds for freq.