Oh, misread you a bit. How about this:
Instead of concentrating on timing and monitoring the input with the hardware, why not set up a 50% duty cycle PWM signal on an output, running continuously at 16hz, not needing any help from the program, all driven by the hardware.
Use the program (pulsin) to monitor the input and change the PWM registers to match the input once it gets above 16hz. Set the pulsin_max to a pulse width corresponding to 16hz at your oscillator speed (ie. OSC is 4mhz, pulsin_max value is 10us per count, pulsin_max = 6250).
With the PWM module, you can change freq and duty cycle, all you have to do is the math for it and change the registers to suit your needs.
Or am I still out in left field for what you're wanting...
Well, if you use a PIC that has a programmable clock source (a lot of the newer ones do), you could change that clock 'on-the-fly' to get it down to 16hz, or do it thru TMR interrupts until the freq gets up to a point where you can use the PWM. For one thing, I don't know which PIC you're going to use ! Also, 16hz is the minimum freq, what's the max?
Last edited by skimask; - 28th February 2007 at 01:55.
Bookmarks