OK. Since you are using timer 1 anyway, how about this... It will need a little ML, but not much. When your input goes high, set your output high. Set timer1 with no prescaler,to interrupt on overflow, and put overflow - 50 in it's register. When it overflows, the ML interrupt routine adds 15 to your pauseus variable, and starts it from overflow - 50 again. This goes on until your input goes low. Use pauseus with the variable you have been adding to, and when it runs out, flip your output low too. If you are running at 4 MHz, this will give you 50 uS resolution. The upper limit will be dictated by the 16 bit size of timer1. You should be able to do this up to about a 110 mS pulse length.
You might be able to write it all in PBP, but at the lower pulse widths, it might not have great resolution.
Bookmarks