Pulse generator issue
bmentink
Posts: 107
Hi All,
In the following code I have a problem.
The pulse works fine(I get my pre-pulse delay, then the pulse delay and the output is high during the pulse), but after that the cnt overflows and the output goes back high, then low again on the next overflow.
Can someone look at the code and let me know what I should do to fix this .. thanks.
Post Edited (bmentink) : 3/5/2010 6:23:54 AM GMT
In the following code I have a problem.
The pulse works fine(I get my pre-pulse delay, then the pulse delay and the output is high during the pulse), but after that the cnt overflows and the output goes back high, then low again on the next overflow.
Can someone look at the code and let me know what I should do to fix this .. thanks.
PUB Pulse(Pin, DelayuS, PulseuS) {{Pulse Pin high for PulseuS after delay of DelayuS.}} ctra[noparse][[/noparse]30..26] := %00100 ' Configure Counter A to NCO ctra[noparse][[/noparse]5..0] := Pin frqa := 1 dira[noparse][[/noparse]Pin]~~ ' Make output if DelayuS > 0 waitcnt((80_000_000/1_000_000 * DelayuS) + cnt) ' Wait for Delay uS phsa := -(clkfreq / 1_000_000 * PulseuS) ' Send the pulse
Post Edited (bmentink) : 3/5/2010 6:23:54 AM GMT
Comments
If you want a single shoot pulse, you have to wait until the pulse is finished and switch off the counter.